Skip to content

Commit 8e645e8

Browse files
committed
ci: reduce test matrix
1 parent 826005e commit 8e645e8

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.runner }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
flags: [""]
16+
arch:
17+
- amd64
18+
runner:
19+
- ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Install Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: '1.23'
28+
cache: false
29+
30+
- name: Get Go environment
31+
id: go-env
32+
shell: bash
33+
run: |
34+
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
35+
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
36+
37+
# Build cache key prefix, using runner OS and arch.
38+
- name: Compute cache prefix
39+
id: cache-prefix
40+
shell: bash
41+
env:
42+
RUNNER_PREFIX: ${{ runner.os }}-${{ runner.arch }}-go
43+
ARCH_PREFIX: ${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
44+
RACE_PREFIX: ${{ contains(matrix.flags, '-race') && '-race' || '' }}
45+
run:
46+
echo "cache_prefix=$RUNNER_PREFIX$ARCH_PREFIX$RACE_PREFIX" >> $GITHUB_ENV
47+
48+
- name: Set up cache
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
${{ env.cache }}
53+
${{ env.modcache }}
54+
key: ${{ env.cache_prefix }}-${{ hashFiles('**/go.sum') }}
55+
restore-keys: |
56+
${{ env.cache_prefix }}-
57+
58+
- name: Run tests
59+
env:
60+
GOARCH: ${{ matrix.arch }}
61+
GOFLAGS: ${{ matrix.flags }}
62+
run: go test --timeout 15m ./...
63+
64+
# Keep benchmark up to date.
65+
- name: Run benchmarks
66+
if: ${{ !contains(matrix.flags, '-race') }}
67+
env:
68+
GOARCH: ${{ matrix.arch }}
69+
GOFLAGS: ${{ matrix.flags }}
70+
run: go test --timeout 15m --benchtime 3x --benchmem --bench "Benchmark" --run=$^. ./...

.github/workflows/x.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ on:
99
# Common Go workflows from go faster
1010
# See https://github.com/go-faster/x
1111
jobs:
12-
test:
13-
uses: go-faster/x/.github/workflows/test.yml@main
1412
lint:
1513
uses: go-faster/x/.github/workflows/lint.yml@main

0 commit comments

Comments
 (0)