Skip to content

Commit c9f3834

Browse files
authored
Merge pull request #18 from spytheman/ci_fix_check.vsh
ci fix check.vsh
2 parents 7e9f44f + 5df93de commit c9f3834

3 files changed

Lines changed: 31 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
uses: vlang/setup-v@v1.4
4949
with:
5050
check-latest: true
51+
- name: Install X11/GL development dependencies (headers and libs)
52+
run: v retry -- sudo apt install libgl1-mesa-dri xvfb libxcursor-dev libxi-dev libxrandr-dev freeglut3-dev
5153
- name: Checkout the gui module
5254
uses: actions/checkout@v4
5355
with:

examples/_build.vsh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env -S v
22

3-
chdir(dir(@FILE))!
3+
unbuffer_stdout()
4+
chdir(@DIR)!
45

56
output_dir := 'bin'
67
if exists(output_dir) {
@@ -25,24 +26,32 @@ if exists(output_dir) {
2526
}
2627
}
2728

28-
dir_files := ls('.') or { [] }
29+
dir_files := ls('.') or { [] }.map(join_path_single(@DIR, it))
2930
files := dir_files.filter(file_ext(it) == '.v').sorted()
3031
if files.len == 0 {
3132
println('no .v files found')
3233
return
3334
}
3435

36+
mut errors := []string{}
3537
for file in files {
36-
p := 'v -prod ${file}'
37-
print('${p:-30}')
38-
flush()
3938
_, name, _ := split_path(file)
4039
output_file := join_path(output_dir, name)
41-
result := execute('v -prod -o ${output_file} ${file}')
42-
if result.exit_code != 0 {
43-
println(' ⭕')
44-
println(result.output)
40+
cmd := 'v -prod -o ${output_file:-22s} ${file:-50s}'
41+
print(cmd)
42+
result := execute(cmd)
43+
if result.exit_code == 0 {
44+
println('✅')
4545
} else {
46-
println(' -> ${output_file}')
46+
println('⭕')
47+
println(result.output)
48+
errors << cmd
49+
}
50+
}
51+
if errors.len > 0 {
52+
println('Encountered ${errors.len} error(s).')
53+
for i, ecmd in errors {
54+
println(' error ${i + 1}/${errors.len} for: `${ecmd}`')
4755
}
56+
exit(1)
4857
}

examples/_check.vsh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
#!/usr/bin/env -S v
22

33
unbuffer_stdout()
4+
chdir(@DIR)!
45

5-
dir_files := ls(dir(@FILE)) or { [] }.map(join_path_single(dir(@FILE), it))
6+
dir_files := ls(@DIR) or { [] }.map(join_path_single(@DIR, it))
67
files := dir_files.filter(file_ext(it) == '.v').sorted()
78
if files.len == 0 {
89
println('no .v files found')
910
return
1011
}
1112
mut errors := []string{}
1213
for i, file in files {
13-
p := 'v -check ${file} '
14-
print('(${i + 1:02}/${files.len:02}) ${p:-70}')
15-
result := execute('v -check ${file}')
14+
cmd := 'v -check -N -W ${file}'
15+
print('(${i + 1:02}/${files.len:02}) ${cmd:-70}')
16+
result := execute(cmd)
1617
if result.exit_code == 0 {
17-
println(' ✅')
18+
println('✅')
1819
} else {
19-
println(' ⭕')
20+
println('⭕')
2021
println(result.output)
21-
errors << file
22+
errors << cmd
2223
}
2324
}
2425
if errors.len > 0 {
2526
println('Encountered ${errors.len} error(s).')
26-
for i, efile in errors {
27-
println(' error ${i + 1}/${errors.len} for: `v -check ${efile}`')
27+
for i, ecmd in errors {
28+
println(' error ${i + 1}/${errors.len} for: `${ecmd}`')
2829
}
2930
exit(1)
3031
}

0 commit comments

Comments
 (0)