CI & release: enforce executable regression checks, PR gates, Windows unit tests, and Mac release gate (#1128)

* CI & release: enforce executable regression checks, PR gates, Windows unit tests, and Mac release gate

* Compose: keep empty environment variables distinct instead of gluing onto preceding entry
This commit is contained in:
Precious Okwu authored and GitHub committed 2026-12-02 02:41:04 +01:00
1 parent 5c29328c44
commit 3db7378e5b
15 files changed
+2160 -149

No files matched your search

+91 -14
View File
@@ -20,22 +20,23 @@
#
# - unit: the workspace's unit tests on Linux (kiri-init's as root, as in
# the guest, since several need it).
# - windows-build: the Windows app and CLI still compile, so shared code
# can't use something only Unix has.
# - windows-build: the build and unit tests on Windows, so shared and Windows
# code is both compiled and run.
# - mac-build: the build and the unit tests on a Mac, and what the runner
# offers for Kiri's VM (in its job summary).
# - scripts: a change to the suites' or scripts' shell or Python files is
# checked in under a minute: bash -n, shellcheck, py_compile, the
# regressions table and the CI scripts' own tests.
# - scripts: a change to the suites, scripts or regression targets is checked
# in under a minute: bash -n, shellcheck, py_compile, the regressions table,
# the pull request gates and the CI scripts' own tests.
# - page-scan: what a pull request adds to the window's page is read for
# new addresses, network calls and hidden code (scripts/ci/page-scan.py);
# anything flagged fails until a maintainer adds the label `page-read`.
#
# One long job waits to be asked for:
# End-to-end Linux suite:
# - e2e-linux: the Linux engine built and started as a Linux host runs it,
# then tests/e2e.sh in strict mode (what the runner lacks fails, it is
# not skipped) and tests/stress.sh, both through the docker CLI. It runs
# only on a pull request that carries the label `run-tests`. Only people
# automatically on pull requests in this repository that change the suites,
# and on any pull request that carries the label `run-tests`. Only people
# with rights on the repository can add a label. The label also starts the
# quick jobs whatever the files are.
#
@@ -85,10 +86,31 @@ jobs:
with:
fetch-depth: 2
persist-credentials: false
- name: Check regressions table and pull request gates
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
NO_REGRESSION: ${{ contains(github.event.pull_request.labels.*.name, 'no-regression-needed') }}
run: |
if git show HEAD^1:tests/lib/check-regressions.py > "$RUNNER_TEMP/check-regressions.py" 2>/dev/null \
&& grep -q '::' "$RUNNER_TEMP/check-regressions.py"; then
:
else
cp tests/lib/check-regressions.py "$RUNNER_TEMP/check-regressions.py"
fi
git show HEAD^1:scripts/ci/check-pr-gates.py > "$RUNNER_TEMP/check-pr-gates.py" 2>/dev/null \
|| cp scripts/ci/check-pr-gates.py "$RUNNER_TEMP/check-pr-gates.py"
python3 -I "$RUNNER_TEMP/check-regressions.py" --repo "$PWD"
set -- --repo "$PWD" --base HEAD^1 --head HEAD
if [ "$NO_REGRESSION" = true ]; then
set -- "$@" --skip-issue-check
fi
python3 -I "$RUNNER_TEMP/check-pr-gates.py" "$@"
- name: Which jobs this pull request needs
id: scope
env:
FORCED: ${{ contains(github.event.pull_request.labels.*.name, 'run-tests') }}
SAME_REPO: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
run: |
# The scripts are main's copies when main has them, so a pull
# request can't decide for itself that it needs no tests. They read
@@ -97,13 +119,19 @@ jobs:
git show HEAD^1:scripts/ci/tests-scope.py > "$RUNNER_TEMP/scope.py" 2>/dev/null || cp scripts/ci/tests-scope.py "$RUNNER_TEMP/scope.py"
git show HEAD^1:scripts/ci/page-scan.py > "$RUNNER_TEMP/page-scan.py" 2>/dev/null || cp scripts/ci/page-scan.py "$RUNNER_TEMP/page-scan.py"
python3 -I "$RUNNER_TEMP/scope.py" HEAD^1 HEAD | tee "$RUNNER_TEMP/scope.txt"
if grep -qx 'suites_changed=true' "$RUNNER_TEMP/scope.txt" && [ "$FORCED" != true ]; then
echo "this pull request changes the suites; add the label run-tests to run them" | tee -a "$GITHUB_STEP_SUMMARY"
fi
echo "suite=false" >> "$RUNNER_TEMP/scope.txt"
if [ "$FORCED" = true ]; then
echo "the run-tests label is on: every job runs" | tee -a "$GITHUB_STEP_SUMMARY"
printf 'linux=true\nwindows=true\nmac=true\nscripts=true\nsuite=true\n' > "$RUNNER_TEMP/scope.txt"
elif grep -qx 'suites_changed=true' "$RUNNER_TEMP/scope.txt"; then
if [ "$SAME_REPO" = true ]; then
echo "this pull request changes the suites: e2e-linux runs automatically" | tee -a "$GITHUB_STEP_SUMMARY"
echo "suite=true" >> "$RUNNER_TEMP/scope.txt"
else
echo "this pull request from a fork changes the suites; add the label run-tests to run them" | tee -a "$GITHUB_STEP_SUMMARY"
echo "suite=false" >> "$RUNNER_TEMP/scope.txt"
fi
else
echo "suite=false" >> "$RUNNER_TEMP/scope.txt"
fi
# The page scan goes by the files whatever the labels are.
python3 -I "$RUNNER_TEMP/page-scan.py" --changed HEAD^1 HEAD | tee -a "$RUNNER_TEMP/scope.txt"
@@ -141,13 +169,51 @@ jobs:
needs: scope
if: needs.scope.outputs.windows == 'true'
runs-on: windows-latest
timeout-minutes: 20
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check the Windows app and CLI compile
run: cargo check --locked --target x86_64-pc-windows-msvc -p kiri-win -p kiri
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: unit-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: unit-${{ runner.os }}-
# kiri-win includes crates/kiri/src/ui/compose.rs, whose unit tests run
# the docker CLI and Compose offline. Install the exact versions Kiri for
# Windows bundles, verified against crates/kiri/src/cli_pins.rs.
- name: The docker CLI and Compose Kiri ships
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
function Get-Pin([string]$Name) {
$m = Select-String -Path 'crates/kiri/src/cli_pins.rs' -Pattern "^pub const ${Name}: \(&str, &str\) = \(`"([^`"]+)`", `"([0-9a-f]{64})`"\);$"
if (-not $m) { throw "could not read $Name from cli_pins.rs" }
return @($m.Matches[0].Groups[1].Value, $m.Matches[0].Groups[2].Value)
}
$dv, $dsum = Get-Pin 'WIN_DOCKER_CLI'
$cv, $csum = Get-Pin 'WIN_COMPOSE'
$zip = Join-Path $env:RUNNER_TEMP 'docker.zip'
$compose = Join-Path $env:RUNNER_TEMP 'docker-compose.exe'
curl.exe -fsSL --proto '=https' -o $zip "https://download.docker.com/win/static/stable/x86_64/docker-$dv.zip"
if ((Get-FileHash -Algorithm SHA256 $zip).Hash.ToLowerInvariant() -ne $dsum) { throw 'docker.zip SHA-256 mismatch' }
curl.exe -fsSL --proto '=https' -o $compose "https://github.com/docker/compose/releases/download/$cv/docker-compose-windows-x86_64.exe"
if ((Get-FileHash -Algorithm SHA256 $compose).Hash.ToLowerInvariant() -ne $csum) { throw 'docker-compose.exe SHA-256 mismatch' }
$unzipDir = Join-Path $env:RUNNER_TEMP 'docker-unpack'
$binDir = Join-Path $env:RUNNER_TEMP 'bin'
$pluginDir = Join-Path $env:USERPROFILE '.docker\cli-plugins'
New-Item -ItemType Directory -Force -Path $unzipDir, $binDir, $pluginDir | Out-Null
tar.exe -xf $zip -C $unzipDir docker/docker.exe
Copy-Item -Force (Join-Path $unzipDir 'docker\docker.exe') (Join-Path $binDir 'docker.exe')
Copy-Item -Force $compose (Join-Path $pluginDir 'docker-compose.exe')
Add-Content -Path $env:GITHUB_PATH -Value $binDir
& (Join-Path $binDir 'docker.exe') --version
& (Join-Path $binDir 'docker.exe') compose version
- name: Build and unit tests on Windows
run: cargo test --locked --target x86_64-pc-windows-msvc -p kiri-win -p kiri
mac-build:
needs: scope
@@ -246,6 +312,17 @@ jobs:
exit $fail
- name: The regressions table names checks that exist
run: python3 tests/lib/check-regressions.py
- name: Pull request gates
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
NO_REGRESSION: ${{ contains(github.event.pull_request.labels.*.name, 'no-regression-needed') }}
run: |
set -- --base HEAD^1 --head HEAD
if [ "$NO_REGRESSION" = true ]; then
set -- "$@" --skip-issue-check
fi
python3 scripts/ci/check-pr-gates.py "$@"
- name: The CI scripts' own tests
run: python3 -m unittest discover -s scripts/ci -p 'test_*.py'