Skip to content

Commit

Permalink
chore(ci/tests): fix branch filters and improve caching
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Oct 3, 2024
1 parent 7542235 commit 1b5ef27
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/test-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ name: Test App

on:
push:
branches: ["*", "!release/*", "!nightly"]
paths: ["cmd/**", "internal/**", "server/**", "test/**", "main.go", "go.mod", "go.sum"]
branches-ignore: ["release/*", "nightly"]
tags-ignore: ["v*"]
pull_request:
branches: ["*", "!release/*", "!nightly"]
paths: ["cmd/**", "internal/**", "server/**", "test/**", "main.go", "go.mod", "go.sum"]
branches-ignore: ["release/*", "nightly"]

env:
REPORT_DIR: "/tmp/test-reports"

jobs:
test_app:
name: Test App on ${{ matrix.os }}
name: Test Go on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v4
Expand All @@ -27,9 +28,23 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false # https://github.com/actions/setup-go/issues/483

- name: Print the Go version
run: go version
- id: go-vars
name: Get Go variables for cache
run: |
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
- name: Cache go modules
uses: actions/cache@v4
with:
path: |
${{ steps.go-vars.outputs.GOCACHE }}
${{ steps.go-vars.outputs.GOMODCACHE }}
key: go-test-${{ runner.os }}-${{ hashFiles('**/go.mod') }}
restore-keys: |
go-test-${{ runner.os }}
- name: Install tools
run: go install gotest.tools/gotestsum@latest
Expand All @@ -40,18 +55,16 @@ jobs:
- name: Run tests
run: |
mkdir -p $REPORT_DIR
gotestsum \
--junitfile $REPORT_DIR/unit-tests.xml \
--jsonfile $REPORT_DIR/unit-tests.json \
-- -coverprofile=$REPORT_DIR/coverage.out ./...
gotestsum --junitfile $REPORT_DIR/unit-tests.xml --jsonfile $REPORT_DIR/unit-tests.json -- -coverprofile=$REPORT_DIR/coverage.out ./...
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: Go-Test-Results
name: Go-Test-Results-${{ runner.os }}
path: ${{ env.REPORT_DIR }}

- name: Upload coverage to Codecov
- if: matrix.os == 'ubuntu-latest'
name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
flags: go
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: Test Docs

on:
push:
branches: ["*", "!release/*", "!nightly"]
paths: ["docs/**"]
branches-ignore: ["release/*", "nightly"]
tags-ignore: ["v*"]
pull_request:
paths: ["docs/**"]
branches: ["*", "!release/*", "!nightly"]
branches-ignore: ["release/*", "nightly"]

jobs:
test_docs:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: Test Frontend

on:
push:
branches: ["*", "!release/*", "!nightly"]
paths: ["ui/**"]
branches-ignore: ["release/*", "nightly"]
tags-ignore: ["v*"]
pull_request:
paths: ["ui/**"]
branches: ["*", "!release/*", "!nightly"]
branches-ignore: ["release/*", "nightly"]

jobs:
test_ui:
strategy:
fail-fast: false
matrix:
node: [18, 20]
os: [ubuntu-latest, windows-latest]
Expand Down

0 comments on commit 1b5ef27

Please sign in to comment.