roc/.github/workflows/ci_zig.yml
Richard Feldman 7bed6e5a8d
Merge pull request #8302 from roc-lang/import-builtins
Import builtins from .roc files
2025-10-20 21:48:14 -04:00

242 lines
8.3 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: |
./ci/zig_lints.sh
zig build check-fmt
# 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:
os: [
macos-15-intel,
macos-15,
ubuntu-22.04,
ubuntu-24.04-arm,
windows-2022,
windows-2025,
windows-11-arm,
] # macos-15 uses arm64
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 repro executables
uses: ./.github/actions/flaky-retry
with:
command: 'zig build -Dfuzz -Dsystem-afl=false'
error_string_contains: 'EndOfStream'
retry_count: 3
- name: Run Test Platforms (Unix)
if: runner.os != 'Windows'
run: |
./zig-out/bin/roc --no-cache test/str/app.roc
./zig-out/bin/roc --no-cache test/int/app.roc
- 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-out\bin\roc.exe --no-cache test/str/app.roc
zig-out\bin\roc.exe --no-cache test/int/app.roc
- 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
- name: build tests and 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
- 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 "Here's what changed:";
echo ""
git diff test/snapshots;
exit 1;
}
- name: check snapshots 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 apt install -y valgrind
valgrind --version
valgrind --leak-check=full --error-exitcode=1 --errors-for-leak-kinds=definite,possible ./zig-out/bin/snapshot --debug
- 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/flake.nix -c 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
run: |
./ci/retry_flaky.sh zig build -Dtarget=${{ matrix.target }}
# Test cross-compilation with Roc's cross-compilation system (musl + glibc)
roc-cross-compile:
uses: ./.github/workflows/ci_cross_compile.yml