From 776e6470d3244730c129c65989416eda5b8e7fd4 Mon Sep 17 00:00:00 2001 From: Jason Lyu Date: Wed, 21 Aug 2024 05:27:20 +0800 Subject: [PATCH] Feature(actions): add testing (#378) --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/docker.yml | 8 +++---- .github/workflows/linter.yml | 6 ++++-- .github/workflows/release.yml | 14 ++++++------ .github/workflows/test.yml | 31 +++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f06de6d..a1c9725 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -38,4 +38,4 @@ jobs: uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 \ No newline at end of file + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1c9a19b..e7a8c61 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,13 +12,11 @@ on: - '*' jobs: - - build: - name: Build + docker: + name: Docker runs-on: ubuntu-latest steps: - - - name: Check out code into the Go module directory + - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 1cff6be..9ec1b5c 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -11,10 +11,12 @@ on: pull_request: jobs: - lint: + linter: + name: Linter runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a87bb52..301beb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,11 +10,11 @@ on: - '*' jobs: - build: - name: Build + release: + name: Release runs-on: ubuntu-latest steps: - - name: Check out code into the Go module directory + - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 @@ -28,15 +28,13 @@ jobs: - name: Cache go module uses: actions/cache@v4 with: - path: ~/go/pkg/mod + path: | + ~/go/pkg/mod + ~/.cache/go-build key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - - name: Run test - run: | - go test ./... - - name: Build if: startsWith(github.ref, 'refs/tags/') run: make -j releases diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..05684f7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Test + +concurrency: + group: test-${{ github.event_name }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: + - 'main' + pull_request: + +jobs: + build-test: + name: Build Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + check-latest: true + go-version-file: 'go.mod' + + - name: Run test + run: | + go test ./...