Skip to content

GitHub Actions: upgrade actions setup-go, checkout #36

GitHub Actions: upgrade actions setup-go, checkout

GitHub Actions: upgrade actions setup-go, checkout #36

Workflow file for this run

name: Test and coverage
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
go-version:
- 1.21.x
- 1.20.x
- 1.19.x
- 1.18.x
- 1.17.x
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v2
if: matrix.os != 'windows-latest'
with:
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-{{ hashFile('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download dependencies
run: go mod download
- name: Run coverage
# Powershell Core has problems with '=': -coverprofile=coverage.out
run: go test -v -race -coverprofile coverage.out -covermode atomic ./...
- name: Upload coverage to Codecov (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: bash <(curl -s https://codecov.io/bash)
- name: Upload coverage to Codecov (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install codecov
codecov.exe -f coverage.out