From b5d6f406af2804fc90548a209da771c89df28c5e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 11 Feb 2025 17:35:04 +0200 Subject: [PATCH] ci: run FreeBSD on a VM in github ci, instead of on the Cirrus service (which stopped working today) (#23692) --- .cirrus.yml | 41 ------------------- .github/workflows/freebsd_ci.yml | 69 ++++++++++++++++++++++++++++++++ ci/common/runner.v | 19 +++++---- ci/freebsd_ci.vsh | 59 +++++++++++++++++++++++++++ ci/linux_ci.vsh | 10 ++--- ci/macos_ci.vsh | 2 +- 6 files changed, 146 insertions(+), 54 deletions(-) delete mode 100644 .cirrus.yml create mode 100644 .github/workflows/freebsd_ci.yml create mode 100644 ci/freebsd_ci.vsh diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index caf22a94a5467d..00000000000000 --- a/.cirrus.yml +++ /dev/null @@ -1,41 +0,0 @@ -env: - LANG: en_US.UTF-8 - -freebsd_instance: - image_family: freebsd-14-0 - -## Note: all tasks should end with _script: here, otherwise they will not be picked up! -freebsd_task: - name: FreeBSD Code CI - timeout_in: 31m - skip: "!changesInclude('.cirrus.yml', '**.{v,vsh}', '**.c', '**.h')" - install_script: pkg install -y git - diagnose_env_script: | - ## env ## CIRRUS_WORKING_DIR is /tmp/cirrus-ci-build - pwd - ls -la - whoami - git log -n1 - echo 'number of detected processors:' - getconf _NPROCESSORS_ONLN - build_script: | - echo 'Building local V' - cc --version - make CFLAGS= - build_fast_script: | - ##.github/workflows/freebsd_build_tcc.sh - ##tcc -v -v - echo 'Build cmd/tools/fast' - cd cmd/tools/fast && ../../../v fast.v ## && ./fast -clang - test_math_script: | - echo 'Test the math module' - ./v test vlib/math - test_math_pure_v_script: | - echo 'Test the math module, using only the pure V versions, without the .c.v overrides' - ./v -exclude @vlib/math/*.c.v test vlib/math - test_zip_modules_script: | - echo 'Test modules using thirdparty/zip' - ./v test vlib/compress/ - test_self_script: | - echo 'Run test-self' - VTEST_JUST_ESSENTIAL=1 ./v test-self diff --git a/.github/workflows/freebsd_ci.yml b/.github/workflows/freebsd_ci.yml new file mode 100644 index 00000000000000..884288d15aba53 --- /dev/null +++ b/.github/workflows/freebsd_ci.yml @@ -0,0 +1,69 @@ +name: CI FreeBSD + +on: + workflow_dispatch: + push: + paths-ignore: + - '**.md' + - '**.yml' + - 'cmd/tools/**' + - '!**/freebsd_ci.yml' + - '!ci/freebsd_ci.vsh' + - '!cmd/tools/builders/**.v' + pull_request: + paths-ignore: + - '**.md' + - '**.yml' + - 'cmd/tools/**' + - '!**/freebsd_ci.yml' + - '!ci/freebsd_ci.vsh' + - '!cmd/tools/builders/**.v' + +### See https://github.com/vmactions/freebsd-vm +### for a description of the used fields here + +jobs: + test-on-freebsd-14-2-x86: + runs-on: ubuntu-latest + name: Run a FreeBSD 14.2 x86 VM + steps: + - uses: actions/checkout@v4 + - name: Test in FreeBSD + id: test-freebsd-14-2-runs-in-vm + uses: vmactions/freebsd-vm@v1 + with: + release: '14.2' + mem: 4096 + usesh: true + copyback: false + prepare: pkg install -y git sqlite3 bash + run: | + git config --global --add safe.directory /home/runner/work/v/v + make CFLAGS= + ./v symlink + ./v run ci/freebsd_ci.vsh all + +##### Run a FreeBSD 14 x86 VM: +##### [ 2/25] C: 808.5 ms, R: 3.835 ms vlib/math/big/array_ops_test.v +##### Run a FreeBSD 15 ARM VM +##### [ 1/25] C: 15992.4 ms, R: 146.582 ms vlib/math/big/array_ops_test.v +##### => the overhead is too much to be practical for the full test suite. +##### It is still nice, that it works at all though ... +## test-on-freebsd-15-aarch64: +## runs-on: ubuntu-latest +## name: Run a FreeBSD 15 ARM VM +## steps: +## - uses: actions/checkout@v4 +## - name: Test in FreeBSD +## id: test-freebsd-15-runs-in-vm +## uses: vmactions/freebsd-vm@v1 +## with: +## release: "15.0" +## arch: aarch64 +## ## cpu: 3 +## mem: 4096 +## usesh: true +## copyback: false +## prepare: pkg install -y git sqlite3 bash +## run: | +## ./.github/workflows/freebsd_ci.sh diff --git a/ci/common/runner.v b/ci/common/runner.v index fe369b3828d8c1..09e7b58ff82857 100644 --- a/ci/common/runner.v +++ b/ci/common/runner.v @@ -14,6 +14,9 @@ pub fn exec(command string) { } } +const self_command = 'v ' + + os.real_path(os.executable()).replace_once(os.real_path(@VROOT), '').trim_left('/\\') + '.vsh' + pub const is_github_job = os.getenv('GITHUB_JOB') != '' pub type Fn = fn () @@ -24,12 +27,14 @@ pub mut: label string } -pub fn (t Task) run() { - log.info(term.colorize(term.yellow, t.label)) +pub fn (t Task) run(tname string) { + cmd := '${self_command} ${tname}' + log.info('Start ${term.colorize(term.yellow, t.label)}, cmd: `${cmd}`') start := time.now() t.f() dt := time.now() - start - log.info('Finished ${term.colorize(term.yellow, t.label)} in ${dt.milliseconds()} ms') + log.info('Finished ${term.colorize(term.yellow, t.label)} in ${dt.milliseconds()} ms, cmd: `${cmd}`') + println('') } pub fn run(all_tasks map[string]Task) { @@ -43,14 +48,14 @@ pub fn run(all_tasks map[string]Task) { task_name := os.args[1] if task_name == 'all' { log.info(term.colorize(term.green, 'Run everything...')) - for _, t in all_tasks { - t.run() + for tname, t in all_tasks { + t.run(tname) } exit(0) } t := all_tasks[task_name] or { - eprintln('Unknown task: ${task_name}') + eprintln('Unknown task with name: `${task_name}`') exit(1) } - t.run() + t.run(task_name) } diff --git a/ci/freebsd_ci.vsh b/ci/freebsd_ci.vsh new file mode 100644 index 00000000000000..d406d1749424d7 --- /dev/null +++ b/ci/freebsd_ci.vsh @@ -0,0 +1,59 @@ +import os +import common { Task, exec } + +fn v_doctor() { + dump(os.getenv('PATH')) + exec('v doctor') + if common.is_github_job { + exec('freebsd-version') + exec('sysctl hw.model') + exec('sysctl hw.ncpu') + exec('sysctl hw.physmem') + exec('sysctl hw.usermem') + exec('whoami') + exec('pwd') + exec('ls -la') + exec('git log -n1') + exec('cc --version') + } +} + +fn verify_v_test_works() { + exec('echo \$VFLAGS') + exec('v cmd/tools/test_if_v_test_system_works.v') + exec('./cmd/tools/test_if_v_test_system_works') +} + +fn build_fast_script() { + exec('cd cmd/tools/fast && v fast.v') +} + +fn check_math() { + exec('v test vlib/math') + println('Test the math module, using only the pure V versions,') + println(' without the .c.v overrides.') + exec('v -exclude @vlib/math/*.c.v test vlib/math') +} + +fn check_compress() { + exec('v test vlib/compress') +} + +fn run_essential_tests() { + if common.is_github_job { + exec('VTEST_JUST_ESSENTIAL=1 v test-self') + } else { + exec('VTEST_JUST_ESSENTIAL=1 v -progress test-self') + } +} + +const all_tasks = { + 'v_doctor': Task{v_doctor, 'Run v doctor'} + 'verify_v_test_works': Task{verify_v_test_works, 'Verify that v test works'} + 'build_fast_script': Task{build_fast_script, 'Check that building fast.v works'} + 'check_math': Task{check_math, 'Check the `math` module works'} + 'check_compress': Task{check_compress, 'Check the `compress` module works'} + 'run_essential_tests': Task{run_essential_tests, 'Run only the essential tests'} +} + +common.run(all_tasks) diff --git a/ci/linux_ci.vsh b/ci/linux_ci.vsh index 24ccd11a887d9f..f4dd6987c5587e 100644 --- a/ci/linux_ci.vsh +++ b/ci/linux_ci.vsh @@ -50,8 +50,8 @@ fn v_doctor() { // fn build_v_with_prealloc() { - exec('v -d debug_malloc -d debug_realloc -o v cmd/v') - exec('v -cg -cstrict -o v cmd/v') + exec('v -d debug_malloc -d debug_realloc -o vdebug1 cmd/v') + exec('v -cg -cstrict -o vstrict1 cmd/v') exec('v -o vrealloc -prealloc cmd/v && ./vrealloc -o v3 cmd/v && ./v3 -o v4 cmd/v') } @@ -68,7 +68,7 @@ fn install_dependencies_for_examples_and_tools_tcc() { fn test_v_to_c_tcc() { exec('thirdparty/tcc/tcc.exe -version') - exec('v -cg -o v cmd/v') // ensure vtcc can build itself twice + exec('v -cg -o vtcc cmd/v') // ensure vtcc can build itself twice } fn v_self_compilation_tcc() { @@ -175,7 +175,7 @@ fn install_dependencies_for_examples_and_tools_gcc() { } fn recompile_v_with_cstrict_gcc() { - exec('v -cc gcc -cg -cstrict -o v cmd/v') + exec('v -cc gcc -cg -cstrict -o vstrict cmd/v') } fn valgrind_v_c_gcc() { @@ -292,7 +292,7 @@ fn install_dependencies_for_examples_and_tools_clang() { } fn recompile_v_with_cstrict_clang() { - exec('v -cc clang -cg -cstrict -o v cmd/v') + exec('v -cc clang -cg -cstrict -o vstrict cmd/v') } fn valgrind_clang() { diff --git a/ci/macos_ci.vsh b/ci/macos_ci.vsh index 14256103a5fc39..eb2873c65c9074 100644 --- a/ci/macos_ci.vsh +++ b/ci/macos_ci.vsh @@ -10,7 +10,7 @@ fn test_cross_compilation() { } fn build_with_cstrict() { - exec('v -cg -cstrict -o v cmd/v') + exec('v -cg -cstrict -o vstrict1 cmd/v') } fn all_code_is_formatted() {