ci: enhance CI workflow with matrix testing and caching

- Replace the testing job with a more structured test job using a matrix strategy for different OS and Go versions.
- Update the Go setup action to version 5.
- Add caching for Go build and module paths to improve build performance.
- Include a step to check out the code with the specific GitHub reference.
- Remove the previous setup tools step and replace it with the new structure.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2024-08-14 23:10:22 +08:00
parent 45cfcd8bb1
commit 65d453bece
+32 -10
View File
@@ -28,20 +28,42 @@ jobs:
with:
dockerfile: docker/Dockerfile
testing:
runs-on: ubuntu-latest
container: golang:1.22-alpine
test:
strategy:
matrix:
os: [ubuntu-latest]
go: [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
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: setup related tools
run: |
apk add make build-base zlib-dev ucl-dev
- 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 }}