Skip to content

Commit 1b5ef27

Browse files
committedOct 3, 2024
chore(ci/tests): fix branch filters and improve caching
1 parent 7542235 commit 1b5ef27

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed
 

‎.github/workflows/test-app.yml

+25-12
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ name: Test App
22

33
on:
44
push:
5-
branches: ["*", "!release/*", "!nightly"]
65
paths: ["cmd/**", "internal/**", "server/**", "test/**", "main.go", "go.mod", "go.sum"]
6+
branches-ignore: ["release/*", "nightly"]
77
tags-ignore: ["v*"]
88
pull_request:
9-
branches: ["*", "!release/*", "!nightly"]
109
paths: ["cmd/**", "internal/**", "server/**", "test/**", "main.go", "go.mod", "go.sum"]
10+
branches-ignore: ["release/*", "nightly"]
1111

1212
env:
1313
REPORT_DIR: "/tmp/test-reports"
1414

1515
jobs:
1616
test_app:
17-
name: Test App on ${{ matrix.os }}
17+
name: Test Go on ${{ matrix.os }}
1818
runs-on: ${{ matrix.os }}
1919
strategy:
20+
fail-fast: false
2021
matrix:
21-
os: [windows-latest, ubuntu-latest, macos-latest]
22+
os: [ubuntu-latest, macos-latest]
2223

2324
steps:
2425
- uses: actions/checkout@v4
@@ -27,9 +28,23 @@ jobs:
2728
uses: actions/setup-go@v5
2829
with:
2930
go-version-file: go.mod
31+
cache: false # https://github.com/actions/setup-go/issues/483
3032

31-
- name: Print the Go version
32-
run: go version
33+
- id: go-vars
34+
name: Get Go variables for cache
35+
run: |
36+
echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
37+
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
38+
39+
- name: Cache go modules
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
${{ steps.go-vars.outputs.GOCACHE }}
44+
${{ steps.go-vars.outputs.GOMODCACHE }}
45+
key: go-test-${{ runner.os }}-${{ hashFiles('**/go.mod') }}
46+
restore-keys: |
47+
go-test-${{ runner.os }}
3348
3449
- name: Install tools
3550
run: go install gotest.tools/gotestsum@latest
@@ -40,18 +55,16 @@ jobs:
4055
- name: Run tests
4156
run: |
4257
mkdir -p $REPORT_DIR
43-
gotestsum \
44-
--junitfile $REPORT_DIR/unit-tests.xml \
45-
--jsonfile $REPORT_DIR/unit-tests.json \
46-
-- -coverprofile=$REPORT_DIR/coverage.out ./...
58+
gotestsum --junitfile $REPORT_DIR/unit-tests.xml --jsonfile $REPORT_DIR/unit-tests.json -- -coverprofile=$REPORT_DIR/coverage.out ./...
4759
4860
- name: Upload test results
4961
uses: actions/upload-artifact@v4
5062
with:
51-
name: Go-Test-Results
63+
name: Go-Test-Results-${{ runner.os }}
5264
path: ${{ env.REPORT_DIR }}
5365

54-
- name: Upload coverage to Codecov
66+
- if: matrix.os == 'ubuntu-latest'
67+
name: Upload coverage to Codecov
5568
uses: codecov/codecov-action@v4
5669
with:
5770
flags: go

‎.github/workflows/test-docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ name: Test Docs
22

33
on:
44
push:
5-
branches: ["*", "!release/*", "!nightly"]
65
paths: ["docs/**"]
6+
branches-ignore: ["release/*", "nightly"]
77
tags-ignore: ["v*"]
88
pull_request:
99
paths: ["docs/**"]
10-
branches: ["*", "!release/*", "!nightly"]
10+
branches-ignore: ["release/*", "nightly"]
1111

1212
jobs:
1313
test_docs:

‎.github/workflows/test-frontend.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ name: Test Frontend
22

33
on:
44
push:
5-
branches: ["*", "!release/*", "!nightly"]
65
paths: ["ui/**"]
6+
branches-ignore: ["release/*", "nightly"]
77
tags-ignore: ["v*"]
88
pull_request:
99
paths: ["ui/**"]
10-
branches: ["*", "!release/*", "!nightly"]
10+
branches-ignore: ["release/*", "nightly"]
1111

1212
jobs:
1313
test_ui:
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
node: [18, 20]
1718
os: [ubuntu-latest, windows-latest]

0 commit comments

Comments
 (0)