Preserve unbracketed multiline paste #231
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nix | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: nix-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| package: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 45 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Linux x86-64 | |
| runner: ubuntu-24.04 | |
| architecture: x86_64 | |
| - name: macOS arm64 | |
| runner: macos-14 | |
| architecture: arm64 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Verify runner architecture | |
| run: test "$(uname -m)" = "${{ matrix.architecture }}" | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check flake | |
| run: nix flake check --no-update-lock-file --print-build-logs | |
| - name: Rebuild deterministic image validation | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| validation_drv=$(nix eval --raw \ | |
| '.#autolith.imageValidation.drvPath') | |
| nix build "$validation_drv^*" --rebuild --no-link \ | |
| --no-update-lock-file --print-build-logs | |
| - name: Build package | |
| run: nix build .#autolith --no-update-lock-file --print-build-logs | |
| - name: Smoke-test first run | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| temporary_home=$(mktemp -d) | |
| export HOME="$temporary_home/home" | |
| export XDG_CONFIG_HOME="$temporary_home/config" | |
| export XDG_DATA_HOME="$temporary_home/data" | |
| export XDG_STATE_HOME="$temporary_home/state" | |
| mkdir -p "$XDG_STATE_HOME/autolith" | |
| printf '%s\n' preserved > "$XDG_STATE_HOME/autolith/private-state" | |
| status=0 | |
| ./result/bin/autolith </dev/null \ | |
| >"$temporary_home/stdout" \ | |
| 2>"$temporary_home/stderr" & | |
| autolith_process=$! | |
| ( | |
| sleep 600 | |
| if kill -0 "$autolith_process" 2>/dev/null; then | |
| kill "$autolith_process" || true | |
| fi | |
| ) & | |
| watchdog_process=$! | |
| wait "$autolith_process" || status=$? | |
| kill "$watchdog_process" 2>/dev/null || true | |
| wait "$watchdog_process" 2>/dev/null || true | |
| cat "$temporary_home/stderr" | |
| cat "$temporary_home/stdout" | |
| fail_smoke() | |
| { | |
| local title=$1 | |
| local detail=$2 | |
| detail=${detail//'%'/'%25'} | |
| detail=${detail//$'\r'/'%0D'} | |
| detail=${detail//$'\n'/'%0A'} | |
| printf '::error title=%s::%s\n' "$title" "$detail" | |
| exit 1 | |
| } | |
| if [ "$status" -ne 0 ]; then | |
| diagnostic=$(printf 'status=%s\nstderr:\n' "$status" | |
| tail -c 8000 "$temporary_home/stderr" | |
| printf '\nstdout:\n' | |
| tail -c 8000 "$temporary_home/stdout") | |
| fail_smoke "Autolith first run exited with status $status" "$diagnostic" | |
| fi | |
| image_identity=$(nix eval --raw '.#autolith.imageIdentity.outPath') | |
| image_directory="$XDG_DATA_HOME/autolith/nix/images/$(basename "$image_identity")" | |
| if [ "$(cat "$image_directory/identity")" != "$image_identity" ]; then | |
| fail_smoke "Autolith first run selected the wrong Nix image identity" \ | |
| "$image_directory" | |
| fi | |
| for artifact in \ | |
| active/autolith-active.core active/manifest.sexp \ | |
| recovery/autolith-recovery.core recovery/manifest.sexp; do | |
| if [ ! -f "$image_directory/$artifact" ] || \ | |
| [ -L "$image_directory/$artifact" ]; then | |
| fail_smoke "Autolith first run omitted a local Nix image artifact" \ | |
| "$image_directory/$artifact" | |
| fi | |
| done | |
| if [ ! -w "$image_directory/active/autolith-active.core" ]; then | |
| fail_smoke "Autolith Nix active image is not writable" \ | |
| "$image_directory/active/autolith-active.core" | |
| fi | |
| if [ "$(cat "$XDG_STATE_HOME/autolith/private-state")" != preserved ]; then | |
| fail_smoke "Autolith Nix image setup changed private state" \ | |
| "$XDG_STATE_HOME/autolith/private-state" | |
| fi | |
| active_hash=$(nix hash file \ | |
| "$image_directory/active/autolith-active.core") | |
| recovery_hash=$(nix hash file \ | |
| "$image_directory/recovery/autolith-recovery.core") | |
| ./result/bin/autolith --version > "$temporary_home/second-output" | |
| if [ "$active_hash" != "$(nix hash file \ | |
| "$image_directory/active/autolith-active.core")" ] || \ | |
| [ "$recovery_hash" != "$(nix hash file \ | |
| "$image_directory/recovery/autolith-recovery.core")" ]; then | |
| fail_smoke "Autolith rebuilt a valid Nix image cache" \ | |
| "$image_directory" | |
| fi | |
| if grep -F 'Installed preloaded active image' \ | |
| "$temporary_home/second-output" >/dev/null || \ | |
| grep -F 'Installed pristine recovery image' \ | |
| "$temporary_home/second-output" >/dev/null; then | |
| fail_smoke "Autolith rebuilt Nix images on its second launch" \ | |
| "$(cat "$temporary_home/second-output")" | |
| fi | |
| if ! grep -F 'AUTOLITH v' "$temporary_home/stdout" >/dev/null; then | |
| fail_smoke "Autolith first run omitted its startup marker" \ | |
| "AUTOLITH v" | |
| fi |