From a779412300b179291724a8bac1e52c09ce5ca666 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sun, 28 Apr 2024 14:55:48 +0200 Subject: [PATCH] wasm,tests,ci: prevent false negatives, activate windows in workflow tests (#21365) --- .github/workflows/wasm_backend_ci.yml | 68 +++++++++++++ .github/workflows/wasm_backend_tests_ci.yml | 104 -------------------- vlib/v/gen/wasm/tests/wasm_test.v | 19 +++- 3 files changed, 82 insertions(+), 109 deletions(-) create mode 100644 .github/workflows/wasm_backend_ci.yml delete mode 100644 .github/workflows/wasm_backend_tests_ci.yml diff --git a/.github/workflows/wasm_backend_ci.yml b/.github/workflows/wasm_backend_ci.yml new file mode 100644 index 00000000000000..f0689d2d5a6553 --- /dev/null +++ b/.github/workflows/wasm_backend_ci.yml @@ -0,0 +1,68 @@ +name: wasm backend CI + +on: + push: + paths: + - 'cmd/tools/builders/**.v' + - 'vlib/builtin/**.v' + - 'vlib/v/ast/**.v' + - 'vlib/v/scanner/**.v' + - 'vlib/v/parser/**.v' + - 'vlib/v/checker/**.v' + - 'vlib/v/gen/c/**.v' + - 'vlib/v/builder/**.v' + - 'vlib/v/cflag/**.v' + - 'vlib/v/live/**.v' + - 'vlib/v/util/**.v' + - 'vlib/v/markused/**.v' + - 'vlib/v/preludes/**.v' + - 'vlib/v/gen/wasm/**.v' + - 'vlib/v/gen/wasm/tests/**.v' + - '**/wasm_backend_ci.yml' + pull_request: + paths: + - 'cmd/tools/builders/**.v' + - 'vlib/builtin/**.v' + - 'vlib/v/ast/**.v' + - 'vlib/v/scanner/**.v' + - 'vlib/v/parser/**.v' + - 'vlib/v/checker/**.v' + - 'vlib/v/gen/c/**.v' + - 'vlib/v/builder/**.v' + - 'vlib/v/cflag/**.v' + - 'vlib/v/live/**.v' + - 'vlib/v/util/**.v' + - 'vlib/v/markused/**.v' + - 'vlib/v/preludes/**.v' + - 'vlib/v/gen/wasm/**.v' + - 'vlib/v/gen/wasm/tests/**.v' + - '**/wasm_backend_ci.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, macos-12, windows-2022] + fail-fast: false + timeout-minutes: 121 + env: + VTEST_ONLY: wasm + steps: + - uses: actions/checkout@v4 + - name: Build V + if: runner.os != 'Windows' + run: make -j4 + - name: Build V (Windows) + if: runner.os == 'Windows' + run: ./make.bat + - name: Build examples + run: ./v build-examples + - name: Setup Wasmer + uses: wasmerio/setup-wasmer@v3.1 + - name: Test the WASM backend + run: ./v test vlib/v/gen/wasm/tests/ diff --git a/.github/workflows/wasm_backend_tests_ci.yml b/.github/workflows/wasm_backend_tests_ci.yml deleted file mode 100644 index ecd76646d3dea3..00000000000000 --- a/.github/workflows/wasm_backend_tests_ci.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: wasm backend CI - -on: - push: - paths: - - '!**' - - '!**.md' - - 'cmd/tools/builders/**.v' - - 'vlib/builtin/**.v' - - 'vlib/v/ast/**.v' - - 'vlib/v/scanner/**.v' - - 'vlib/v/parser/**.v' - - 'vlib/v/checker/**.v' - - 'vlib/v/gen/c/**.v' - - 'vlib/v/builder/**.v' - - 'vlib/v/cflag/**.v' - - 'vlib/v/live/**.v' - - 'vlib/v/util/**.v' - - 'vlib/v/markused/**.v' - - 'vlib/v/preludes/**.v' - - 'vlib/v/gen/wasm/**.v' - - 'vlib/v/gen/wasm/tests/**.v' - pull_request: - paths: - - '!**' - - '!**.md' - - 'cmd/tools/builders/**.v' - - 'vlib/builtin/**.v' - - 'vlib/v/ast/**.v' - - 'vlib/v/scanner/**.v' - - 'vlib/v/parser/**.v' - - 'vlib/v/checker/**.v' - - 'vlib/v/gen/c/**.v' - - 'vlib/v/builder/**.v' - - 'vlib/v/cflag/**.v' - - 'vlib/v/live/**.v' - - 'vlib/v/util/**.v' - - 'vlib/v/markused/**.v' - - 'vlib/v/preludes/**.v' - - 'vlib/v/gen/wasm/**.v' - - 'vlib/v/gen/wasm/tests/**.v' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} - cancel-in-progress: true - -jobs: - wasm-backend-ubuntu: - runs-on: ubuntu-22.04 - timeout-minutes: 121 - steps: - - uses: actions/checkout@v4 - - - name: Build V - run: make && ./v symlink -githubci - - - name: Build examples - run: VTEST_ONLY=wasm ./v build-examples - - - name: Install wasmer to execute WASM modules - run: | - curl https://get.wasmer.io -sSfL | sh - sudo ln -s ~/.wasmer/bin/wasmer /usr/local/bin - - - name: Test the WASM backend - run: ./v test vlib/v/gen/wasm/tests/ - - - wasm-backend-macos: - runs-on: macOS-12 - timeout-minutes: 121 - steps: - - uses: actions/checkout@v4 - - - name: Build V - run: make && ./v symlink -githubci - - - name: Build examples - run: VTEST_ONLY=wasm ./v build-examples - - - name: Install wasmer to execute WASM modules - run: | - curl https://get.wasmer.io -sSfL | sh - sudo ln -s ~/.wasmer/bin/wasmer /usr/local/bin - - - name: Test the WASM backend - run: ./v test vlib/v/gen/wasm/tests/ - -# wasm-backend-windows: -# runs-on: windows-2022 -# timeout-minutes: 121 -# steps: -# - uses: actions/checkout@v4 -# -# - name: Build V -# run: .\make.bat -msvc -# - name: Symlink V -# run: .\v.exe symlink -githubci -# -# - name: Build examples -# run: $env:VTEST_ONLY='wasm'; v build-examples -# -# - name: Test the WASM backend -# run: v -stats test vlib/v/gen/wasm/tests/ diff --git a/vlib/v/gen/wasm/tests/wasm_test.v b/vlib/v/gen/wasm/tests/wasm_test.v index c8f02edb7345da..bc8f38d360a781 100644 --- a/vlib/v/gen/wasm/tests/wasm_test.v +++ b/vlib/v/gen/wasm/tests/wasm_test.v @@ -20,6 +20,9 @@ fn test_wasm() { if !runtime_found { eprintln('cannot find suitable wasm runtime, exiting...') + if os.getenv('VTEST_ONLY') == 'wasm' { + exit(1) + } exit(0) } @@ -27,19 +30,25 @@ fn test_wasm() { vexe := os.getenv('VEXE') vroot := os.dir(vexe) dir := os.join_path(vroot, 'vlib/v/gen/wasm/tests') - files := os.ls(dir) or { panic(err) } + files := os.ls(dir)! // wrkdir := os.join_path(os.vtmp_dir(), 'wasm_tests') - os.mkdir_all(wrkdir) or { panic(err) } + os.mkdir_all(wrkdir)! defer { os.rmdir_all(wrkdir) or {} } - os.chdir(wrkdir) or {} - tests := files.filter(it.ends_with('.vv')) + os.chdir(wrkdir)! + mut tests := files.filter(it.ends_with('.vv')) if tests.len == 0 { println('no wasm tests found') assert false } + $if windows { + // FIXME: + if os.getenv('CI') == 'true' { + tests = tests.filter(it !in ['arrays.vv', 'asm.vv', 'builtin.vv']) + } + } bench.set_total_expected_steps(tests.len) for test in tests { bench.step() @@ -60,7 +69,7 @@ fn test_wasm() { eprintln(bench.step_message_fail(cmd)) if os.exists(tmperrfile) { - err := os.read_file(tmperrfile) or { panic(err) } + err := os.read_file(tmperrfile)! eprintln(err) }