Skip to content
Merged
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
58 changes: 38 additions & 20 deletions .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:

permissions:
contents: read
actions: read

# A newer push to a pull request supersedes its older run.
concurrency:
Expand All @@ -22,11 +21,14 @@ jobs:
# normative x86-64 host; the arm host runs the host-dependent `rest` leg.
# Wall time is the slowest leg, not the sum.
#
# Every leg but `rest` is a formal obligation: it runs once per content
# identity κ of its inputs (scripts/ci-receipt.sh) and uploads a receipt when
# it passes. A later run with the same κ (a product-only change, a rerun, the
# merge of an up-to-date pull request) finds the receipt and does not repeat
# the work. `rest` checks the product and runs on every revision.
# Every leg is a factory obligation (factory/graph.json, scripts/factory.mjs):
# its identity is the SHA-256 of the inputs it declares, and it runs once per
# identity. A later run with the same identity (a product-only change for the
# formal legs, the merge of an up-to-date pull request for all of them) finds
# the receipt and does not repeat the work; a formal leg that failed on the
# same inputs is refuted in seconds instead of failing again an hour later
# (re-run the job to observe it anyway). Each leg uploads only its outcome;
# factory.yml turns outcomes into receipts from the default branch.
template-gate:
name: acceptance / ${{ matrix.leg }} / ${{ matrix.runner }}
strategy:
Expand All @@ -51,16 +53,31 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- name: Look up a receipt for this leg's inputs
id: receipt
if: matrix.leg != 'rest'
- name: Route this leg by its own inputs
id: route
shell: bash
env:
GH_TOKEN: ${{ github.token }}
OBLIGATION: ${{ matrix.leg }}-${{ matrix.runner }}
run: scripts/ci-receipt.sh lookup "$OBLIGATION" >> "$GITHUB_OUTPUT"
LEG_RECIPES: ${{ matrix.recipes }}
run: node scripts/factory.mjs route "$OBLIGATION" --expect-run "just $LEG_RECIPES" >> "$GITHUB_OUTPUT"
- name: Stop on refuted or blocked inputs
if: steps.route.outputs.route != 'observe' && steps.route.outputs.route != 'proved'
shell: bash
run: exit 1
- name: Pull the locked SDK, retrying the registry
if: steps.route.outputs.route == 'observe'
shell: bash
run: |
set -euo pipefail
image=$(sed -n 's/.*"sdk_image":"\([^"]*\)".*/\1/p' prismpm.lock)
for attempt in 1 2 3 4; do
if docker pull --quiet "$image"; then exit 0; fi
sleep $((attempt * 15))
done
exit 1
- name: Run this leg of the template gate through the locked SDK
if: steps.receipt.outputs.proved != 'true'
id: run
if: steps.route.outputs.route == 'observe'
shell: bash
env:
LEG_RECIPES: ${{ matrix.recipes }}
Expand Down Expand Up @@ -103,20 +120,21 @@ jobs:
devcontainer --version
exec just $LEG_RECIPES
'
- name: Record the receipt for this leg's inputs
if: steps.receipt.outputs.proved == 'false'
- name: Record this leg's outcome
if: always() && steps.route.outputs.route == 'observe' && (steps.run.outcome == 'success' || steps.run.outcome == 'failure')
shell: bash
env:
OBLIGATION: ${{ matrix.leg }}-${{ matrix.runner }}
KAPPA: ${{ steps.receipt.outputs.kappa }}
run: scripts/ci-receipt.sh record "$OBLIGATION" "$KAPPA"
IDENTITY: ${{ steps.route.outputs.identity }}
OUTCOME: ${{ steps.run.outcome }}
run: node scripts/factory.mjs outcome "$OBLIGATION" "$IDENTITY" "$OUTCOME" .tmp/factory
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
if: steps.receipt.outputs.proved == 'false'
if: always() && steps.route.outputs.route == 'observe' && (steps.run.outcome == 'success' || steps.run.outcome == 'failure')
with:
name: receipt-${{ matrix.leg }}-${{ matrix.runner }}-${{ steps.receipt.outputs.kappa }}
path: .tmp/receipt/receipt.json
name: factory-outcome-${{ matrix.leg }}-${{ matrix.runner }}
path: .tmp/factory/
if-no-files-found: error
retention-days: 90
retention-days: 3

# The single required signal per host: it passes only when every leg passed.
acceptance:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/factory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Records receipts. After a bootstrap, offline or release run from this
# repository completes, this turns the outcomes its jobs uploaded into receipts
# on the factory-receipts branch (scripts/factory.mjs publish). It runs from the
# default branch with its own token, so no pull-request code ever gets write
# access, and an outcome from a fork is never recorded. Runs that finish
# together each rebuild on the branch's newest head and retry the push.
name: factory

on:
workflow_run:
workflows: [bootstrap, SDK offline reproducibility, release]
types: [completed]

permissions:
contents: read

jobs:
receipts:
name: record receipts
if: github.event.workflow_run.head_repository.full_name == github.repository
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
actions: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093
with:
pattern: factory-outcome-*
path: .tmp/outcomes
merge-multiple: true
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Publish the run's receipts and reweigh the schedule
env:
GH_TOKEN: ${{ github.token }}
FACTORY_RUN_ID: ${{ github.event.workflow_run.id }}
FACTORY_RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
run: node scripts/factory.mjs publish .tmp/outcomes
41 changes: 19 additions & 22 deletions .github/workflows/offline-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,36 @@ on:

permissions:
contents: read
actions: read

# A newer push to a pull request supersedes its older run.
concurrency:
group: offline-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
# The whole workflow is one formal obligation: it runs once per content
# identity κ of its inputs (scripts/ci-receipt.sh). When an earlier run with
# the same κ passed, every job below is skipped.
# The whole workflow is one factory obligation, `offline` (factory/graph.json):
# it runs once per identity of its declared inputs. When an earlier run with
# the same identity passed, every job below is skipped.
route:
name: offline formal construction / receipt
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
proved: ${{ steps.receipt.outputs.proved }}
kappa: ${{ steps.receipt.outputs.kappa }}
route: ${{ steps.route.outputs.route }}
identity: ${{ steps.route.outputs.identity }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
persist-credentials: false
- name: Look up a receipt for this workflow's inputs
id: receipt
- name: Route this workflow by its own inputs
id: route
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: scripts/ci-receipt.sh lookup offline >> "$GITHUB_OUTPUT"
run: node scripts/factory.mjs route offline >> "$GITHUB_OUTPUT"
regenerate:
name: review-only generated projections
needs: route
if: needs.route.outputs.proved != 'true'
if: needs.route.outputs.route == 'observe'
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
Expand All @@ -60,7 +57,7 @@ jobs:
set -euo pipefail
image=$(node -p 'JSON.parse(require("fs").readFileSync("prismpm.lock")).sdk_image')
[[ "$image" =~ ^[a-z0-9.-]+(:[0-9]{1,5})?/[a-z0-9./_-]+@sha256:[0-9a-f]{64}$ ]]
docker pull "$image"
for attempt in 1 2 3 4; do docker pull "$image" && break; test "$attempt" -lt 4; sleep $((attempt * 15)); done
docker run --rm --user "$(id -u):$(id -g)" \
--volume "$PWD:$PWD" --workdir "$PWD" \
--env PRISMPM_EPHEMERAL_HOME=1 \
Expand All @@ -75,7 +72,7 @@ jobs:
offline-setup:
name: offline formal construction / dependency setup
needs: route
if: needs.route.outputs.proved != 'true'
if: needs.route.outputs.route == 'observe'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
Expand All @@ -95,7 +92,7 @@ jobs:
set -euo pipefail
image=$(node -p 'JSON.parse(require("fs").readFileSync("prismpm.lock")).sdk_image')
[[ "$image" =~ ^[a-z0-9.-]+(:[0-9]{1,5})?/[a-z0-9./_-]+@sha256:[0-9a-f]{64}$ ]]
docker pull "$image"
for attempt in 1 2 3 4; do docker pull "$image" && break; test "$attempt" -lt 4; sleep $((attempt * 15)); done
docker run --rm --user "$(id -u):$(id -g)" \
--group-add "$(stat -c '%g' /var/run/docker.sock)" \
--volume "$PWD:$PWD" --workdir "$PWD" \
Expand Down Expand Up @@ -146,7 +143,7 @@ jobs:
mkdir -p .tmp && tar -C .tmp -xf .prism/offline-setup/offline-acquisition.tar && rm -rf .prism/offline-setup
image=$(node -p 'JSON.parse(require("fs").readFileSync("prismpm.lock")).sdk_image')
[[ "$image" =~ ^[a-z0-9.-]+(:[0-9]{1,5})?/[a-z0-9./_-]+@sha256:[0-9a-f]{64}$ ]]
docker pull "$image"
for attempt in 1 2 3 4; do docker pull "$image" && break; test "$attempt" -lt 4; sleep $((attempt * 15)); done
# Only orchestration sees the daemon. The verifier containers have
# no socket, credentials, parent checkout mount, or network interface.
docker run --rm --user "$(id -u):$(id -g)" \
Expand Down Expand Up @@ -188,14 +185,14 @@ jobs:
name: offline-comparison
path: .prism/uorc/offline-comparison.json
if-no-files-found: error
- name: Record the receipt for this workflow's inputs
- name: Record this workflow's outcome
shell: bash
env:
KAPPA: ${{ needs.route.outputs.kappa }}
run: scripts/ci-receipt.sh record offline "$KAPPA"
IDENTITY: ${{ needs.route.outputs.identity }}
run: node scripts/factory.mjs outcome offline "$IDENTITY" success .tmp/factory
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: receipt-offline-${{ needs.route.outputs.kappa }}
path: .tmp/receipt/receipt.json
name: factory-outcome-offline
path: .tmp/factory/
if-no-files-found: error
retention-days: 90
retention-days: 3
Loading
Loading