roc/.github/workflows/ci_zig.yml
Anton-4 0a11193943
Add missing fx tests (#8556)
* add missing fx tests

* cleanup
2025-12-03 18:00:32 +01:00

285 lines
No EOL
10 KiB
YAML

on:
workflow_call:
workflow_dispatch:
name: CI New Compiler
# Do not add permissions here! Configure them at the job level!
permissions: {}
jobs:
# Checks that don't need to run on every OS
check-once:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5
with:
version: 0.15.2
use-cache: true
- name: zig lints
run: |
zig run ci/zig_lints.zig
zig build check-fmt
- name: Check that test is actually wired up
run: |
zig run ci/check_test_wiring.zig
- name: Check fx platform test coverage
run: |
zig build checkfx
# We run zig check with tracy enabled.
# This ensure it compiles and doesn't go stale.
- name: Checkout Tracy
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
with:
path: tracy
repository: wolfpld/tracy
ref: v0.11.0
- name: zig check
run: |
# Just the do super fast check step for now.
zig build -Dno-bin -Dfuzz -Dtracy=./tracy
# To `roc check` benchmark script:
- name: setup Roc
run: |
curl -s -OL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz
# rename nightly tar
mv $(ls | grep "roc_nightly.*tar\.gz") roc_nightly.tar.gz
# decompress the tar
tar -xzf roc_nightly.tar.gz
rm roc_nightly.tar.gz
# simplify nightly folder name
mv roc_nightly* roc_nightly
cd roc_nightly
# make roc binary available
echo "$(pwd)" >> $GITHUB_PATH
- run: roc version
- run: |
roc check src/PROFILING/exec_bench.roc
roc test src/PROFILING/exec_bench.roc
- name: Run Playground Tests
run: |
zig build test-playground -Doptimize=ReleaseSmall -- --verbose
- name: Verify Serialized Type Sizes
run: |
zig build test-serialization-sizes
zig-tests:
needs: check-once
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
cpu_flag: -Dcpu=x86_64_v3
- os: macos-15
cpu_flag: ''
- os: ubuntu-22.04
cpu_flag: -Dcpu=x86_64_v3
- os: ubuntu-24.04-arm
cpu_flag: ''
- os: windows-2022
cpu_flag: -Dcpu=x86_64_v3
- os: windows-2025
cpu_flag: -Dcpu=x86_64_v3
- os: windows-11-arm
cpu_flag: ''
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5
with:
version: 0.15.2
use-cache: true
- if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # ratchet:cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-25.05
# temp fix, see https://roc.zulipchat.com/#narrow/channel/395097-compiler-development/topic/CI/near/542085291
- name: delete llvm-config
if: startsWith(matrix.os, 'ubuntu') && endsWith(matrix.os, '-arm')
run: |
sudo rm /usr/lib/llvm-18/bin/llvm-config
- name: build roc + repro executables
uses: ./.github/actions/flaky-retry
with:
command: "zig build -Dfuzz -Dsystem-afl=false -Doptimize=ReleaseFast ${{ matrix.cpu_flag }}"
error_string_contains: "EndOfStream"
retry_count: 3
- name: Check Builtin.roc formatting (Unix)
if: runner.os != 'Windows'
run: |
./zig-out/bin/roc fmt --check src/build/roc/Builtin.roc
- name: Check Builtin.roc formatting (Windows)
if: runner.os == 'Windows'
run: |
zig-out\bin\roc.exe fmt --check src/build/roc/Builtin.roc
- name: Run Test Platforms (Unix)
if: runner.os != 'Windows'
run: |
zig build test-cli
- name: Setup MSVC (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # ratchet:ilammy/msvc-dev-cmd@v1.13.0
with:
arch: ${{ matrix.os == 'windows-11-arm' && 'arm64' || 'x64' }}
- name: Run Test Platforms (Windows)
if: runner.os == 'Windows'
run: |
zig build test-cli
- name: Build Test Platforms (cross-compile)
if: runner.os != 'Windows'
run: |
./ci/test_int_platform.sh
- name: roc executable minimal check (Unix)
if: runner.os != 'Windows'
run: |
./zig-out/bin/roc check ./src/PROFILING/bench_repeated_check.roc
- name: roc executable minimal check (Windows)
if: runner.os == 'Windows'
run: |
zig-out\bin\roc.exe check ./src/PROFILING/bench_repeated_check.roc
- name: zig snapshot tests
run: zig build snapshot -- --debug
# 1) in debug mode
- name: build and execute tests, build repro executables
uses: ./.github/actions/flaky-retry
with:
command: "zig build test -Dfuzz -Dsystem-afl=false"
error_string_contains: "double roundtrip bundle"
retry_count: 3
# 2) in release mode
- name: Build and execute tests, build repro executables. All in release mode.
uses: ./.github/actions/flaky-retry
with:
command: "zig build test -Doptimize=ReleaseFast -Dfuzz -Dsystem-afl=false ${{ matrix.cpu_flag }}"
error_string_contains: "double roundtrip bundle"
retry_count: 3
- name: Check for snapshot changes
run: |
git diff --exit-code test/snapshots || {
echo ""
echo ""
echo "OOPS! It looks like the snapshots in 'test/snapshots' have changed.";
echo "Please run 'zig build snapshot' locally, review the updates, and commit the changes.";
echo ""
echo "NOTE: If snapshots pass locally but fail in CI, you may need to merge origin/main";
echo "into your branch first, then regenerate snapshots. CI tests your branch merged with";
echo "main, so new snapshots from main can cause diffs when regenerated with your changes.";
echo ""
echo "Here's what changed:";
echo ""
git diff test/snapshots;
exit 1;
}
- name: test with valgrind (ubuntu)
# Sadly, with zig 0.14.1, this had to be disabled on arm.
# Valgrind as of 3.25.1 does not support some arm instructions zig generates.
# So valgrind only works happily on x86_64 linux.
# We can re-evaluate as new version of zig/valgrind come out.
if: ${{ matrix.os == 'ubuntu-22.04' }}
run: |
sudo snap install valgrind --classic
valgrind --version
./ci/custom_valgrind.sh ./zig-out/bin/snapshot --debug --verbose
./ci/custom_valgrind.sh ./zig-out/bin/roc --no-cache test/str/app.roc
./ci/custom_valgrind.sh ./zig-out/bin/roc --no-cache test/int/app.roc
# valgrind all app files in test/fx except those that read from stdin
# find test/fx -maxdepth 1 -name "*.roc" -type f -exec grep -l "app \[main" {} + | xargs -I {} sh -c 'grep -L "Stdin" {} || true' | xargs -I {} ./ci/custom_valgrind.sh ./zig-out/bin/roc --no-cache {}
- 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
}
- name: Test inside nix too
if: ${{ runner.os == 'Linux' || (runner.os == 'macOS' && runner.arch != 'X64') }}
run: |
git clean -fdx
git reset --hard HEAD
nix develop ./src/ -c zig build && zig build snapshot && zig build test
zig-cross-compile:
needs: check-once
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
target:
- aarch64-linux-musl
- aarch64-macos-none
- aarch64-windows-gnu
- arm-linux-musleabihf
- x86-linux-musl
- x86_64-linux-musl
- x86_64-macos-none
- x86_64-windows-gnu
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # ratchet:mlugg/setup-zig@v2.0.5
with:
version: 0.15.2
use-cache: true
- name: cross compile with llvm
uses: ./.github/actions/flaky-retry
with:
command: zig build -Dtarget=${{ matrix.target }}
error_string_contains: "error: bad HTTP response code: '500 Internal Server Error'|TemporaryNameServerFailure|503"
# Test cross-compilation with Roc's cross-compilation system (musl + glibc)
roc-cross-compile:
uses: ./.github/workflows/ci_cross_compile.yml