Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions .github/workflows/axum-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Axum container preparation

on:
pull_request:
branches: [main]
paths:
- .github/workflows/axum-container.yml
- Cargo.toml
- Cargo.lock
- .tool-versions
- crates/**
- examples/app-demo/**
- examples/container-publishing/**
- examples/axum-deployment/**
- scripts/*axum_container*.sh
- scripts/axum_container*.mjs
- scripts/package*.json
- scripts/tests/*axum_container*.mjs
push:
branches: [main]
paths:
- .github/workflows/axum-container.yml
- Cargo.toml
- Cargo.lock
- .tool-versions
- crates/**
- examples/app-demo/**
- examples/container-publishing/**
- examples/axum-deployment/**
- scripts/*axum_container*.sh
- scripts/axum_container*.mjs
- scripts/package*.json
- scripts/tests/*axum_container*.mjs

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
prepare:
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Retrieve Node version
id: node-version
run: echo "node-version=$(awk '$1 == "nodejs" { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicated Node setup: this "Retrieve Node version" + setup-node pair is repeated in three jobs (and deploy-action). setup-node supports node-version-file: .tool-versions directly, which removes the awk step. Also ⛏ the pin comment is # v6; other actions name the exact release.

- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: ${{ steps.node-version.outputs.node-version }}
- name: Use the declared Rust toolchain
run: |
version=$(awk '$1 == "rust" { print $2 }' .tool-versions)
rustup toolchain install "$version" --profile minimal
echo "RUSTUP_TOOLCHAIN=$version" >> "$GITHUB_ENV"
- name: Install framework helper dependencies
run: npm ci --prefix scripts --ignore-scripts
- name: Prepare one application and lockfile
run: |
./scripts/prepare_generated_axum_container.sh "$RUNNER_TEMP/fixture"
AXUM_PREPARED_CONTEXT="$RUNNER_TEMP/fixture/container-probe" \
node --test scripts/tests/test_axum_container*.test.mjs
tar -C "$RUNNER_TEMP/fixture" -cf "$RUNNER_TEMP/context.tar" container-probe
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: axum-context-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/context.tar
if-no-files-found: error
retention-days: 7

native:
needs: prepare
timeout-minutes: 30
# Framework packaging evidence is not application release approval.
env:
SCAN_POLICY: report-only
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Retrieve Node version
id: node-version
run: echo "node-version=$(awk '$1 == "nodejs" { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: ${{ steps.node-version.outputs.node-version }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: axum-context-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/context
digest-mismatch: error
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
with:
version: v0.37.0
use: false
driver-opts: image=moby/buildkit:v0.25.1@sha256:79cc6476ab1a3371c9afd8b44e7c55610057c43e18d9b39b68e2b0c2475cc1b6

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏ Duplicate BuildKit pin for an unused builder

With use: false, this step only installs buildx; scripts/test_axum_container_handoff.sh creates its own builder from BUILDKIT_IMAGE in examples/container-publishing/tools.env. The driver-opts image here, and the same line in examples/container-publishing/release.yml:116, is a second copy of that pin that configures a builder nothing uses, so the two can drift unnoticed. Drop driver-opts and keep tools.env as the single source.

- name: Install framework helper dependencies
run: npm ci --prefix scripts --ignore-scripts
- name: Native image, packaging, scan and OCI identity checks
env:
ARCH: ${{ matrix.arch }}
run: |
tar -C "$RUNNER_TEMP/context" -xf "$RUNNER_TEMP/context/context.tar" --no-same-owner
./scripts/test_axum_container_handoff.sh build \
"$RUNNER_TEMP/context/container-probe" "$RUNNER_TEMP/accepted" \
"linux/$ARCH" "$GITHUB_SHA" "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: accepted-${{ matrix.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/accepted/image.tar
${{ runner.temp }}/accepted/receipt.json
${{ runner.temp }}/accepted/inputs.json
${{ runner.temp }}/accepted/scan.json
${{ runner.temp }}/accepted/scanner.json
${{ runner.temp }}/accepted/sbom.json
${{ runner.temp }}/accepted/provenance.json
${{ runner.temp }}/accepted/rust-advisories.json
if-no-files-found: error
retention-days: 7
- name: Retain sanitized failure evidence separately
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: failed-${{ matrix.arch }}-${{ github.run_id }}-${{ github.run_attempt }}
path: |
${{ runner.temp }}/accepted/*.log
${{ runner.temp }}/accepted/scan.json
${{ runner.temp }}/accepted/scanner.json
${{ runner.temp }}/accepted/image.json
${{ runner.temp }}/accepted/inputs.json
${{ runner.temp }}/accepted/rust-advisories.json
${{ runner.temp }}/accepted/smoke
if-no-files-found: warn
retention-days: 7

handoff:
needs: native
runs-on: ubuntu-24.04
timeout-minutes: 15
env:
SCAN_POLICY: report-only
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Retrieve Node version
id: node-version
run: echo "node-version=$(awk '$1 == "nodejs" { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: ${{ steps.node-version.outputs.node-version }}
- name: Select exact immutable artifacts from this run and attempt
id: artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/artifacts?per_page=100" > "$RUNNER_TEMP/artifacts.json"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏ No pagination: artifacts?per_page=100 without --paginate; reruns accumulate artifacts on the same run. Use gh api --paginate --slurp or filter with ?name=.

ids=$(node examples/container-publishing/verify_artifacts.mjs artifact-ids \
"$RUNNER_TEMP/artifacts.json" --run-id "$GITHUB_RUN_ID" --attempt "$GITHUB_RUN_ATTEMPT")
echo "ids=$ids" >> "$GITHUB_OUTPUT"
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
artifact-ids: ${{ steps.artifacts.outputs.ids }}
path: ${{ runner.temp }}/bundles
digest-mismatch: error
- name: Import accepted variants in a separate job without rebuilding
run: |
for arch in amd64 arm64; do
./scripts/test_axum_container_handoff.sh import \
"$RUNNER_TEMP/bundles/accepted-$arch-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" \
"$RUNNER_TEMP/import-$arch" "linux/$arch" "$GITHUB_SHA" "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
done
- name: Assemble and verify a localhost runtime index without external publication
run: |
source examples/container-publishing/tools.env
registry="axum-index-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
trap 'docker rm -f "$registry" >/dev/null 2>&1 || true' EXIT
docker run -d --name "$registry" -p 127.0.0.1::5000 "$REGISTRY_IMAGE"
port=$(docker port "$registry" 5000/tcp | awk -F: '{print $NF}')
for _ in $(seq 1 30); do curl --fail --silent "http://127.0.0.1:$port/v2/" && break; sleep 1; done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏ Registry wait never fails: if the registry never comes up the loop just ends and publish.sh fails later with a confusing error. test_axum_container_handoff.sh:65-69 already does this right — add a trailing curl --fail --silent "http://127.0.0.1:$port/v2/" >/dev/null.

./examples/container-publishing/publish.sh "127.0.0.1:$port/fixture" fixture \
"$RUNNER_TEMP/bundles/accepted-amd64-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" \
"$RUNNER_TEMP/bundles/accepted-arm64-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" \
"$RUNNER_TEMP/index" "$GITHUB_SHA" "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
36 changes: 33 additions & 3 deletions .github/workflows/deploy-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ name: Deploy actions
on:
pull_request:
paths:
- scripts/*axum_container*.sh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Over-broad triggers: these paths start the full deploy smoke matrix, but this workflow only ShellChecks the axum helpers. Consider moving that ShellCheck into axum-container.yml and dropping these paths here.

- scripts/axum_container*.mjs
- scripts/tests/*axum_container*.mjs
- examples/container-publishing/**
- examples/axum-deployment/**
- docs/guide/*axum-containers.md
# ANY workflow or action change must start the repository-wide pin gate (and
# the smokes) — including a brand-new action directory or an unrelated
# workflow like test.yml that could introduce a floating ref.
- .github/actions/**
- .github/workflows/**
- .github/zizmor.yml
Expand All @@ -23,6 +32,15 @@ on:
push:
branches: [main]
paths:
- scripts/*axum_container*.sh
- scripts/axum_container*.mjs
- scripts/tests/*axum_container*.mjs
- examples/container-publishing/**
- examples/axum-deployment/**
- docs/guide/*axum-containers.md
# ANY workflow or action change must start the repository-wide pin gate (and
# the smokes) — including a brand-new action directory or an unrelated
# workflow like test.yml that could introduce a floating ref.
- .github/actions/**
- .github/workflows/**
- .github/zizmor.yml
Expand Down Expand Up @@ -81,12 +99,15 @@ jobs:
- name: Actionlint
run: |
"$RUNNER_TEMP/tools/bin/actionlint" -shellcheck='shellcheck -S warning'
"$RUNNER_TEMP/tools/bin/actionlint" -shellcheck='shellcheck -S warning' examples/container-publishing/release.yml

- name: Third-party action pin gate
run: .github/actions/deploy-core/tests/check-action-pins.sh
run: |
.github/actions/deploy-core/tests/check-action-pins.sh
.github/actions/deploy-core/tests/check-action-pins.sh examples/container-publishing/release.yml

- name: Zizmor security scan
run: '"$RUNNER_TEMP/tools/bin/zizmor" --offline .github'
run: '"$RUNNER_TEMP/tools/bin/zizmor" --offline .github examples/container-publishing/release.yml'

- name: ShellCheck action scripts
run: |
Expand All @@ -95,7 +116,16 @@ jobs:
.github/actions/*/tests/*.sh \
.github/actions/deploy-core/tests/*.sh \
scripts/install-actionlint.sh \
scripts/install-yq.sh
scripts/install-yq.sh \
scripts/*axum_container*.sh \
examples/container-publishing/publish.sh

- name: Retrieve Node version
id: node-version
run: echo "node-version=$(awk '$1 == "nodejs" { print $2 }' .tool-versions)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: ${{ steps.node-version.outputs.node-version }}

- name: Bash contract tests
run: .github/actions/deploy-core/tests/run.sh
Expand Down
Loading
Loading