Skip to content

Commit

Permalink
update github actions workflow file to test different golang versions
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesKaufmann committed May 24, 2024
1 parent ac2bca7 commit b00aaf9
Showing 1 changed file with 46 additions and 30 deletions.
76 changes: 46 additions & 30 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,52 @@ on:

jobs:

build:
name: Build
# Test the latest go version
# and upload the test coverage.
test_latest:
name: Go latest stable

runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
check-latest: true

- name: Checkout code
uses: actions/checkout@v4

- name: Build
run: go build -v .

- name: Test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic

- uses: codecov/codecov-action@v4
with:
files: ./coverage.txt
token: ${{ secrets.CODECOV_TOKEN }}

# Test the latest three golang version
# on different operating systems.
test_versions:
strategy:
matrix:
go: ['1.20', '1.21', '1.22']
os: [ubuntu-latest, macos-latest, windows-latest]
name: Go ${{ matrix.go }} on ${{ matrix.os }}

runs-on: ${{ matrix.os }}
steps:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Checkout code
uses: actions/checkout@v4

- name: Test
run: go test ./... -v -race -cover

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v .

- name: Test
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic .

- name: Upload Coverage report to CodeCov
uses: codecov/codecov-action@v2
with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage.txt

0 comments on commit b00aaf9

Please sign in to comment.