Skip to content

Commit 879982b

Browse files
committed
ci: nest the race-test matrix under a reusable workflow
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
1 parent b5cc3a0 commit 879982b

2 files changed

Lines changed: 55 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
- name: golangci-lint (telemetry)
3535
working-directory: telemetry
3636
run: go run "$GOLANGCI_LINT" run --config "$GITHUB_WORKSPACE/.golangci.yml" ./...
37-
- name: golangci-lint (telemetry/slogadapter)
38-
working-directory: telemetry/slogadapter
37+
- name: golangci-lint (telemetry/slog)
38+
working-directory: telemetry/slog
3939
run: go run "$GOLANGCI_LINT" run --config "$GITHUB_WORKSPACE/.golangci.yml" ./...
4040
- name: golangci-lint (telemetry/otel)
4141
working-directory: telemetry/otel
@@ -44,34 +44,14 @@ jobs:
4444
working-directory: telemetry/datadog
4545
run: go run "$GOLANGCI_LINT" run --config "$GITHUB_WORKSPACE/.golangci.yml" ./...
4646

47-
test:
48-
strategy:
49-
fail-fast: false
50-
matrix:
51-
go: ["1.25.x", "1.26.x"]
52-
os: [ubuntu-latest, macos-latest, windows-latest]
53-
runs-on: ${{ matrix.os }}
54-
steps:
55-
- uses: actions/checkout@v6
56-
- uses: actions/setup-go@v6
57-
with:
58-
go-version: ${{ matrix.go }}
59-
cache-dependency-path: "**/go.sum"
60-
- name: test -race (state)
61-
working-directory: state
62-
run: go test -race ./...
63-
- name: test -race (telemetry)
64-
working-directory: telemetry
65-
run: go test -race ./...
66-
- name: test -race (telemetry/slogadapter)
67-
working-directory: telemetry/slogadapter
68-
run: go test -race ./...
69-
- name: test -race (telemetry/otel)
70-
working-directory: telemetry/otel
71-
run: go test -race ./...
72-
- name: test -race (telemetry/datadog)
73-
working-directory: telemetry/datadog
74-
run: go test -race ./...
47+
# The race-test matrix lives in a reusable workflow so its legs render as a
48+
# single collapsible tree in the checks UI ("tests / test (1.25.x, …)") rather
49+
# than as flat top-level checks. Keep the module list in sync with the lint,
50+
# vuln, and coverage jobs below.
51+
tests:
52+
uses: ./.github/workflows/test.yml
53+
with:
54+
modules: "state telemetry telemetry/slog telemetry/otel telemetry/datadog"
7555

7656
vuln:
7757
runs-on: ubuntu-latest
@@ -87,8 +67,8 @@ jobs:
8767
- name: govulncheck (telemetry)
8868
working-directory: telemetry
8969
run: go run "$GOVULNCHECK" ./...
90-
- name: govulncheck (telemetry/slogadapter)
91-
working-directory: telemetry/slogadapter
70+
- name: govulncheck (telemetry/slog)
71+
working-directory: telemetry/slog
9272
run: go run "$GOVULNCHECK" ./...
9373
- name: govulncheck (telemetry/otel)
9474
working-directory: telemetry/otel
@@ -123,8 +103,8 @@ jobs:
123103
echo "total coverage: ${pct}% (threshold ${THRESHOLD}%)"
124104
awk -v p="$pct" -v t="$THRESHOLD" 'BEGIN { exit (p+0 < t+0) ? 1 : 0 }' \
125105
|| { echo "::error::coverage ${pct}% is below the ${THRESHOLD}% threshold"; exit 1; }
126-
- name: coverage gate (telemetry/slogadapter)
127-
working-directory: telemetry/slogadapter
106+
- name: coverage gate (telemetry/slog)
107+
working-directory: telemetry/slog
128108
run: |
129109
go test -covermode=atomic -coverprofile=coverage.out ./...
130110
pct=$(go tool cover -func=coverage.out | awk '/^total:/ {sub(/%/,"",$3); print $3}')

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: tests
2+
3+
# Reusable race-test matrix. Runs `go test -race ./...` for every module in the
4+
# suite across the Go × OS matrix. Called by ci.yml so the matrix legs render as
5+
# a single collapsible tree in the checks UI (e.g. "tests / test (1.25.x,
6+
# ubuntu-latest)") instead of cluttering the top-level checks list.
7+
on:
8+
workflow_call:
9+
inputs:
10+
modules:
11+
description: "Space-separated list of module directories to test."
12+
required: true
13+
type: string
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
test:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
go: ["1.25.x", "1.26.x"]
24+
os: [ubuntu-latest, macos-latest, windows-latest]
25+
runs-on: ${{ matrix.os }}
26+
env:
27+
MODULES: ${{ inputs.modules }}
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: actions/setup-go@v6
31+
with:
32+
go-version: ${{ matrix.go }}
33+
cache-dependency-path: "**/go.sum"
34+
- name: test -race
35+
shell: bash
36+
run: |
37+
for module in $MODULES; do
38+
echo "::group::test -race ($module)"
39+
go test -C "$module" -race ./...
40+
echo "::endgroup::"
41+
done

0 commit comments

Comments
 (0)