IND-2293 test.yml updated with unit test coverage and linting #145
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-hclog | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
go-version: | |
- 'oldstable' | |
- 'stable' | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Checkout | |
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
- name: Cache GolangCI-Lint | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/golangci-lint | |
key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: golangci-lint-${{ runner.os }}- | |
- name: Cache Go Modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: go-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: go-mod-${{ runner.os }}- | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 | |
with: | |
version: latest | |
args: --timeout=5m --verbose | |
only-new-issues: true | |
- name: Ensure coverage directory exists | |
run: mkdir -p $(dirname ./coverage.out) | |
- name: Run test and generate coverage report | |
run: go test -v -coverprofile=.\coverage.out ./... | |
- name: Upload coverage report | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 | |
with: | |
path: .\coverage.out | |
name: Coverage-report-${{ matrix.os }}-${{ matrix.go-version }} | |
- name: Display coverage report | |
run: go tool cover -func=.\coverage.out | |
- name: Build Go | |
run: go build ./... |