Skip to content

Commit 1d0e6f7

Browse files
authored
Merge branch 'master' into fix/v3-refactors-part-one
2 parents 13f798d + 5c12375 commit 1d0e6f7

179 files changed

Lines changed: 4215 additions & 685 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/linux_ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,13 @@ jobs:
169169
V_MACOS_V3_NO_FALLBACK: 1
170170
run: v run ci/linux_ci.vsh build_examples_gcc
171171
- name: Build tetris with -autofree
172+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
172173
run: v run ci/linux_ci.vsh build_tetris_autofree_gcc
173174
- name: Build blog tutorial with -autofree
175+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
174176
run: v run ci/linux_ci.vsh build_blog_autofree_gcc
175177
- name: Build option_test.c.v with -autofree
178+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
176179
run: v run ci/linux_ci.vsh build_option_test_autofree_gcc
177180
- name: V self compilation with -parallel-cc
178181
run: v run ci/linux_ci.vsh v_self_compilation_parallel_cc_gcc
@@ -241,6 +244,7 @@ jobs:
241244
V_MACOS_V3_NO_FALLBACK: 1
242245
run: v run ci/linux_ci.vsh build_examples_clang
243246
- name: Build examples with -autofree
247+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
244248
run: v run ci/linux_ci.vsh build_examples_autofree_clang
245249
- name: Build modules
246250
run: v run ci/linux_ci.vsh build_modules_clang

‎.github/workflows/macos_ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ jobs:
292292
- name: Build examples
293293
run: v run ci/macos_ci.vsh build_examples
294294
- name: Build hello_world with -autofree
295+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
295296
run: v run ci/macos_ci.vsh build_hello_world_autofree
296297
- name: Build tetris with -autofree
298+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
297299
run: v run ci/macos_ci.vsh build_tetris_autofree
298300
- name: Build blog tutorial with -autofree
301+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
299302
run: v run ci/macos_ci.vsh build_blog_autofree
300303
- name: Build examples with -prod
301304
run: v run ci/macos_ci.vsh build_examples_prod

‎.github/workflows/v_apps_and_modules_compile_ci.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ jobs:
121121
cd ved && v -o ved .
122122
echo "Build"
123123
v .
124-
echo "Build with -autofree ..."
125-
v -autofree .
124+
echo "Skip -autofree build (ownership/autofree coverage is temporarily disabled)"
126125
echo "Build with -prod ..."
127126
v -prod .
128127
cd ..

‎.github/workflows/windows_ci_gcc.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ jobs:
113113
- name: Self tests
114114
run: v -silent test-self vlib
115115
- name: Build option_test.c.v with -autofree
116+
if: ${{ false }} # Ownership/autofree coverage is temporarily disabled on GitHub CI.
116117
run: v -autofree vlib/v/tests/options/option_test.c.v
117118
- name: Test v->js
118119
run: v -o hi.js examples/js_hello_world.v && node hi.js

‎TESTS.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ In this mode, the output lines will be limited, no matter how many `_test.v`
191191
files there are. The output will contain the total stats and the output of
192192
the failing tests too.
193193

194+
NB 6: Set `VTEST_SKIP_OWNERSHIP=1` to omit ownership and autofree tests from
195+
`v test`, `v test-self`, and `vlib/v/test_all.vsh`. GitHub Actions enables this
196+
behavior automatically while ownership/autofree coverage is disabled there.
197+
194198
## `.github/workflows/ci.yml`
195199

196200
This is a Github Actions configuration file, that runs various CI

‎ci/common/progress.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import os
66
// exec_with_progress checkpoints a successful command and its output files when
77
// invoked by the aggregate CI runner. Missing or changed outputs force a rerun.
88
pub fn exec_with_progress(command string, outputs []string) {
9-
dir := os.getenv('V_MACOS_CI_TASK_PROGRESS')
9+
dir := ci_task_progress_dir()
1010
if dir == '' {
1111
exec(command)
1212
return

‎ci/common/runner.v‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import time
99
// exec is a helper function, to execute commands and exit early, if they fail.
1010
pub fn exec(command string) {
1111
cmd := resolve_v_command(command)
12-
progress_dir := os.getenv('V_MACOS_CI_TASK_PROGRESS')
12+
progress_dir := ci_task_progress_dir()
1313
previous_resume_dir := os.getenv_opt('VTEST_RESUME_DIR')
1414
if progress_dir != '' {
1515
// Keep the same file's results separate across tasks and command variants.
@@ -31,6 +31,10 @@ pub fn exec(command string) {
3131
}
3232
}
3333

34+
fn ci_task_progress_dir() string {
35+
return os.getenv_opt('V_CI_TASK_PROGRESS') or { os.getenv('V_MACOS_CI_TASK_PROGRESS') }
36+
}
37+
3438
// resolve_v_command ensures that commands starting with `v ` use the V from @VEXEROOT,
3539
// not a potentially different V found via PATH.
3640
fn resolve_v_command(command string) string {

‎ci/linux_ci.vsh‎

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import common { Task, exec }
2+
import crypto.sha256
23
import os
34

45
// Shared tasks/helpers
@@ -255,21 +256,41 @@ fn self_tests_cstrict_gcc() {
255256
exec('VTEST_JUST_ESSENTIAL=1 V_CI_CSTRICT=1 v -cc gcc -cstrict -silent test-self vlib')
256257
}
257258
259+
fn skip_ownership_autofree_test() bool {
260+
return common.is_github_job || os.getenv('VTEST_SKIP_OWNERSHIP') == '1'
261+
}
262+
263+
fn report_skipped_ownership_autofree_test() {
264+
eprintln('> skipping ownership/autofree test')
265+
}
266+
258267
fn build_examples_gcc() {
259268
build_examples()
260269
}
261270
262271
fn build_tetris_autofree_gcc() {
272+
if skip_ownership_autofree_test() {
273+
report_skipped_ownership_autofree_test()
274+
return
275+
}
263276
exec('v -autofree -o tetris examples/tetris/tetris.v')
264277
exec('rm -f tetris')
265278
}
266279
267280
fn build_blog_autofree_gcc() {
281+
if skip_ownership_autofree_test() {
282+
report_skipped_ownership_autofree_test()
283+
return
284+
}
268285
exec('v -autofree -o blog tutorials/building_a_simple_web_blog_with_veb/code/blog')
269286
exec('rm -f blog')
270287
}
271288
272289
fn build_option_test_autofree_gcc() {
290+
if skip_ownership_autofree_test() {
291+
report_skipped_ownership_autofree_test()
292+
return
293+
}
273294
exec('v -autofree vlib/v/tests/options/option_test.c.v')
274295
}
275296
@@ -382,6 +403,10 @@ fn build_examples_clang() {
382403
}
383404
384405
fn build_examples_autofree_clang() {
406+
if skip_ownership_autofree_test() {
407+
report_skipped_ownership_autofree_test()
408+
return
409+
}
385410
exec('v -N -W -autofree -experimental -o tetris examples/tetris/tetris.v')
386411
exec('rm -f tetris')
387412
}
@@ -404,6 +429,178 @@ fn test_inline_assembly() {
404429
exec('v test vlib/v/slow_tests/assembly')
405430
}
406431
432+
// Keep this list in the same order as the active tasks in
433+
// .github/workflows/linux_ci.yml. The aggregate runner changes compiler flags at
434+
// the same boundaries as the three workflow jobs.
435+
const ci_tasks = [
436+
'build_v_with_prealloc',
437+
'all_code_is_formatted_tcc',
438+
'install_dependencies_for_examples_and_tools_tcc',
439+
'test_v_to_c_tcc',
440+
'v_self_compilation_tcc',
441+
'v_doctor_tcc',
442+
'verify_v_test_works_tcc',
443+
'test_pure_v_math_module_tcc',
444+
'test_inline_assembly',
445+
'self_tests_tcc',
446+
'build_examples_tcc',
447+
'run_submodule_example_tcc',
448+
'build_tools_tcc',
449+
'build_vbinaries_tcc',
450+
'build_benches_tcc',
451+
'run_vsh_script_tcc',
452+
'test_v_tutorials_tcc',
453+
'build_fast_tcc',
454+
'v_self_compilation_usecache_tcc',
455+
'test_password_input_tcc',
456+
'test_readline_tcc',
457+
'test_leak_detector_tcc',
458+
'test_leak_detector_not_active_tcc',
459+
'all_code_is_formatted_gcc',
460+
'install_dependencies_for_examples_and_tools_gcc',
461+
'recompile_v_with_cstrict_gcc',
462+
'valgrind_v_c_gcc',
463+
'run_sanitizers_gcc',
464+
'v_self_compilation_gcc',
465+
'v_self_compilation_usecache_gcc',
466+
'verify_v_test_works_gcc',
467+
'test_pure_v_math_module_gcc',
468+
'self_tests_gcc',
469+
'self_tests_prod_gcc',
470+
'self_tests_cstrict_gcc',
471+
'build_examples_gcc',
472+
'build_tetris_autofree_gcc',
473+
'build_blog_autofree_gcc',
474+
'build_option_test_autofree_gcc',
475+
'v_self_compilation_parallel_cc_gcc',
476+
'build_modules_gcc',
477+
'compile_vdoctor_prod_gcc',
478+
'compile_vup_prod_gcc',
479+
'all_code_is_formatted_clang',
480+
'install_dependencies_for_examples_and_tools_clang',
481+
'recompile_v_with_cstrict_clang',
482+
'valgrind_clang',
483+
'run_sanitizers_clang',
484+
'v_self_compilation_clang',
485+
'v_self_compilation_usecache_clang',
486+
'verify_v_test_works_clang',
487+
'test_pure_v_math_module_clang',
488+
'self_tests_clang',
489+
'self_tests_vprod_clang',
490+
'self_tests_cstrict_clang',
491+
'build_examples_clang',
492+
'build_examples_autofree_clang',
493+
'build_modules_clang',
494+
]
495+
496+
// Keep progress across edits/rebuilds, but isolate users and checkout directories.
497+
fn ci_progress_path() string {
498+
checkout := sha256.hexhash(os.real_path(os.getwd()))
499+
return os.join_path(os.cache_dir(), 'v-linux-ci-${os.getuid()}-${checkout}.progress')
500+
}
501+
502+
fn ci_progress_contents(task_name string) string {
503+
// Record the whole ordered task list so changed plans restart safely.
504+
return 'linux-ci-v1\n${task_name}\n${ci_tasks.join('\n')}\n'
505+
}
506+
507+
fn ci_resume_index(path string) !int {
508+
if !os.exists(path) {
509+
return -1
510+
}
511+
if !os.is_file(path) {
512+
return error('CI progress path is not a file: ${path}')
513+
}
514+
saved := os.read_file(path)!
515+
for i, task_name in ci_tasks {
516+
if saved == ci_progress_contents(task_name) {
517+
return i
518+
}
519+
}
520+
eprintln('Ignoring invalid or outdated CI progress; restarting from the first task.')
521+
return -1
522+
}
523+
524+
fn save_ci_progress(path string, task_name string) ! {
525+
// Write privately, then rename on the same filesystem. An interrupted write
526+
// leaves the previous checkpoint intact, never a partially written cursor.
527+
if os.exists(path) && !os.is_file(path) {
528+
return error('CI progress path is not a file: ${path}')
529+
}
530+
tmp_dir := '${path}.${os.getpid()}.tmp'
531+
os.mkdir(tmp_dir, mode: 0o700)!
532+
defer {
533+
os.rmdir_all(tmp_dir) or {}
534+
}
535+
tmp_path := os.join_path(tmp_dir, 'progress')
536+
os.write_file(tmp_path, ci_progress_contents(task_name))!
537+
os.rename(tmp_path, path)!
538+
}
539+
540+
fn ci_vflags(task_index int) string {
541+
if task_index < ci_tasks.index('all_code_is_formatted_gcc') {
542+
return '-cc tcc -no-retry-compilation'
543+
}
544+
if task_index < ci_tasks.index('all_code_is_formatted_clang') {
545+
return ''
546+
}
547+
return '-cc clang'
548+
}
549+
550+
// run_ci_tasks mirrors the active ci/linux_ci.vsh steps in
551+
// .github/workflows/linux_ci.yml. The generic `all` mode intentionally remains
552+
// exhaustive, including tasks that are currently disabled in the workflow.
553+
fn run_ci_tasks(reset bool) ! {
554+
// Match the GitHub Actions environment that changes test behavior.
555+
os.setenv('CI', 'true', true)
556+
os.setenv('GITHUB_ACTIONS', 'true', true)
557+
os.setenv('RUNNER_OS', 'Linux', true)
558+
os.setenv('V_MACOS_V3_NO_FALLBACK', '1', true)
559+
// Stop test/build sessions promptly while retaining Linux CI's normal worker count.
560+
os.setenv('VTEST_FAIL_FAST', '1', true)
561+
os.setenv('VTEST_SHOW_LONGEST_BY_RUNTIME', '3', true)
562+
os.setenv('VTEST_SHOW_LONGEST_BY_COMPTIME', '3', true)
563+
os.setenv('VTEST_SHOW_LONGEST_BY_TOTALTIME', '3', true)
564+
os.setenv('VTEST_SKIP_OWNERSHIP', '1', true)
565+
566+
progress_path := ci_progress_path()
567+
progress_dir := '${progress_path}.d'
568+
saved_index := if reset { -1 } else { ci_resume_index(progress_path)! }
569+
// No valid cursor means none of its finer-grained records may be reused.
570+
if saved_index < 0 && os.exists(progress_dir) {
571+
os.rmdir_all(progress_dir)!
572+
}
573+
if !os.exists(progress_dir) {
574+
os.mkdir(progress_dir, mode: 0o700)!
575+
}
576+
start := if saved_index < 0 { 0 } else { saved_index }
577+
os.unsetenv('VTEST_RESUME_OWNER')
578+
eprintln('CI progress: ${progress_path}')
579+
eprintln('Use `v run ci/linux_ci.vsh ci --reset` to restart from the first task.')
580+
if start > 0 {
581+
eprintln('Resuming at ${ci_tasks[start]}; skipping ${start} completed CI tasks.')
582+
}
583+
for i in start .. ci_tasks.len {
584+
task_name := ci_tasks[i]
585+
// Save BEFORE execution: a failure or interruption must retry this task.
586+
save_ci_progress(progress_path, task_name)!
587+
os.setenv('V_CI_TASK_PROGRESS', os.join_path(progress_dir, task_name), true)
588+
os.setenv('VFLAGS', ci_vflags(i), true)
589+
if task_name.ends_with('_tcc') || task_name in ['build_v_with_prealloc', 'test_inline_assembly'] {
590+
os.setenv('GITHUB_JOB', 'tcc-linux', true)
591+
} else if task_name.ends_with('_gcc') {
592+
os.setenv('GITHUB_JOB', 'gcc-linux', true)
593+
} else {
594+
os.setenv('GITHUB_JOB', 'clang-linux', true)
595+
}
596+
eprintln('CI task ${i + 1}/${ci_tasks.len}: ${task_name}')
597+
exec('v run ci/linux_ci.vsh ${task_name}')
598+
}
599+
os.rmdir_all(progress_dir)!
600+
os.rm(progress_path)!
601+
eprintln('CI tasks complete; progress cleared.')
602+
}
603+
407604
// Collect all tasks
408605
const all_tasks = {
409606
'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
@@ -469,4 +666,16 @@ const all_tasks = {
469666
'test_inline_assembly': Task{test_inline_assembly, 'Test inline assembly'}
470667
}
471668
669+
if os.args.len > 1 && os.args[1] == 'ci' {
670+
if os.args.len > 3 || (os.args.len == 3 && os.args[2] != '--reset') {
671+
eprintln('Usage: v run ci/linux_ci.vsh ci [--reset]')
672+
exit(1)
673+
}
674+
run_ci_tasks(os.args.len == 3) or {
675+
eprintln('Could not update CI progress: ${err.msg()}')
676+
exit(1)
677+
}
678+
exit(0)
679+
}
680+
472681
common.run(all_tasks)

0 commit comments

Comments
 (0)