Files
kryon/.github/workflows/ci.yml
T

359 lines
13 KiB
YAML

name: CI
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
# Several sessions push master many times an hour, longer apart than a run
# takes; cancelling on master left no finished run. Only pull requests
# replace their older runs.
concurrency:
group: ci-${{ github.ref }}-${{ github.event_name == 'pull_request' && 'pr' || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
ZIRAN_ROOT: ${{ github.workspace }}/ziran
jobs:
# A broken host link fails here in minutes, before the long jobs start.
push-check:
name: Source rules and host links
runs-on: ubuntu-latest
outputs:
code: ${{ steps.changes.outputs.code }}
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# Every job that builds the AVIF decoder needs Meson and Ninja for dav1d,
# and on x86-64 nasm for dav1d's and libaom's SIMD; arm64 builds assemble
# with the C compiler.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@a4956dec87b259c044ef7cb661aafa0ba2d742c5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential python3 ripgrep pkg-config libsdl2-dev libcairo2-dev libglib2.0-dev
libpango1.0-dev libdrm-dev libgbm-dev libegl-dev libgles-dev libegl-mesa0
libgl1-mesa-dri libx11-dev libxt-dev libxext-dev libfontconfig1-dev libfreetype-dev
libxkbcommon-x11-0
libcurl4-openssl-dev fonts-dejavu-core fonts-wqy-zenhei xvfb xdotool x11-apps x11-utils
imagemagick xfwm4 dbus-x11 cmake nasm meson ninja-build libwebpdemux2
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
- name: Source rules and host links
run: make push-check
# A push touching only prose or the site skips the long jobs: this job
# still checks the docs, and the Pages workflow tests the site. Anything
# unknown runs everything.
- name: Decide whether the long jobs apply
id: changes
env:
GH_TOKEN: ${{ github.token }}
BEFORE: ${{ github.event.before }}
run: |
code=true
if [ "$GITHUB_EVENT_NAME" = push ] && files=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$GITHUB_SHA" --jq '.files[].filename'); then
count=$(printf '%s\n' "$files" | grep -c . || true)
other=$(printf '%s\n' "$files" | grep -vE '^docs/|\.md$' || true)
if [ "$count" -gt 0 ] && [ "$count" -lt 300 ] && [ -z "$other" ]; then code=false; fi
fi
echo "code=$code" >> "$GITHUB_OUTPUT"
test-macos-zx:
name: macOS native ZX build and display-free execution
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: macos-latest
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# The locked compiler comes prebuilt, and the package checkouts cached.
- name: Set up the locked Ziran and fetch packages
uses: ziranlang/ziran/.github/actions/setup@a4956dec87b259c044ef7cb661aafa0ba2d742c5
with:
project: kryon
path: ziran
fetch: true
- name: Install the AVIF decoder's dav1d build tools
run: brew install meson ninja pkgconf sdl2 cairo pango fontconfig freetype gdk-pixbuf webp $([ "$RUNNER_ARCH" = X64 ] && echo nasm)
# No GUI launch or screenshot can reach a runner's inherited display.
- name: Build native player and execute the portable VM with CPU pixels
run: |
export PATH="$ZIRAN_ROOT/build/bin:$PATH"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
make zx-headless-test zx-player
build/bin/zx --check build/scratch/zx-headless/app.zx
test-linux:
name: Ziran library and host tests (${{ matrix.shard }})
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [zx, check, web, site, hosts]
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# Template tests serve the checkouts through local Git URLs and use
# their master refs.
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@a4956dec87b259c044ef7cb661aafa0ba2d742c5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential ccache python3 ripgrep xvfb pkg-config libsdl2-dev libcairo2-dev
libfreetype-dev libfontconfig1-dev libcurl4-openssl-dev libdrm-dev libgbm-dev
libegl-dev libgles-dev libegl-mesa0 libgl1-mesa-dri imagemagick xclip xdotool
libxkbcommon-x11-0
x11-xserver-utils python3-gi python3-gi-cairo python3-cairo python3-pil python3-xlib ffmpeg gir1.2-gtk-3.0 gir1.2-atspi-2.0
libglib2.0-dev libpango1.0-dev at-spi2-core dbus-x11 gstreamer1.0-plugins-base
gstreamer1.0-plugins-good gstreamer1.0-libav cmake nasm meson ninja-build libwebpdemux2 libopus-dev
# SDL3's GPU renderer needs Vulkan even on a software-only runner.
- name: Install native host test tools
if: matrix.shard == 'hosts'
run: sudo apt-get install -y libvulkan-dev mesa-vulkan-drivers libx11-dev libxext-dev libxtst-dev xauth libgtk-3-dev
# Template tests serve this checkout through local Git URLs and use
# the manifest's master ref. Keep that ref at the locked commit.
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '22'
# The pay-per-import test and the gallery build these examples as
# applications of this checkout, as ziran.local.toml does locally.
- name: Build the in-tree examples from this checkout
if: matrix.shard == 'hosts' || matrix.shard == 'site'
run: |
python3 - <<'PY'
import os, subprocess
from pathlib import Path
ziran = Path(os.environ['ZIRAN_ROOT'])
settings = f'[overrides]\nkryon = "{Path.cwd()}"\nziran = "{ziran}"\n'
for project in ('examples/box', 'examples/button', 'examples/image', 'examples/textfield', 'examples/gallery'):
(Path(project) / 'ziran.local.toml').write_text(settings)
subprocess.run([str(ziran / 'build/bin/ziran'), 'lock'], cwd=project, check=True)
PY
# The Canvas2D and DOM tests compile to Wasm with emscripten and run
# in private headless Chrome; the tests look for ~/emsdk.
- name: Restore emsdk
id: emsdk
uses: actions/cache@v6
with:
path: ~/emsdk
key: emsdk-${{ runner.os }}-6.0.6
- name: Install emsdk
if: steps.emsdk.outputs.cache-hit != 'true'
working-directory: .
run: |
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
~/emsdk/emsdk install 6.0.6
~/emsdk/emsdk activate 6.0.6
- name: Keep compile results between runs
uses: ./kryon/.github/actions/compile-cache
with:
key: ${{ matrix.shard }}
# The behavior suite executes the Windows storage regression under Wine.
- name: Install Windows storage test tools
if: matrix.shard == 'check'
run: sudo apt-get install -y gcc-mingw-w64-x86-64 wine wine64
- name: Test opt-in SDL3 GPU renderer on a private display
if: matrix.shard == 'hosts'
env:
LIBGL_ALWAYS_SOFTWARE: '1'
run: |
set -- /usr/share/vulkan/icd.d/lvp_icd*.json
test -f "$1"
export VK_DRIVER_FILES="$1"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS HARMONY_DESKTOP_RECOVERY=0 make sdl3-test
- name: Build and test
if: matrix.shard != 'site'
env:
CHROMIUM: google-chrome
run: env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS HARMONY_DESKTOP_RECOVERY=0 make test-shard-${{ matrix.shard }}
- name: Check repeatable frame workloads
if: matrix.shard == 'hosts'
run: python3 tools/performance.py --budget-ms 64
- name: Test SVG example
if: matrix.shard == 'hosts'
run: env -u DISPLAY -u WAYLAND_DISPLAY make -C examples test
# The whole site is rebuilt from this checkout, so the live editor's
# embedded examples match the gallery under test. Nothing is deployed.
- name: Build and test the widget gallery
if: matrix.shard == 'site'
env:
CHROMIUM: google-chrome
run: |
export PATH="$ZIRAN_ROOT/build/bin:$PATH"
make site
python3 tests/gallery_modules_test.py
make site-browser-test
- name: Show how much the compile cache saved
if: always()
run: ccache --show-stats || true
test-sanitizers:
name: Behavior tests under AddressSanitizer and UndefinedBehaviorSanitizer
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# Template tests serve the checkouts through local Git URLs and use
# their master refs.
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@a4956dec87b259c044ef7cb661aafa0ba2d742c5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential python3 python3-pil ripgrep ffmpeg pkg-config libsdl2-dev
libcairo2-dev libglib2.0-dev libpango1.0-dev libfreetype-dev libfontconfig1-dev
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-libav cmake
nasm meson ninja-build libwebpdemux2
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
- name: Install Windows storage test tools
run: sudo apt-get install -y gcc-mingw-w64-x86-64 wine wine64 xvfb xauth
- name: Run the behavior tests with sanitized C
run: env -u DISPLAY -u WAYLAND_DISPLAY make sanitize-test TEST_JOBS=4
test-desktop-hosts:
name: Desktop hosts on private Xvfb
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# Template tests serve the checkouts through local Git URLs and use
# their master refs.
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@a4956dec87b259c044ef7cb661aafa0ba2d742c5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential python3 pkg-config libsdl2-dev libcairo2-dev libglib2.0-dev
libpango1.0-dev libdrm-dev libgbm-dev libegl-dev libgles-dev libegl-mesa0
libgl1-mesa-dri libx11-dev libxt-dev libxext-dev libxtst-dev libfontconfig1-dev libfreetype-dev
libxkbcommon-x11-0
fonts-dejavu-core fonts-wqy-zenhei xvfb xdotool x11-apps x11-utils imagemagick xfwm4
dbus-x11 cmake nasm meson ninja-build libwebpdemux2 libopus-dev
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
# Each test starts its own display with xvfb-run -a; none may reach a
# real one.
- name: Desktop host
run: env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY make desktop-project-test
- name: Desktop frame input snapshots
run: make desktop-frame-input-test