-
Notifications
You must be signed in to change notification settings - Fork 77
314 lines (313 loc) · 12.5 KB
/
Copy pathpr_test.yml
File metadata and controls
314 lines (313 loc) · 12.5 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: Test
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
branches:
- main
permissions:
contents: read
# Stop any in-flight CI jobs when a new commit is pushed.
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
env:
GO_VERSION: 1.25.x
GOLANGCI_LINT_VERSION: v2.4
WASI_SDK_VERSION: 25
WASI_SDK_FULL_VERSION: "25.0"
jobs:
changelog:
name: Enforce changelog entry
if: github.event.pull_request.user.login != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: dangoslen/changelog-enforcer@8b5e9dc3121363bb7c0115f8533404d92af382de # v3.7.0
config:
name: Build static app config
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
toolchain: stable
cache: false
rustflags: ""
- name: "Generate static app config"
run: make config
- name: "Config Artifact"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: config-artifact-${{ github.sha }}
path: pkg/config/config.toml
lint:
name: Lint (pinned golangci version)
needs: [config]
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
toolchain: stable
cache: false
rustflags: ""
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
- name: "Install dependencies"
run: make mod-download
shell: bash
- name: "Config Artifact"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: config-artifact-${{ github.sha }}
- name: "Move Config"
run: mv config.toml pkg/config/config.toml
- name: golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
only-new-issues: true
test:
name: Test (${{ matrix.platform }})
needs: [config]
strategy:
matrix:
tinygo-version: [0.31.2]
go-version: [1.25.x]
node-version: [18]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install Go"
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go-version }}
# IMPORTANT: Disable caching to prevent cache restore errors later.
cache: false
- uses: acifani/setup-tinygo@dd8a7075d951a7595b2ef2123ed0ab1af0c13e56 # v3.0.0
with:
tinygo-version: ${{ matrix.tinygo-version }}
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
toolchain: stable
target: wasm32-wasip1
cache: false
rustflags: ""
- name: "Validate Rust toolchain"
run: rustup show && rustup target list --installed --toolchain stable
shell: bash
- name: "Install Node"
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
- name: "Install WASI SDK"
run: |
wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_FULL_VERSION}-x86_64-linux.tar.gz"
tar xzf "wasi-sdk-${WASI_SDK_FULL_VERSION}-x86_64-linux.tar.gz"
echo "$(pwd)/wasi-sdk-${WASI_SDK_FULL_VERSION}-x86_64-linux/bin" >> "$GITHUB_PATH"
shell: bash
- name: "Config Artifact"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: config-artifact-${{ github.sha }}
- name: "Move Config"
run: mv config.toml pkg/config/config.toml
- name: "Modify git cloned repo files 'modified' times"
run: go run ./scripts/go-test-cache/main.go
# NOTE: Windows should fail quietly running pre-requisite target of `test`.
#
# On Windows, executing `make config` directly works fine.
# But when `config` is a pre-requisite to running `test`, it fails.
# But only when run via GitHub Actions.
# The ../../scripts/config.sh isn't run because you can't nest PowerShell instances.
# Each GitHub Action 'run' step is a PowerShell instance.
# And each instance is run as: powershell.exe -command ". '...'"
- name: "Test suite"
run: make test
shell: bash
env:
# NOTE: The following lets us focus the test run while debugging.
# TEST_ARGS: "-run TestBuild ./pkg/commands/compute/..."
TEST_COMPUTE_INIT: true
TEST_COMPUTE_BUILD: true
TEST_COMPUTE_DEPLOY: true
test-release:
name: Test release (${{ matrix.platform }})
if: contains(github.head_ref, 'release')
needs: [config]
strategy:
matrix:
tinygo-version: [0.31.2]
go-version: [1.25.x]
node-version: [18]
platform: [macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install Go"
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go-version }}
# IMPORTANT: Disable caching to prevent cache restore errors later.
cache: false
- uses: acifani/setup-tinygo@dd8a7075d951a7595b2ef2123ed0ab1af0c13e56 # v3.0.0
with:
tinygo-version: ${{ matrix.tinygo-version }}
- name: "Install Rust"
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
toolchain: stable
target: wasm32-wasip1
cache: false
rustflags: ""
- name: "Validate Rust toolchain"
run: rustup show && rustup target list --installed --toolchain stable
shell: bash
- name: "Install Node"
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
- name: "Install WASI SDK (Ubuntu)"
if: matrix.platform == 'ubuntu-latest'
run: |
wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_FULL_VERSION}-x86_64-linux.tar.gz"
tar xzf "wasi-sdk-${WASI_SDK_FULL_VERSION}-x86_64-linux.tar.gz"
echo "$(pwd)/wasi-sdk-${WASI_SDK_FULL_VERSION}-x86_64-linux/bin" >> "$GITHUB_PATH"
shell: bash
- name: "Install WASI SDK (macOS)"
if: matrix.platform == 'macos-latest'
run: |
wget -q "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_FULL_VERSION}-arm64-macos.tar.gz"
tar xzf "wasi-sdk-${WASI_SDK_FULL_VERSION}-arm64-macos.tar.gz"
echo "$(pwd)/wasi-sdk-${WASI_SDK_FULL_VERSION}-arm64-macos/bin" >> "$GITHUB_PATH"
shell: bash
- name: "Install WASI SDK (Windows)"
if: matrix.platform == 'windows-latest'
run: |
Invoke-WebRequest -Uri "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${env:WASI_SDK_VERSION}/wasi-sdk-${env:WASI_SDK_FULL_VERSION}-x86_64-windows.tar.gz" -OutFile "wasi-sdk.tar.gz"
tar -xzf wasi-sdk.tar.gz
echo "$PWD/wasi-sdk-${env:WASI_SDK_FULL_VERSION}-x86_64-windows/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: "Config Artifact"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: config-artifact-${{ github.sha }}
- name: "Move Config"
run: mv config.toml pkg/config/config.toml
- name: "Modify git cloned repo files 'modified' times"
run: go run ./scripts/go-test-cache/main.go
# NOTE: Windows should fail quietly running pre-requisite target of `test`.
#
# On Windows, executing `make config` directly works fine.
# But when `config` is a pre-requisite to running `test`, it fails.
# But only when run via GitHub Actions.
# The ../../scripts/config.sh isn't run because you can't nest PowerShell instances.
# Each GitHub Action 'run' step is a PowerShell instance.
# And each instance is run as: powershell.exe -command ". '...'"
- name: "Test suite"
run: make test
shell: bash
env:
# NOTE: The following lets us focus the test run while debugging.
# TEST_ARGS: "-run TestBuild ./pkg/commands/compute/..."
TEST_COMPUTE_INIT: true
TEST_COMPUTE_BUILD: true
TEST_COMPUTE_DEPLOY: true
docker-builds:
name: Build docker images
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build docker images
run: |
for dockerFile in Dockerfile*; do docker build -f $dockerFile . ; done
tools-build:
name: "goreleaser tools build"
if: contains(github.event.pull_request.labels.*.name, 'tools')
needs: [config]
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install Go"
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: tools/go.mod
- name: "Config Artifact"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: config-artifact-${{ github.sha }}
- name: "Move Config"
run: mv config.toml pkg/config/config.toml
- name: "Test goreleaser tools build"
run: go tool -modfile=tools/go.mod goreleaser build --single-target --snapshot --skip=post-hooks --skip=validate
golangci-latest:
name: lint-latest (informational)
needs: [config]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Download config artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: config-artifact-${{ github.sha }}
path: pkg/config
- name: Verify embedded config exists
run: |
test -f pkg/config/config.toml || { echo "missing pkg/config/config.toml"; ls -la pkg/config; exit 1; }
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Run golangci-lint@latest
id: lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: latest
only-new-issues: true
continue-on-error: true
- name: Report lint summary
env:
LINT_OUTCOME: ${{ steps.lint.outcome }}
run: |
if [ "$LINT_OUTCOME" = "success" ]; then
echo "✅ golangci-lint@latest passed." >> "$GITHUB_STEP_SUMMARY"
else
echo "⚠️ golangci-lint@latest failed (informational only)." >> "$GITHUB_STEP_SUMMARY"
fi