image-repository: add alpine-3.23 #60
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: Build and test changed container images | |
| on: | |
| push: | |
| paths: | |
| - .github/workflows/image-scripts.yml | |
| - image-scripts/** | |
| - os/lib/nixos-container/** | |
| pull_request: | |
| paths: | |
| - .github/workflows/image-scripts.yml | |
| - image-scripts/** | |
| - os/lib/nixos-container/** | |
| env: | |
| NIX_PATH: nixpkgs=https://channels.nixos.org/nixos-25.11/nixexprs.tar.xz | |
| jobs: | |
| build: | |
| name: Build OS and populate binary cache | |
| runs-on: self-hosted | |
| timeout-minutes: 180 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Determine branch name | |
| id: vars | |
| run: | | |
| echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
| - name: Build toplevel closure | |
| run: | | |
| make toplevel | |
| echo "BUILD_OUT=$(readlink -f os/result/toplevel)" >> $GITHUB_ENV | |
| - name: Copy toplevel closure to binary cache | |
| env: | |
| VPSADMINOS_CACHE_SSH_KEY: ${{ secrets.VPSADMINOS_CACHE_SSH_KEY }} | |
| run: | | |
| install -m 600 -D <(echo "$VPSADMINOS_CACHE_SSH_KEY") .ssh/cache_id | |
| NIX_SSHOPTS="-i .ssh/cache_id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" nix-copy-closure --to [email protected] "$BUILD_OUT" | |
| - name: Add new profile generation | |
| env: | |
| BRANCH: ${{ steps.vars.outputs.branch }} | |
| run: | | |
| ssh -i .ssh/cache_id \ | |
| -o StrictHostKeyChecking=no \ | |
| -o UserKnownHostsFile=/dev/null \ | |
| [email protected] \ | |
| sudo push-ci-generation "$BRANCH" "$BUILD_OUT" | |
| detect: | |
| name: Detect changed image scripts | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| outputs: | |
| images: ${{ steps.set.outputs.images }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - id: set | |
| shell: bash | |
| run: | | |
| BASE_SHA=$(jq -r '.before // .pull_request.base.sha' "$GITHUB_EVENT_PATH") | |
| HEAD_SHA=$GITHUB_SHA | |
| images=$(BASE_SHA="$BASE_SHA" HEAD_SHA="$HEAD_SHA" ruby .github/workflows/scripts/changed-image-scripts.rb) | |
| echo "Detected images: $images" | |
| echo "images=$images" >> "$GITHUB_OUTPUT" | |
| test: | |
| name: Build and test changed images | |
| needs: detect | |
| if: ${{ needs.detect.outputs.images != '' }} | |
| runs-on: self-hosted | |
| timeout-minutes: 86400 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Determine job count | |
| id: determine-test-jobs | |
| uses: ./.github/actions/determine-test-jobs | |
| - name: Build and test images | |
| run: | | |
| set -o pipefail | |
| ./test-runner.sh test -f -j "${{ steps.determine-test-jobs.outputs.jobs }}" "image-scripts/test@{${{ needs.detect.outputs.images }}}" | tee test.log | |
| - name: Evaluate test results | |
| if: always() | |
| run: | | |
| EXPECTED_SUCCESSFUL=$(grep -oP "\d+ tests successful" test.log | cut -f1 -d ' ') | |
| EXPECTED_FAILED=$(grep -oP "\d+ tests failed as expected" test.log | cut -f1 -d ' ') | |
| UNEXPECTED_FAILED=$(grep -oP "\d+ tests should have succeeded" test.log | cut -f1 -d ' ') | |
| UNEXPECTED_SUCCESSFUL=$(grep -oP "\d+ tests should have failed" test.log | cut -f1 -d ' ') | |
| echo "expected_successful=${EXPECTED_SUCCESS:-0}" >> $GITHUB_OUTPUT | |
| echo "expected_failed=${EXPECTED_FAILED:-0}" >> $GITHUB_OUTPUT | |
| echo "unexpected_failed=${UNEXPECTED_FAILED:-0}" >> $GITHUB_OUTPUT | |
| echo "unexpected_successful=${UNEXPECTED_SUCCESSFUL:-0}" >> $GITHUB_OUTPUT | |
| { | |
| echo '### Test summary' | |
| echo "" | |
| echo "| Result | Count |" | |
| echo "|--------|-------|" | |
| echo "| ✅ Successful (expected) | ${EXPECTED_SUCCESSFUL:-0} |" | |
| echo "| ⚠️ Failed (expected) | ${EXPECTED_FAILED:-0} |" | |
| echo "| ❌ Failed (unexpected) | ${UNEXPECTED_FAILED:-0} |" | |
| echo "| ❌ Successful (unexpected) | ${UNEXPECTED_SUCCESSFUL:-0} |" | |
| echo "" | |
| } >> $GITHUB_STEP_SUMMARY | |
| if [ "${UNEXPECTED_FAILED:-0}" -gt 0 ] || [ "${UNEXPECTED_SUCCESSFUL:-0}" -gt 0 ]; then | |
| echo "::error::${UNEXPECTED_FAILED:-0} tests unexpectedly failed, ${UNEXPECTED_SUCCESSFUL:-0} tests unexpectedly succeeded" | |
| exit 1 | |
| fi | |
| - name: Summarise test logs | |
| if: always() | |
| run: | | |
| summary_file="$GITHUB_STEP_SUMMARY" | |
| logs_root=/tmp/os-test-runner | |
| if [ -d "$logs_root" ]; then | |
| echo "## Per-test logs (tail, last 200 lines each)" >>"$summary_file" | |
| echo >>"$summary_file" | |
| # One collapsible <details> section per test | |
| for test_dir in "$logs_root"/os-test-*; do | |
| test_name=$(basename "$test_dir") | |
| result_file="$test_dir"/test-result.txt | |
| [ -e "$result_file" ] || continue | |
| test_result=$(cat "$test_dir"/test-result.txt) | |
| if [ "$test_result" == "expected_success" ] || [ "$test_result" == "expected_failure" ]; then | |
| continue | |
| fi | |
| echo "<details><summary><code>$test_name</code></summary>" >>"$summary_file" | |
| echo >>"$summary_file" | |
| for f in "$test_dir"/*.log; do | |
| echo "#### $(basename "$f")" >>"$summary_file" | |
| echo '```' >>"$summary_file" | |
| tail -n 200 "$f" >>"$summary_file" | |
| echo '```' >>"$summary_file" | |
| echo >>"$summary_file" | |
| done | |
| echo '</details>' >>"$summary_file" | |
| echo >>"$summary_file" | |
| done | |
| fi | |
| - name: Upload full test logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: os-test-logs-${{ github.run_id }} | |
| path: | | |
| /tmp/os-test-runner/**/*.log | |
| /tmp/os-test-runner/**/*.txt | |
| retention-days: 14 | |
| if-no-files-found: ignore |