From 8d4974b0ec06d480381fde1b8274b60e4232ae8e Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Fri, 7 Feb 2025 21:40:23 +0100 Subject: [PATCH] new compiler CI init (#7582) * new compiler CI init * update name Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * altered exe check * add macos dynamic dep check * add windows too * use builtin windows tools * ci_manager changes * move devtools too * fix deadlock * moved md link check * correct filename Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * correct filename Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * correct trigger Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * fixed call_old_workflow if * naming fix * add output * fix finish if Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> * zig CI test change * fix auto cancellation * fix finish if * new compiler CI init update name Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> altered exe check add macos dynamic dep check add windows too use builtin windows tools ci_manager changes move devtools too fix deadlock moved md link check correct filename Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> correct filename Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> correct trigger Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> fixed call_old_workflow if naming fix add output fix finish if Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> zig CI test change fix auto cancellation fix finish if --------- Signed-off-by: Anton-4 <17049058+Anton-4@users.noreply.github.com> --- .github/workflows/ci_manager.yml | 215 +++++------------- .github/workflows/ci_manager_old.yml | 195 ++++++++++++++++ .github/workflows/ci_zig.yml | 76 +++++++ .../workflows/devtools_test_linux_x86_64.yml | 6 +- .../devtools_test_macos_apple_silicon.yml | 6 +- .github/workflows/markdown_link_check.yml | 6 +- src/cli.zig | 4 +- 7 files changed, 330 insertions(+), 178 deletions(-) create mode 100644 .github/workflows/ci_manager_old.yml create mode 100644 .github/workflows/ci_zig.yml diff --git a/.github/workflows/ci_manager.yml b/.github/workflows/ci_manager.yml index bc94d9812ee..9b071fbb407 100644 --- a/.github/workflows/ci_manager.yml +++ b/.github/workflows/ci_manager.yml @@ -1,170 +1,63 @@ -on: - pull_request: - -name: CI manager +name: CI Manager # cancel current runs when a new commit is pushed concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true + +on: + pull_request: jobs: - check-changes: - runs-on: ubuntu-22.04 - outputs: - run_tests: ${{ steps.filecheck.outputs.run_tests }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Check if only css, html or md files changed - id: check_ignored_files - run: | - git fetch origin ${{ github.base_ref }} - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qvE '(\.md$|\.css$|\.html$|^AUTHORS$)'; then - echo "should_run_tests=y" >> $GITHUB_OUTPUT - else - echo "should_run_tests=n" >> $GITHUB_OUTPUT - fi - - - name: Check if only comments changed in rust files - id: check_rs_comments - run: | - git fetch origin ${{ github.base_ref }} - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qvE '(\.md$|\.css$|\.html$|^AUTHORS$|\.rs|\.roc)'; then - echo "should_run_tests=y" >> $GITHUB_OUTPUT - else - if git diff --unified=0 origin/${{ github.base_ref }} HEAD '*.rs' | grep -E --color=never '^[+-]' | grep -qvE '^(\+\+\+|\-\-\-|[+-]\s*($|\/\/[^\/]|\/\*.*\*\/\s*$))'; then - echo "should_run_tests=y" >> $GITHUB_OUTPUT - else - echo "should_run_tests=n" >> $GITHUB_OUTPUT - fi - fi - - - name: Check if only comments changed in roc files - id: check_roc_comments - run: | - git fetch origin ${{ github.base_ref }} - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qvE '(\.md$|\.css$|\.html$|^AUTHORS$|\.rs|\.roc)'; then - echo "should_run_tests=y" >> $GITHUB_OUTPUT - else - if git diff --unified=0 origin/${{ github.base_ref }} HEAD '*.roc' | grep -E --color=never '^[+-]' | grep -qvE '^(\+\+\+|\-\-\-|[+-]\s*($|#))'; then - echo "should_run_tests=y" >> $GITHUB_OUTPUT - else - echo "should_run_tests=n" >> $GITHUB_OUTPUT - fi - fi - - - name: Check if tests need to run based on earlier checks - id: filecheck - run: | - if [ ${{ steps.check_ignored_files.outputs.should_run_tests }} = "y" ]; then - if [ ${{ steps.check_rs_comments.outputs.should_run_tests }} = "y" ]; then - echo "run_tests=full" >> $GITHUB_OUTPUT - else - if [ ${{ steps.check_roc_comments.outputs.should_run_tests }} = "y" ]; then - echo "run_tests=full" >> $GITHUB_OUTPUT - else - echo "run_tests=none" >> $GITHUB_OUTPUT - fi - fi - else - echo "run_tests=none" >> $GITHUB_OUTPUT - fi - - - run: echo "debug output ${{ steps.filecheck.outputs.run_tests }}" - - start-nix-linux-x86-64-tests: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/nix_linux_x86_64.yml - - start-nix-linux-aarch64-build-default-test: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/nix_linux_arm64_default.yml - - start-nix-linux-aarch64-cargo-build-test: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/nix_linux_arm64_cargo.yml - - start-nix-macos-apple-silicon-tests: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/nix_macos_apple_silicon.yml - - start-macos-x86-64-tests: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/macos_x86_64.yml - - start-ubuntu-x86-64-tests: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/ubuntu_x86_64.yml - - start-ubuntu-x86-64-nix-tests-debug: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/ubuntu_x86_64_nix_debug.yml - - start-windows-release-build-test: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/windows_release_build.yml - - start-windows-tests: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/windows_tests.yml - - start-roc-benchmarks: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/benchmarks.yml - - start-fuzzer-tests: - needs: check-changes - if: needs.check-changes.outputs.run_tests == 'full' - uses: ./.github/workflows/fuzzer.yml - - ran-full: - runs-on: ubuntu-22.04 - needs: [ - start-nix-linux-x86-64-tests, - start-nix-linux-aarch64-build-default-test, - start-nix-linux-aarch64-cargo-build-test, - start-nix-macos-apple-silicon-tests, - start-macos-x86-64-tests, - start-ubuntu-x86-64-tests, - start-ubuntu-x86-64-nix-tests-debug, - start-windows-release-build-test, - start-windows-tests, - start-roc-benchmarks - ] - steps: - - run: echo "all workflows succeeded!" - - ran-none: - runs-on: ubuntu-22.04 - needs: [check-changes] - if: needs.check-changes.outputs.run_tests == 'none' - steps: - - run: echo "Only non-code files changed and/or rs and/or roc comment lines changed. CI manager did not run any workflows." - - # we need a single end job for the required checks under branch protection rules - finish: - runs-on: ubuntu-22.04 - needs: [ran-full, ran-none] - if: | - always() - steps: - - name: Check previous job results - run: | - if [ "${{ needs.ran-full.result }}" != "success" ] && [ "${{ needs.ran-none.result }}" != "success" ]; then - echo "One or more jobs failed." + check-changes: + runs-on: ubuntu-24.04 + permissions: + pull-requests: read + outputs: + zig: ${{ steps.filter.outputs.zig }} + other_than_zig: ${{ steps.filter.outputs.other_than_zig }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + zig: + - 'src/**' + - 'build.zig' + - 'build.zig.zon' + other_than_zig: + - '**/*' + - '!src/**' + - '!build.zig' + - '!build.zig.zon' + + call-zig-workflow: + needs: check-changes + if: needs.check-changes.outputs.zig == 'true' + uses: ./.github/workflows/ci_zig.yml + + call-old-workflow: + needs: check-changes + if: needs.check-changes.outputs.other_than_zig == 'true' + uses: ./.github/workflows/ci_manager_old.yml + + finish: + needs: [check-changes, call-zig-workflow, call-old-workflow] + runs-on: ubuntu-latest + if: always() + steps: + - name: Check workflow results + run: | + if [[ "${{ needs.check-changes.outputs.zig }}" == "true" ]]; then + if [[ "${{ needs.call-zig-workflow.result }}" != "success" ]]; then + echo "ci_zig.yml failed." exit 1 fi - - - run: echo "Workflow succeeded :)" + fi + if [[ "${{ needs.check-changes.outputs.other_than_zig }}" == "true" ]]; then + if [[ "${{ needs.call-old-workflow.result }}" != "success" ]]; then + echo "ci_manager_old.yml failed." + exit 1 + fi + fi \ No newline at end of file diff --git a/.github/workflows/ci_manager_old.yml b/.github/workflows/ci_manager_old.yml new file mode 100644 index 00000000000..e3806d0caf4 --- /dev/null +++ b/.github/workflows/ci_manager_old.yml @@ -0,0 +1,195 @@ +on: + workflow_call: + +name: Old CI manager + +jobs: + check-changes: + runs-on: ubuntu-22.04 + outputs: + run_tests: ${{ steps.filecheck.outputs.run_tests }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check if only css, html or md files changed + id: check_ignored_files + run: | + git fetch origin ${{ github.base_ref }} + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qvE '(\.md$|\.css$|\.html$|^AUTHORS$)'; then + echo "should_run_tests=y" >> $GITHUB_OUTPUT + else + echo "should_run_tests=n" >> $GITHUB_OUTPUT + fi + + - name: Check if markdown files changed + id: check_md_changed + run: | + git fetch origin ${{ github.base_ref }} + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qE '\.md$'; then + echo "md_files_changed=y" >> $GITHUB_OUTPUT + else + echo "md_files_changed=n" >> $GITHUB_OUTPUT + fi + + - name: Check if only comments changed in rust files + id: check_rs_comments + run: | + git fetch origin ${{ github.base_ref }} + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qvE '(\.md$|\.css$|\.html$|^AUTHORS$|\.rs|\.roc)'; then + echo "should_run_tests=y" >> $GITHUB_OUTPUT + else + if git diff --unified=0 origin/${{ github.base_ref }} HEAD '*.rs' | grep -E --color=never '^[+-]' | grep -qvE '^(\+\+\+|\-\-\-|[+-]\s*($|\/\/[^\/]|\/\*.*\*\/\s*$))'; then + echo "should_run_tests=y" >> $GITHUB_OUTPUT + else + echo "should_run_tests=n" >> $GITHUB_OUTPUT + fi + fi + + - name: Check if only comments changed in roc files + id: check_roc_comments + run: | + git fetch origin ${{ github.base_ref }} + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -qvE '(\.md$|\.css$|\.html$|^AUTHORS$|\.rs|\.roc)'; then + echo "should_run_tests=y" >> $GITHUB_OUTPUT + else + if git diff --unified=0 origin/${{ github.base_ref }} HEAD '*.roc' | grep -E --color=never '^[+-]' | grep -qvE '^(\+\+\+|\-\-\-|[+-]\s*($|#))'; then + echo "should_run_tests=y" >> $GITHUB_OUTPUT + else + echo "should_run_tests=n" >> $GITHUB_OUTPUT + fi + fi + + - name: Check if tests need to run based on earlier checks + id: filecheck + run: | + if [ ${{ steps.check_ignored_files.outputs.should_run_tests }} = "y" ]; then + if [ ${{ steps.check_rs_comments.outputs.should_run_tests }} = "y" ]; then + echo "run_tests=full" >> $GITHUB_OUTPUT + else + if [ ${{ steps.check_roc_comments.outputs.should_run_tests }} = "y" ]; then + echo "run_tests=full" >> $GITHUB_OUTPUT + else + echo "run_tests=none" >> $GITHUB_OUTPUT + fi + fi + else + echo "run_tests=none" >> $GITHUB_OUTPUT + fi + + - run: echo "debug output ${{ steps.filecheck.outputs.run_tests }}" + + start-nix-linux-x86-64-tests: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/nix_linux_x86_64.yml + + start-nix-linux-aarch64-build-default-test: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/nix_linux_arm64_default.yml + + start-nix-linux-aarch64-cargo-build-test: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/nix_linux_arm64_cargo.yml + + start-nix-macos-apple-silicon-tests: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/nix_macos_apple_silicon.yml + + start-macos-x86-64-tests: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/macos_x86_64.yml + + start-ubuntu-x86-64-tests: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/ubuntu_x86_64.yml + + start-ubuntu-x86-64-nix-tests-debug: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/ubuntu_x86_64_nix_debug.yml + + start-windows-release-build-test: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/windows_release_build.yml + + start-windows-tests: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/windows_tests.yml + + start-roc-benchmarks: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/benchmarks.yml + + start-fuzzer-tests: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/fuzzer.yml + + start-devtools-tests-linux: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/devtools_test_linux_x86_64.yml + + start-devtools-tests-macos: + needs: check-changes + if: needs.check-changes.outputs.run_tests == 'full' + uses: ./.github/workflows/devtools_test_macos_apple_silicon.yml + + start-md-files-check: + needs: check-changes + if: needs.check-changes.outputs.md_files_changed == 'y' + uses: ./.github/workflows/markdown_link_check.yml + + ran-full: + runs-on: ubuntu-22.04 + needs: [ + start-nix-linux-x86-64-tests, + start-nix-linux-aarch64-build-default-test, + start-nix-linux-aarch64-cargo-build-test, + start-nix-macos-apple-silicon-tests, + start-macos-x86-64-tests, + start-ubuntu-x86-64-tests, + start-ubuntu-x86-64-nix-tests-debug, + start-windows-release-build-test, + start-windows-tests, + start-roc-benchmarks, + start-devtools-tests-linux, + start-devtools-tests-macos, + start-md-files-check, + ] + steps: + - run: echo "all workflows succeeded!" + + ran-none: + runs-on: ubuntu-22.04 + needs: [check-changes] + if: needs.check-changes.outputs.run_tests == 'none' + steps: + - run: echo "Only non-code files changed and/or rs and/or roc comment lines changed. CI manager did not run any workflows." + + # we need a single end job for the required checks under branch protection rules + finish: + runs-on: ubuntu-22.04 + needs: [ran-full, ran-none] + if: | + always() + steps: + - name: Check previous job results + run: | + if [ "${{ needs.ran-full.result }}" == "success" ] || [ "${{ needs.ran-full.result }}" == "skipped" ]; then + exit 0 + else + echo "One or more jobs failed." + exit 1 + fi + + - run: echo "Workflow succeeded :)" diff --git a/.github/workflows/ci_zig.yml b/.github/workflows/ci_zig.yml new file mode 100644 index 00000000000..ba70d864ae5 --- /dev/null +++ b/.github/workflows/ci_zig.yml @@ -0,0 +1,76 @@ +on: + workflow_call: + +name: CI New Compiler + +jobs: + check-zig-fmt: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.13.0 + + - run: zig fmt --check . + + zig-tests: + needs: check-zig-fmt + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-13, macos-14, ubuntu-24.04, ubuntu-24.04-arm, windows-2022] # macos-13 uses x64, macos-14 uses arm64 + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.13.0 + + - run: zig build + + - name: roc executable minimal check (Unix) + if: runner.os != 'Windows' + run: | + ./zig-out/bin/roc -h | grep -q "Usage:" + + - name: roc executable minimal check (Windows) + if: runner.os == 'Windows' + run: | + zig-out\bin\roc.exe -h | findstr "Usage:" + + - name: zig tests (Unix) + if: runner.os != 'Windows' + run: ./zig-out/bin/test + + - name: zig tests (Windows) + if: runner.os == 'Windows' + run: zig-out\bin\test.exe + + - name: check if statically linked (ubuntu) + if: startsWith(matrix.os, 'ubuntu') + run: | + file ./zig-out/bin/roc | grep "statically linked" + + - name: check if statically linked (macOS) + if: startsWith(matrix.os, 'macos') + run: | + otool_out="$(otool -L ./zig-out/bin/roc)" + num_lines=$(echo "$otool_out" | wc -l) + if [ "$num_lines" -ne 2 ]; then + echo "$otool_out" + echo "Looks like you added a new dynamic dependency to the Roc executable, we want Roc to be super easy to install, so libSystem should be the only dynamic dependency." + exit 1 + fi + + - name: check if statically linked (Windows) + if: startsWith(matrix.os, 'windows') + run: | + $imports = (Get-Command zig-out\bin\roc.exe).FileVersionInfo.ImportCharacterSet + if ($imports) { + echo "Looks like the executable has dynamic dependencies. We want Roc to be super easy to install, so it should be statically linked." + echo "Dynamic dependencies found:" + $imports | ForEach-Object { echo " $_" } + exit 1 + } diff --git a/.github/workflows/devtools_test_linux_x86_64.yml b/.github/workflows/devtools_test_linux_x86_64.yml index e6de0d87eec..11dd4c34c74 100644 --- a/.github/workflows/devtools_test_linux_x86_64.yml +++ b/.github/workflows/devtools_test_linux_x86_64.yml @@ -1,12 +1,8 @@ on: - pull_request: + workflow_call: name: devtools nix files test - linux -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: devtools-test-linux: name: devtools-test-linux diff --git a/.github/workflows/devtools_test_macos_apple_silicon.yml b/.github/workflows/devtools_test_macos_apple_silicon.yml index d9dd9a644d7..6b17c3b8658 100644 --- a/.github/workflows/devtools_test_macos_apple_silicon.yml +++ b/.github/workflows/devtools_test_macos_apple_silicon.yml @@ -1,12 +1,8 @@ on: - pull_request: + workflow_call: name: devtools nix files test - macos -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: devtools-test-macos: name: devtools-test-mac diff --git a/.github/workflows/markdown_link_check.yml b/.github/workflows/markdown_link_check.yml index 2dceabbfbf2..862c196ff28 100644 --- a/.github/workflows/markdown_link_check.yml +++ b/.github/workflows/markdown_link_check.yml @@ -1,14 +1,10 @@ on: - pull_request: + workflow_call: schedule: - cron: '0 9 * * *' # 9=9am utc+0 name: Check Markdown links -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: markdown-link-check: runs-on: ubuntu-22.04 diff --git a/src/cli.zig b/src/cli.zig index 28af5f413e7..599ebdf060e 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -14,7 +14,7 @@ pub const RocCmd = enum { roc_glue, roc_help, - pub fn parse(str: []const u8) ?RocCmd { + pub fn parse(arg_str: []const u8) ?RocCmd { const map = std.static_string_map.StaticStringMap(RocCmd).initComptime(.{ .{ "run", .roc_run }, .{ "build", .roc_build }, @@ -28,7 +28,7 @@ pub const RocCmd = enum { .{ "help", .roc_help }, }); - if (map.get(str)) |cmd| { + if (map.get(arg_str)) |cmd| { return cmd; } return null;