@@ -286,7 +286,7 @@ jobs:
286286 duration=$((end - start))
287287 echo "Docker Pull Time: $duration seconds"
288288 echo "[{\"name\": \"Docker Pull Time\", \"unit\": \"seconds\", \"value\": $duration}]" > pull_time.json
289-
289+
290290 docker tag ghcr.io/google/zerocopy/anneal:${STEPS_DOCKER_TAG_OUTPUTS_TAG} anneal-ci:local
291291 env :
292292 STEPS_DOCKER_TAG_OUTPUTS_TAG : ${{ steps.docker_tag.outputs.tag }}
@@ -471,6 +471,100 @@ jobs:
471471 fi
472472 fi
473473
474+ v2_nix_cache :
475+ name : Warm Nix Cache for V2
476+ runs-on : ubuntu-latest
477+ needs : build_docker_env
478+ permissions :
479+ contents : read
480+ id-token : write # Required to exchange GitHub OIDC tokens for Determinate Systems Cache API access
481+ steps :
482+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
483+ with :
484+ persist-credentials : false
485+
486+ - name : Install Nix
487+ uses : DeterminateSystems/determinate-nix-action@441b9e401ac050c38a07d8313748c5c2d17e8aff # v3.6.1
488+
489+ - name : Run Magic Nix Cache
490+ uses : DeterminateSystems/magic-nix-cache-action@908b263ff629f4cc17666315b7fd3ec127c6244d # v14
491+
492+ # On Ubuntu 24.04 (currently `ubuntu-latest`), AppArmor restricts unprivileged user namespaces by default.
493+ # The Nix build sandbox runs `steam-run` (which uses `bubblewrap`/`bwrap`) during the `mathlib-cache-download`
494+ # phase to create an FHS environment. `bwrap` requires creating a user namespace to set up uid mappings,
495+ # which fails with "Permission denied" unless this restriction is temporarily disabled on the host.
496+ #
497+ # We temporarily disable it right before the `nix build` step and re-enable it immediately after
498+ # to maintain the principle of least privilege.
499+ #
500+ # FIXME(#3412): Deduplicate this with what's repeated below?
501+ - name : Enable unprivileged user namespaces (Ubuntu 24.04)
502+ run : sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
503+
504+ - name : Warm Nix Cache
505+ run : nix build .#omnibus-archive
506+ working-directory : anneal/v2
507+
508+ # Re-enable the AppArmor namespace restriction to restore the runner host's default security posture.
509+ # `if: always()` ensures this cleanup step runs even if the Nix build fails.
510+ - name : Restore AppArmor restriction
511+ if : always()
512+ run : sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=1
513+
514+ v2 :
515+ name : Run V2 tests
516+ runs-on : ubuntu-latest
517+ # Depending on `v2_nix_cache` avoids duplicate work and ensure `nix build ...` step for this job is fast.
518+ needs : [build_docker_env, v2_nix_cache]
519+ permissions :
520+ contents : read
521+ id-token : write # Required to exchange GitHub OIDC tokens for Determinate Systems Cache API access
522+ steps :
523+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
524+ with :
525+ persist-credentials : false
526+
527+ - name : Install Nix
528+ uses : DeterminateSystems/determinate-nix-action@441b9e401ac050c38a07d8313748c5c2d17e8aff # v3.6.1
529+
530+ - name : Run Magic Nix Cache
531+ uses : DeterminateSystems/magic-nix-cache-action@908b263ff629f4cc17666315b7fd3ec127c6244d # v14
532+
533+ # On Ubuntu 24.04 (currently `ubuntu-latest`), AppArmor restricts unprivileged user namespaces by default.
534+ # The Nix build sandbox runs `steam-run` (which uses `bubblewrap`/`bwrap`) during the `mathlib-cache-download`
535+ # phase to create an FHS environment. `bwrap` requires creating a user namespace to set up uid mappings,
536+ # which fails with "Permission denied" unless this restriction is temporarily disabled on the host.
537+ #
538+ # We temporarily disable it right before the `nix build` step and re-enable it immediately after
539+ # to maintain the principle of least privilege.
540+ #
541+ # FIXME(#3412): Deduplicate this with what's repeated above?
542+ - name : Enable unprivileged user namespaces (Ubuntu 24.04)
543+ run : sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
544+
545+ - name : Build outside-cargo dependencies (cached)
546+ run : |
547+ mkdir -p target
548+ nix build .#omnibus-archive --out-link target/anneal-exocrate.tar.zst
549+ working-directory : anneal/v2
550+
551+ # Re-enable the AppArmor namespace restriction to restore the runner host's default security posture.
552+ # `if: always()` ensures this cleanup step runs even if the Nix build fails.
553+ - name : Restore AppArmor restriction
554+ if : always()
555+ run : sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=1
556+
557+ # FIXME: Pin this nightly to the same Rust date encoded in
558+ # anneal/v2/flake.nix, or derive it from the archive metadata, so v2 CI is
559+ # reproducible instead of following whatever nightly happens to be latest.
560+ - name : Install latest nightly Rust
561+ uses : dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # zizmor: ignore[superfluous-actions]
562+ with :
563+ toolchain : nightly
564+
565+ - name : Run V2 tests
566+ run : cargo test --workspace --all-features # include, e.g., tests that assume exocrate prebuilt
567+ working-directory : anneal/v2
474568
475569 # Used to signal to branch protections that all other jobs have succeeded.
476570 all-jobs-succeed :
@@ -485,7 +579,7 @@ jobs:
485579 # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
486580 if : failure()
487581 runs-on : ubuntu-latest
488- needs : [build_docker_env, anneal_tests, verify_examples, measure_image_size]
582+ needs : [build_docker_env, anneal_tests, verify_examples, measure_image_size, v2_nix_cache, v2 ]
489583 steps :
490584 - name : Mark the job as failed
491585 run : exit 1
0 commit comments