-
Notifications
You must be signed in to change notification settings - Fork 8
161 lines (140 loc) · 4.89 KB
/
ci.yml
File metadata and controls
161 lines (140 loc) · 4.89 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI
on:
pull_request:
branches: [main]
paths-ignore:
- 'docs/**'
workflow_dispatch:
inputs:
run_integration:
description: 'Run integration tests'
type: boolean
default: true
spec:
description: 'Specific spec to test (e.g., 3.0/misc/stripe.com.yml)'
type: string
required: false
max_concurrency:
description: 'Max concurrency for integration tests'
type: number
default: 5
jobs:
build-ci:
name: Build CI
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check branch is up to date with main
if: github.event_name == 'pull_request'
run: |
git fetch origin main
if ! git merge-base --is-ancestor origin/main HEAD; then
echo "❌ Branch is not up to date with main. Please rebase or merge main into your branch."
exit 1
fi
echo "✅ Branch is up to date with main"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25.3"
cache: true
- name: Install gosec
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
- name: Download Go modules
run: go mod download
- name: Run build-ci
run: make build-ci
timeout-minutes: 30
test-ci:
name: Test CI
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25.3"
cache: true
- name: Download Go modules
run: go mod download
- name: Run generate and check for uncommitted changes
run: |
make generate
if ! git diff --exit-code; then
echo "ERROR: make generate produced uncommitted changes"
echo "Please run 'make generate' locally and commit the changes"
exit 1
fi
- name: Run test-ci
run: make test-ci
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 65
# Run on: merge_group (merge queue), push to main, or manual trigger with run_integration=true
if: github.event_name == 'merge_group' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.run_integration)
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25.3"
cache: true
- name: Cache Go build cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build
key: go-build-integration-${{ runner.os }}-${{ hashFiles('**/*.go', 'go.sum') }}
restore-keys: |
go-build-integration-${{ runner.os }}-
- name: Restore integration test cache
id: cache-restore
uses: actions/cache/restore@v4
with:
path: .integration-cache.json
key: integration-cache-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
integration-cache-${{ github.ref_name }}-
- name: Debug cache restore
run: |
echo "Cache hit: ${{ steps.cache-restore.outputs.cache-hit }}"
echo "Cache key: ${{ steps.cache-restore.outputs.cache-primary-key }}"
echo "Cache matched key: ${{ steps.cache-restore.outputs.cache-matched-key }}"
if [ -f .integration-cache.json ]; then
echo "Cache file exists, size: $(wc -c < .integration-cache.json) bytes"
echo "Entries: $(grep -c '"passed": true' .integration-cache.json || echo 0)"
else
echo "Cache file does not exist"
fi
- name: Download Go modules
run: go mod download
- name: Fetch specs
run: make fetch-specs
- name: Run integration tests
run: |
if [ -n "${{ inputs.spec }}" ]; then
make test-integration SPEC="${{ inputs.spec }}"
else
INTEGRATION_MAX_CONCURRENCY=${{ inputs.max_concurrency }} go test -v -tags=integration -count=1 -timeout=55m .
fi
timeout-minutes: 60
- name: Debug cache before save
if: always()
run: |
if [ -f .integration-cache.json ]; then
echo "Cache file exists, size: $(wc -c < .integration-cache.json) bytes"
echo "Entries: $(grep -c '"passed": true' .integration-cache.json || echo 0)"
else
echo "Cache file does not exist - nothing to save"
fi
- name: Save integration test cache
uses: actions/cache/save@v4
if: always()
with:
path: .integration-cache.json
key: integration-cache-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }}