diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 156a4bc..f8c1bfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,7 @@ permissions: id-token: write # Every job here runs on GitHub-hosted runners: this repository is public and -# its workflows must never reach a self-hosted fleet (NR-G). The plan and run -# lanes for infra/* arrive with NR1. +# its workflows must never reach a self-hosted fleet (NR-G). jobs: # THE WORK TREE, BEFORE THE MERGE: a malformed epic.yaml, a listed task with # no contract or a stray contract in the NR prefix fails the pull request. @@ -32,6 +31,71 @@ jobs: version: v2.69.0 - run: orun work check --base "origin/${{ github.base_ref }}" + plan: + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + job-matrix: ${{ steps.matrix.outputs.job-matrix }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: sourceplane/orun-action@v1.2.0 + with: + version: v2.69.0 + - run: | + set -euo pipefail + orun plan \ + --from-ci github \ + --event-file "$GITHUB_EVENT_PATH" \ + --intent intent.yaml \ + --output plan.json \ + --changed + - id: matrix + run: | + echo "job-matrix=$(jq -c '[.jobs[] | {"job-id": .id, "job-name": .checkName}]' plan.json)" >> "$GITHUB_OUTPUT" + - uses: actions/upload-artifact@v4 + with: + name: orun-plan + path: plan.json + + # One lane per plan job. Remote state is on for pull requests too: the + # terraform-aws composition keeps Terraform state on the platform (the runner + # exports TF_HTTP_* only under --remote-state), and the plan-only profile + # never applies. AWS credentials come from the aws-admin-owned role over OIDC. + run: + needs: plan + if: ${{ needs.plan.outputs.job-matrix != '[]' && needs.plan.outputs.job-matrix != '' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.plan.outputs.job-matrix) }} + name: ${{ matrix.job-name }} + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: orun-plan + - uses: sourceplane/orun-action@v1.2.0 + with: + version: v2.69.0 + - run: | + set -euo pipefail + retry_flag="" + if [ "${GITHUB_RUN_ATTEMPT:-1}" -gt 1 ]; then retry_flag="--retry"; fi + orun run \ + --plan plan.json \ + --runner github-actions \ + --remote-state \ + --job "${{ matrix.job-id }}" \ + --exec-id "${{ github.run_id }}" \ + $retry_flag + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # THE WORK TREE, AFTER THE MERGE: Orunbase is reconciled from work/ under CI's # OIDC identity. Idempotent by repo, path and commit; never deletes. work-sync: diff --git a/infra/.gitkeep b/infra/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/intent.yaml b/intent.yaml index 9ea357d..2ea12fe 100644 --- a/intent.yaml +++ b/intent.yaml @@ -21,8 +21,21 @@ work: tasks: work/tasks sync: on-merge -# Compositions arrive with NR1 (stack-granite terraform-aws, pinned by OCI -# digest). Until then the repo carries only its work tree. +# The compositions are stack-granite's, consumed as a published OCI artifact +# and pinned by version: a bare reference resolves to :latest, which would let +# a catalog release change this repo's execution contracts without a commit +# here. terraform-aws brings OIDC-assumed AWS credentials and Orun-held state. +compositions: + sources: + - name: stack-granite + kind: oci + ref: oci://ghcr.io/sourceplane/stack-granite:0.1.0 + resolution: + precedence: + - stack-granite + bindings: + terraform-aws: stack-granite + discovery: roots: - infra/ @@ -61,5 +74,7 @@ environments: namespacePrefix: nimbus- owner: sourceplane repo: nimbus-runners + # Owned by sourceplane/aws-admin (github-repo-sourceplane-nimbus-runners). + awsRoleArn: arn:aws:iam::306024784101:role/github-sourceplane-nimbus-runners env: AWS_REGION: us-east-1 diff --git a/work/epics/nimbus-runners-baseline/IMPLEMENTATION-STATUS.md b/work/epics/nimbus-runners-baseline/IMPLEMENTATION-STATUS.md index a850550..4a6b1c4 100644 --- a/work/epics/nimbus-runners-baseline/IMPLEMENTATION-STATUS.md +++ b/work/epics/nimbus-runners-baseline/IMPLEMENTATION-STATUS.md @@ -4,8 +4,8 @@ As-built ≠ intent. This file records what actually shipped, and every place th | Milestone | State | PR | |---|---|---| -| NR0 — the spec | in review | | -| NR1 — foundations | | | +| NR0 — the spec | ✅ merged, synced | [#1](https://github.com/sourceplane/nimbus-runners/pull/1), [#2](https://github.com/sourceplane/nimbus-runners/pull/2) | +| NR1 — foundations | in progress | NR-2; [stack-granite#1](https://github.com/sourceplane/stack-granite/pull/1) + tag v0.1.0; [aws-admin#35](https://github.com/sourceplane/aws-admin/pull/35) | | NR2 — the fleet | | | | NR3 — the image | | | | NR4 — orun-cloud on the fleet | | | @@ -22,4 +22,11 @@ As-built ≠ intent. This file records what actually shipped, and every place th ## Departures from the design -None yet. +### One role, not a plan/deploy pair (NR1) + +The design named a plan role for pull requests and main, and a deploy role for `prod`. stack-granite's `terraform-aws` takes one `awsRoleArn` per environment, and orun has no per-trigger parameter override. So the PR plan lane and the main apply lane assume one role, `github-sourceplane-nimbus-runners`, trusted for `pull_request` and `ref:refs/heads/main`. + +What limits it: +- Fork pull requests never receive an OIDC token. +- Every role the fleet creates must carry `nimbus-runners-boundary`, which the role cannot loosen. +- IAM, Lambda, SQS, SSM, S3, logs, events and budgets are scoped to `nimbus-runners*`. diff --git a/work/epics/nimbus-runners-baseline/epic.yaml b/work/epics/nimbus-runners-baseline/epic.yaml index 7c4d46a..f8729d3 100644 --- a/work/epics/nimbus-runners-baseline/epic.yaml +++ b/work/epics/nimbus-runners-baseline/epic.yaml @@ -16,8 +16,8 @@ spec: - name: "NR1 — foundations" exitCriteria: - "stack-granite 0.1.0 resolves from ghcr.io and orun plan loads its terraform-aws composition here" - - "a PR lane assumes the aws-admin-owned nimbus-runners plan role over GitHub OIDC" - tasks: [] + - "a PR lane assumes the aws-admin-owned nimbus-runners role over GitHub OIDC" + tasks: [NR-2] - name: "NR2 — the fleet" exitCriteria: - "a workflow on runs-on [self-hosted, linux, x64, nimbus] boots a spot instance, passes, and the instance is terminated" diff --git a/work/tasks/NR-2.TaskContract.yaml b/work/tasks/NR-2.TaskContract.yaml new file mode 100644 index 0000000..5ba18d0 --- /dev/null +++ b/work/tasks/NR-2.TaskContract.yaml @@ -0,0 +1,18 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: NR-2 + title: "Foundations: stack-granite pinned, plan and run lanes" +spec: + goal: "This repository plans through stack-granite 0.1.0's terraform-aws composition with the aws-admin-owned OIDC role, and CI runs one lane per plan job." + affects: + - "intent.yaml" + - ".github/workflows/**" + - "work/**" + - "infra/.gitkeep" + doneWhen: + - "stack-granite 0.1.0 is published to ghcr.io and anonymously pullable (sourceplane/stack-granite#1, tag v0.1.0)" + - "the github-sourceplane-nimbus-runners role and nimbus-runners-boundary exist (sourceplane/aws-admin#35)" + - "orun plan --env prod resolves the OCI stack and binds terraform-aws" + - "CI carries plan and run jobs with remote state and GitHub-hosted runners only" + gates: []