From 65d453beceedac4bede0b88dfe802d13f3efb3b0 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 14 Aug 2024 23:10:22 +0800 Subject: [PATCH] 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 --- .github/workflows/lint.yml | 42 +++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 416c144..d1b2351 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 }}