Skip to content

Add code coverage CI job #24

Add code coverage CI job

Add code coverage CI job #24

name: FreeLRU
on:
push:
branches: [main]
pull_request:
branches: ["**"]
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable"]
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
- name: Linter
run: |
go version
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
make lint
test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable", "1.18.10"]
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
- name: Run Test
run: |
make check
bench:
name: Bench
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable"]
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
- name: Run Benchmarks
run: |
GOMAXPROCS=100 make bench
coverage:
name: Coverage
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 2
matrix:
go: ["stable"]
permissions:
contents: write
steps:
- name: Set up Go ${{matrix.go}}
uses: actions/setup-go@v4
with:
go-version: ${{matrix.go}}
check-latest: true
id: go
- name: Check out
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Build
run: |
go install
- name: Run Coverage
run: |
go test -v -cover ./... -coverprofile coverage.out -coverpkg ./...
go tool cover -func coverage.out -o coverage.out # Replaces coverage.out with the analysis of coverage.out
- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v1
# if: ${{ runner.os == 'Linux' && matrix.go == '1.17' }} # Runs this on only one of the ci builds.
with:
green: 80
filename: coverage.out
# - name: Pull in remote changes
# run: git pull --rebase
- uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
with:
commit_message: Apply Code Coverage Badge
skip_fetch: true
skip_checkout: true
file_pattern: ./README.md