Skip to content

Commit

Permalink
ci: enhance CI with multi-version Go testing and caching
Browse files Browse the repository at this point in the history
- Rename job from `testing` to `test`
- Add matrix strategy to test on multiple Go versions (1.21, 1.22)
- Set up Go environment variables `GO111MODULE` and `GOPROXY`
- Replace `actions/checkout@v4` with `actions/setup-go@v5` for Go setup
- Add caching for Go build and module paths using `actions/cache@v4`
- Add `ref` parameter to `actions/checkout@v4`
- Add flags to `codecov/codecov-action@v4` for matrix os and Go version

Signed-off-by: appleboy <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed May 31, 2024
1 parent e405b03 commit 24c1eda
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,46 @@ jobs:
with:
dockerfile: docker/Dockerfile

testing:
runs-on: ubuntu-latest
container: golang:1.21-alpine
test:
strategy:
matrix:
os: [ubuntu-latest]
go: [1.21, 1.22]
include:
- os: ubuntu-latest
go-build: ~/.cache/go-build
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
env:
GO111MODULE: on
GOPROXY: https://proxy.golang.org
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: add git make command
run: |
apk add git make curl perl bash build-base zlib-dev ucl-dev
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: testing
- uses: actions/cache@v4
with:
path: |
${{ matrix.go-build }}
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Tests
run: |
make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
flags: ${{ matrix.os }},go-${{ matrix.go }}

commitlint:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 24c1eda

Please sign in to comment.