Setup pipeline jobs to run code tests & linters in gha/ci #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Code Checks | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: | |
# Required: allow read access to the content for analysis. | |
contents: read | |
# Optional: allow read access to pull request. Use with `only-new-issues` option. | |
# pull-requests: read | |
# Optional: Allow write access to checks to allow the action to annotate code in the PR. | |
checks: write | |
jobs: | |
linters: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go: [ '^1.22' ] | |
name: Go ${{ matrix.go }} linters | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go ${{ matrix.go }} | |
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: ${{ matrix.go }} | |
check-latest: false | |
cache: false | |
id: go | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 | |
with: | |
version: v1.57 | |
# Optional: golangci-lint command line arguments. | |
# | |
# Note: By default, the `.golangci.yml` file should be at the root of the repository. | |
# The location of the configuration file can be changed by using `--config=` | |
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 | |
# Optional: show only new issues if it's a pull request. The default value is `false`. | |
# only-new-issues: true | |
# skip-cache: true | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go: [ '^1.22' ] | |
name: Go ${{ matrix.go }} checks | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go ${{ matrix.go }} | |
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: ${{ matrix.go }} | |
check-latest: false | |
cache: false | |
id: go | |
- name: Test | |
run: go test -v -coverprofile=coverage.out ./... | |
- name: Coverage report | |
id: gocoverage | |
run: | | |
go tool cover -func=coverage.out > coverage.txt | |
coverage=$(cat coverage.txt) | |
echo "$coverage" |