-
Notifications
You must be signed in to change notification settings - Fork 124
91 lines (81 loc) · 3.2 KB
/
Copy pathgo-test.yml
File metadata and controls
91 lines (81 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Go Tests
# Pre-merge gate that runs the FULL Go test suite on PRs. Without this,
# Go test breakages would only surface in the nightly Release workflow —
# historically every test failure in the nightly had to be traced back
# to an already-merged commit. See release.yml for the other invocation.
on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/go-coverage-ratchet.txt'
- '.github/go-package-coverage-ratchet.txt'
- '.github/workflows/go-test.yml'
- 'scripts/check-go-coverage-ratchet.sh'
- 'scripts/__tests__/check-go-coverage-ratchet.test.sh'
- 'scripts/testdata/check-go-coverage-ratchet/**'
push:
branches: [main]
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/go-coverage-ratchet.txt'
- '.github/go-package-coverage-ratchet.txt'
- '.github/workflows/go-test.yml'
- 'scripts/check-go-coverage-ratchet.sh'
- 'scripts/__tests__/check-go-coverage-ratchet.test.sh'
- 'scripts/testdata/check-go-coverage-ratchet/**'
workflow_dispatch:
# Cancel superseded runs on the same PR/branch so we don't queue stale work.
concurrency:
group: go-test-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
GO_COVERAGE_RATCHET_FILE: .github/go-coverage-ratchet.txt
GO_PACKAGE_COVERAGE_RATCHET_FILE: .github/go-package-coverage-ratchet.txt
GO_COVERAGE_REPORT_FILE: go-coverage-summary.md
GO_COVERAGE_FUNCTIONS_FILE: go-coverage-functions.txt
jobs:
test:
name: go test ./...
runs-on: ubuntu-latest
# Matches the release workflow's timeout budget; full suite runs in
# ~1-2 minutes today, cushion is for slower runners and test growth.
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: '1.26.4'
cache: true
# Full suite — must match what release.yml runs or main can still
# break the nightly. -race catches concurrency bugs that only show
# up under load, which is cheap relative to the cost of a broken
# release pipeline.
- name: Run full Go test suite
run: go test -race -coverprofile=coverage.out -covermode=atomic -timeout 10m ./...
- name: Check Go coverage ratchet
run: |
chmod +x scripts/check-go-coverage-ratchet.sh
./scripts/check-go-coverage-ratchet.sh \
coverage.out \
"$GO_COVERAGE_RATCHET_FILE" \
"$GO_PACKAGE_COVERAGE_RATCHET_FILE" \
"$GO_COVERAGE_REPORT_FILE"
go tool cover -func=coverage.out | tee "$GO_COVERAGE_FUNCTIONS_FILE" | tail -1
- name: Upload Go coverage artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: go-coverage-${{ github.run_id }}-${{ github.run_attempt }}
retention-days: 7
path: |
coverage.out
${{ env.GO_COVERAGE_FUNCTIONS_FILE }}
${{ env.GO_COVERAGE_REPORT_FILE }}