Skip to content

ci: download dependencies and ensure go.mod file is consistent #25

ci: download dependencies and ensure go.mod file is consistent

ci: download dependencies and ensure go.mod file is consistent #25

Workflow file for this run

---
on: [push, pull_request]
name: Test
jobs:
# Run tests for the oldest supported Go version and OS first.
pre-test:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go${{ matrix.go-version }}-
- name: Download dependencies
run: go mod download
- name: Check go.mod
run: |
go mod tidy -v
git diff --exit-code
- run: go test ./...
# Main test suite for all Go versions and OS.
test:
needs: pre-test
strategy:
matrix:
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x, 1.23.x]
os:
- ubuntu-22.04
- ubuntu-20.04
- windows-2022
- windows-2019
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go${{ matrix.go-version }}-
- name: Download dependencies
run: go mod download
- name: Check go.mod
run: |
go mod tidy -v
git diff --exit-code
- name: Run tests (with race detector on Linux)
if: matrix.os != 'windows-2019'
run: go test -race ./...
- name: Run tests (without race detector)
if: matrix.os == 'windows-2019'
run: go test ./...