-
Notifications
You must be signed in to change notification settings - Fork 18
450 lines (442 loc) · 17.4 KB
/
Copy pathci.yml
File metadata and controls
450 lines (442 loc) · 17.4 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
name: CI Checks
on:
push:
paths:
- "**.v"
- "**.vsh"
- "**.c"
- "**.h"
- "**.glsl"
- "**.hlsl"
- "**.m"
- "**.md"
- "**.metal"
- "**.wgsl"
- "**/ci.yml"
- ".github/workflows/*.yml"
pull_request:
paths:
- "**.v"
- "**.vsh"
- "**.c"
- "**.h"
- "**.glsl"
- "**.hlsl"
- "**.m"
- "**.md"
- "**.metal"
- "**.wgsl"
- "**/ci.yml"
- ".github/workflows/*.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
linting:
runs-on: ubuntu-latest
timeout-minutes: 25
env:
VFLAGS: -no-parallel
steps:
- name: Install V
id: install-v
uses: vlang/setup-v@v1.4
with:
check-latest: true
- name: Install vglyph
run: v install vglyph
- name: Install C development dependencies (headers and libs)
if: runner.os == 'Linux'
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev dbus libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev
- name: Install development dependencies on macos (headers and libs)
if: runner.os == 'macOS'
run: v retry -- brew install pango harfbuzz freetype2
- name: Checkout the gui module
uses: actions/checkout@v6
with:
path: gui
fetch-depth: 0
- name: Verify formatting of changed V files
if: github.event_name == 'pull_request'
working-directory: gui
run: |
base_ref="${{ github.base_ref }}"
git fetch --no-tags origin "$base_ref:refs/remotes/origin/$base_ref"
git diff --name-only -z --diff-filter=ACMRT "origin/${base_ref}...HEAD" -- '*.v' '*.vsh' > /tmp/vfmt-files
if [ ! -s /tmp/vfmt-files ]; then
echo "No changed V/VSH files to format-check."
exit 0
fi
xargs -0 v fmt -verify -inprocess < /tmp/vfmt-files
- name: Verify formatting
if: github.event_name != 'pull_request'
run: v fmt -verify -inprocess gui/
- name: Check formatting of MD files
run: v check-md gui/
- name: Check syntax of changed example scripts
if: github.event_name == 'pull_request'
working-directory: gui
run: |
base_ref="${{ github.base_ref }}"
files_list="${RUNNER_TEMP}/gui-example-syntax-files"
git fetch --no-tags origin "$base_ref:refs/remotes/origin/$base_ref"
git diff --name-only -z --diff-filter=ACMRT "origin/${base_ref}...HEAD" -- 'examples/*.vsh' > "$files_list"
if [ ! -s "$files_list" ]; then
echo "No changed example VSH scripts to syntax-check."
exit 0
fi
while IFS= read -r -d '' file; do
v -check -W "$file"
done < "$files_list"
- name: Skip full examples syntax lint
if: github.event_name != 'pull_request'
run: echo "Skipping full examples syntax lint; example .v files are covered by compilation checks."
compiling:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
fail-fast: true
runs-on: ${{ matrix.os }}
timeout-minutes: 25
env:
VFLAGS: -no-parallel
steps:
- name: Install V
id: install-v
uses: vlang/setup-v@v1.4
with:
check-latest: true
- name: Install vglyph
run: v install vglyph
- name: Install X11/GL development dependencies (headers and libs)
if: runner.os == 'Linux'
run: v retry -- sudo apt -qq update && v retry -- sudo apt install libpango1.0-dev libfontconfig1-dev libfribidi-dev libharfbuzz-dev libfreetype-dev libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev dbus libdbus-1-dev libdbus-glib-1-2 libdbus-glib-1-dev
- name: Install development dependencies on macos (headers and libs)
if: runner.os == 'macOS'
run: v retry -- brew install pango harfbuzz freetype2
- name: Checkout the gui module
uses: actions/checkout@v6
with:
path: gui
fetch-depth: 0
- name: Run tests
env:
GUI_CHECK_GENERATED_SHADERS: "1"
VFLAGS: -no-parallel -cc clang
run: |
test_manifest="${RUNNER_TEMP}/gui-test-files"
git -C gui ls-files '*_test.v' | LC_ALL=C sort > "$test_manifest"
test_count="$(wc -l < "$test_manifest" | tr -d ' ')"
echo "Test files: $test_count"
i=0
while IFS= read -r file; do
i=$((i + 1))
echo "[$i/$test_count] gui/$file"
done < "$test_manifest"
v test gui/
- name: Check compilation of examples
if: github.event_name == 'pull_request'
env:
VFLAGS: -no-parallel -cc clang
run: v should-compile-all gui/examples/
- name: Check compilation of changed examples with -W
if: github.event_name == 'pull_request'
env:
VFLAGS: -no-parallel -cc clang
working-directory: gui
run: |
base_ref="${{ github.base_ref }}"
files_list="${RUNNER_TEMP}/gui-example-compile-files"
git fetch --no-tags origin "$base_ref:refs/remotes/origin/$base_ref"
git diff --name-only -z --diff-filter=ACMRT "origin/${base_ref}...HEAD" -- 'examples/*.v' > "$files_list"
if [ ! -s "$files_list" ]; then
echo "No changed example .v files to compile with -W."
exit 0
fi
mkdir -p examples/bin
while IFS= read -r -d '' file; do
output_file="examples/bin/$(basename "${file%.v}")"
if [ "$file" = "examples/showcase.v" ]; then
v -no-parallel -o "$output_file" "$file"
else
v -no-parallel -W -o "$output_file" "$file"
fi
done < "$files_list"
- name: Check compilation of examples without warning-fatal mode
if: github.event_name != 'pull_request'
env:
VFLAGS: -no-parallel -cc clang
run: v gui/examples/_build.vsh --no-warnings
compiling-on-windows:
runs-on: windows-latest
timeout-minutes: 70
env:
VFLAGS: -no-parallel
VCPKG_BINARY_CACHE: ${{ github.workspace }}\vcpkg-binary-cache
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg-binary-cache,readwrite
steps:
- name: Resolve V revision
id: v
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$revision = (git ls-remote https://github.com/vlang/v HEAD).Split()[0]
"revision=$revision" | Add-Content -Path $env:GITHUB_OUTPUT
- name: Restore V compiler cache
id: restore-v-cache
uses: actions/cache/restore@v4
with:
path: v
key: windows-v-compiler-${{ steps.v.outputs.revision }}-v1
- name: Install V
id: install-v
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
function Assert-NativeCommand($Message) {
if ($LASTEXITCODE -ne 0) {
throw $Message
}
}
$expectedRevision = '${{ steps.v.outputs.revision }}'
if (Test-Path .\v\v.exe) {
$cachedRevision = (& git -C v rev-parse HEAD).Trim()
Assert-NativeCommand "Could not inspect cached V revision"
if ($cachedRevision -ne $expectedRevision) {
Write-Host "Cached V revision $cachedRevision does not match expected $expectedRevision; rebuilding."
Remove-Item -Recurse -Force .\v
}
}
if (-not (Test-Path .\v\v.exe)) {
if (Test-Path .\v) {
Remove-Item -Recurse -Force .\v
}
git init v
Assert-NativeCommand "git init failed"
git -C v remote add origin https://github.com/vlang/v
Assert-NativeCommand "git remote add failed"
git -C v fetch --depth 1 origin $expectedRevision
Assert-NativeCommand "git fetch failed"
git -C v checkout --detach FETCH_HEAD
Assert-NativeCommand "git checkout failed"
Push-Location v
cmd /c makev.bat
if ($LASTEXITCODE -ne 0) {
throw "makev.bat failed"
}
Pop-Location
}
$vPath = (Resolve-Path .\v).Path
Add-Content -Path $env:GITHUB_PATH -Value $vPath
$version = (& .\v\v.exe version).Trim()
$revision = (& git -C v rev-parse HEAD).Trim()
Assert-NativeCommand "Could not inspect V revision"
"version=$version" | Add-Content -Path $env:GITHUB_OUTPUT
"revision=$revision" | Add-Content -Path $env:GITHUB_OUTPUT
- name: Log V version
run: v version
- name: Save V compiler cache
if: ${{ steps.restore-v-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: v
key: ${{ steps.restore-v-cache.outputs.cache-primary-key }}
- name: Resolve vglyph revision
id: vglyph
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$revision = (git ls-remote https://github.com/vlang/vglyph HEAD).Split()[0]
if ($LASTEXITCODE -ne 0) {
throw "Could not resolve vglyph revision"
}
"revision=$revision" | Add-Content -Path $env:GITHUB_OUTPUT
- name: Restore vcpkg binary cache
id: restore-vcpkg-cache
uses: actions/cache/restore@v4
with:
path: ${{ env.VCPKG_BINARY_CACHE }}
key: windows-vcpkg-x64-windows-pango-freetype-${{ steps.install-v.outputs.revision }}-v2
restore-keys: |
windows-vcpkg-x64-windows-pango-freetype-
- name: Restore V module cache
id: restore-vglyph-cache
uses: actions/cache/restore@v4
with:
path: ~/.vmodules/vglyph
key: windows-vmodules-vglyph-${{ steps.install-v.outputs.revision }}-${{ steps.vglyph.outputs.revision }}-v2
- name: Install pango and freetype
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path "$env:VCPKG_BINARY_CACHE" | Out-Null
vcpkg install pango freetype
- name: Save vcpkg binary cache
if: ${{ steps.restore-vcpkg-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ${{ env.VCPKG_BINARY_CACHE }}
key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }}
- name: Expose vcpkg pkg-config paths
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$triplet = 'x64-windows'
$vcpkgExe = (Get-Command vcpkg -ErrorAction Stop).Source
$roots = @()
if ($vcpkgExe) {
$roots += Split-Path -Parent $vcpkgExe
}
if ($env:VCPKG_ROOT) {
$roots += $env:VCPKG_ROOT
}
$vcpkgRoot = $null
foreach ($root in ($roots | Select-Object -Unique)) {
if (Test-Path (Join-Path $root "installed\$triplet")) {
$vcpkgRoot = $root
break
}
}
if (-not $vcpkgRoot) {
throw "Could not find vcpkg installed\$triplet from vcpkg.exe or VCPKG_ROOT"
}
$tripletRoot = Join-Path $vcpkgRoot "installed\$triplet"
$pkgConfigDirs = @(
(Join-Path $tripletRoot 'lib\pkgconfig'),
(Join-Path $tripletRoot 'share\pkgconfig')
) | Where-Object { Test-Path $_ }
if ($pkgConfigDirs.Count -eq 0) {
throw "No pkgconfig directories found under $tripletRoot"
}
$pkgConfigPath = $pkgConfigDirs -join ';'
"PKG_CONFIG_PATH=$pkgConfigPath" | Add-Content -Path $env:GITHUB_ENV
$env:PKG_CONFIG_PATH = $pkgConfigPath
$pathEntries = @()
$binDir = Join-Path $tripletRoot 'bin'
if (Test-Path $binDir) {
$pathEntries += $binDir
}
$pkgconfDir = Join-Path $tripletRoot 'tools\pkgconf'
if (Test-Path $pkgconfDir) {
$pathEntries += $pkgconfDir
}
foreach ($entry in $pathEntries) {
$entry | Add-Content -Path $env:GITHUB_PATH
}
if ($pathEntries.Count -gt 0) {
$env:PATH = ($pathEntries + $env:PATH) -join ';'
}
if (-not (Get-Command pkg-config -ErrorAction SilentlyContinue)) {
$pkgconf = Get-Command pkgconf -ErrorAction SilentlyContinue
if ($pkgconf) {
$shimDir = Join-Path $env:RUNNER_TEMP 'pkg-config-shim'
New-Item -ItemType Directory -Force -Path $shimDir | Out-Null
Set-Content -Path (Join-Path $shimDir 'pkg-config.cmd') -Encoding ascii -Value @(
'@echo off',
'"' + $pkgconf.Source + '" %*'
)
$shimDir | Add-Content -Path $env:GITHUB_PATH
$env:PATH = "$shimDir;$env:PATH"
}
}
$pkgConfig = Get-Command pkg-config -ErrorAction Stop
& $pkgConfig.Source --exists freetype2 pango pangoft2
if ($LASTEXITCODE -ne 0) {
throw "pkg-config could not resolve freetype2 pango pangoft2"
}
- name: Ensure vglyph revision
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
function Assert-NativeCommand($Message) {
if ($LASTEXITCODE -ne 0) {
throw $Message
}
}
$expectedRevision = '${{ steps.vglyph.outputs.revision }}'
$vglyphPath = Join-Path $HOME '.vmodules\vglyph'
if (Test-Path (Join-Path $vglyphPath '.git')) {
$cachedRevision = (& git -C $vglyphPath rev-parse HEAD).Trim()
Assert-NativeCommand "Could not inspect cached vglyph revision"
if ($cachedRevision -ne $expectedRevision) {
Write-Host "Cached vglyph revision $cachedRevision does not match expected $expectedRevision; rebuilding."
Remove-Item -Recurse -Force $vglyphPath
}
} elseif (Test-Path $vglyphPath) {
Remove-Item -Recurse -Force $vglyphPath
}
if (-not (Test-Path $vglyphPath)) {
$vmodulesPath = Split-Path -Parent $vglyphPath
New-Item -ItemType Directory -Force -Path $vmodulesPath | Out-Null
git init $vglyphPath
Assert-NativeCommand "git init vglyph failed"
git -C $vglyphPath remote add origin https://github.com/vlang/vglyph
Assert-NativeCommand "git remote add vglyph failed"
git -C $vglyphPath fetch --depth 1 origin $expectedRevision
Assert-NativeCommand "git fetch vglyph failed"
git -C $vglyphPath checkout --detach FETCH_HEAD
Assert-NativeCommand "git checkout vglyph failed"
}
- name: Save V module cache
if: ${{ steps.restore-vglyph-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: ~/.vmodules/vglyph
key: ${{ steps.restore-vglyph-cache.outputs.cache-primary-key }}
- name: Checkout the gui module
uses: actions/checkout@v6
with:
path: gui
fetch-depth: 0
- name: Configure MSVC developer environment
uses: ilammy/msvc-dev-cmd@v1
- name: Run Windows setup preflight
env:
GUI_WINDOWS_PREFLIGHT_CC: msvc
run: v -cc msvc run gui/_windows_preflight.vsh
- name: Run tests
env:
GUI_CHECK_GENERATED_SHADERS: "1"
VFLAGS: -no-parallel -cc msvc
VJOBS: 1
VTEST_ONLY_FN: test_*
run: |
$testFiles = @(git -C gui ls-files '*_test.v' | Sort-Object)
Write-Host "Test files: $($testFiles.Count)"
for ($i = 0; $i -lt $testFiles.Count; $i++) {
Write-Host ("[{0}/{1}] gui/{2}" -f ($i + 1), $testFiles.Count, $testFiles[$i])
}
v test gui/
- name: Check compilation of examples
if: github.event_name == 'pull_request'
env:
VFLAGS: -no-parallel -cc msvc
run: v gui/examples/_build.vsh --no-warnings --skip-missing-sqlite
- name: Check compilation of changed examples with -W
if: github.event_name == 'pull_request'
env:
VFLAGS: -no-parallel -cc msvc
shell: pwsh
working-directory: gui
run: |
$baseRef = '${{ github.base_ref }}'
git fetch --no-tags origin "${baseRef}:refs/remotes/origin/${baseRef}"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
$files = @(git diff --name-only --diff-filter=ACMRT "origin/${baseRef}...HEAD" -- 'examples/*.v')
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
if ($files.Count -eq 0) {
Write-Host 'No changed example .v files to compile with -W.'
exit 0
}
v examples/_build.vsh --skip-missing-sqlite @files
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
- name: Check compilation of examples without warning-fatal mode
if: github.event_name != 'pull_request'
env:
VFLAGS: -no-parallel -cc msvc
run: v gui/examples/_build.vsh --no-warnings --skip-missing-sqlite