diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 61441a8..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Docs - -on: - pull_request: - paths: - - "README.md" - - "docs/**" - - "blueprints/**" - - "compositions/**" - - "scripts/generate-readme.sh" - push: - branches: - - main - paths: - - "README.md" - - "docs/**" - - "blueprints/**" - - "compositions/**" - - "scripts/generate-readme.sh" - -permissions: - contents: read - -jobs: - docs-check: - name: Check generated catalog docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Make helper scripts executable - run: chmod +x scripts/*.sh - - - name: Check composition docs - run: ./scripts/generate-readme.sh --check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6947ab0..747a8cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,12 +43,6 @@ jobs: - name: Verify catalog run: ./scripts/verify.sh - - name: Publish OCI package - run: | - orun publish ghcr.io/sourceplane/stack-tectonic:${STACK_VERSION} \ - --root . \ - --version "${STACK_VERSION}" - - name: Create GitHub release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -62,8 +56,20 @@ jobs: --title "${GITHUB_REF_NAME}" \ --generate-notes - - name: Upload registry index - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload "${GITHUB_REF_NAME}" registry/index.json --clobber - + # Runs after the release so the tag and release notes are the record of + # record before the immutable artifact is pushed. The target is passed + # explicitly: with no ref, orun infers ghcr.io/// + # from the git remote, which is the wrong repository path. + - name: Publish OCI package + run: | + orun publish "ghcr.io/sourceplane/stack-tectonic:${STACK_VERSION}" \ + --root . \ + --version "${STACK_VERSION}" + + - name: Confirm package is pullable + run: | + orun fetch "ghcr.io/sourceplane/stack-tectonic:${STACK_VERSION}" \ + --output "${RUNNER_TEMP}/published" --overwrite + test -f "${RUNNER_TEMP}/published/stack.yaml" + echo "published $(ls "${RUNNER_TEMP}/published/compositions" | wc -l) composition(s)" + diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml deleted file mode 100644 index 39aeef0..0000000 --- a/.github/workflows/scorecard.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Scorecard - -on: - pull_request: - paths: - - "compositions/**" - - "blueprints/**" - - "registry/**" - - "scripts/score.sh" - - ".github/workflows/scorecard.yml" - push: - branches: - - main - paths: - - "compositions/**" - - "blueprints/**" - - "registry/**" - - "scripts/score.sh" - - ".github/workflows/scorecard.yml" - -permissions: - contents: read - -jobs: - scorecard: - name: Check generated scorecard - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Make helper scripts executable - run: chmod +x scripts/*.sh - - - name: Check registry index - run: ./scripts/score.sh --check diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 32d19c5..37fc681 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -11,36 +11,8 @@ permissions: packages: read jobs: - composition-fixtures: - name: Composition fixture (${{ matrix.composition }}) - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - composition: - - cloudflare-pages - - cloudflare-pages-turbo - - cloudflare-pages-terraform - - cloudflare-pages-turbo-terraform - - cloudflare-worker - - cloudflare-worker-turbo - - terraform - - helm-chart - - helm-values - - turbo-package - - workspace - steps: - - uses: actions/checkout@v4 - - - name: Make helper scripts executable - run: chmod +x scripts/*.sh - - - name: Verify composition fixtures - run: ./scripts/verify-composition.sh "${{ matrix.composition }}" - verify-stack: name: Verify stack catalog - needs: composition-fixtures runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -60,5 +32,8 @@ jobs: - name: Make helper scripts executable run: chmod +x scripts/*.sh + # Structurally validates every composition contract, resolves the publish + # target, then packs the shipped layers and resolves them back through a + # throwaway consumer intent — the same path a consuming repo runs. - name: Verify catalog run: ./scripts/verify.sh diff --git a/.gitignore b/.gitignore index 24f60df..7de69c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .workspace/ .DS_Store +error.log diff --git a/README.md b/README.md index 36e0c23..339e9c5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Stack Tectonic -Versioned OCI catalog for reusable Orun compositions, blueprints, examples, and release metadata. +Versioned OCI catalog of reusable Orun compositions, starter examples, and release metadata. This repository is the source of truth for the stack published to: @@ -15,7 +15,7 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.12.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 ``` Pin the catalog in `intent.yaml`, then run it with Orun. The full consumer setup is in [docs/using-this-stack-from-oci.md](docs/using-this-stack-from-oci.md), and the default GitHub Actions workflow template is documented in [docs/remote-state-matrix-ci.md](docs/remote-state-matrix-ci.md). @@ -27,46 +27,76 @@ stack-tectonic/ ├── stack.yaml ├── README.md ├── docs/ -├── blueprints/ ├── compositions/ ├── examples/ ├── scripts/ -├── registry/ └── .github/workflows/ ``` +`orun publish` ships the layers a consumer actually resolves: `stack.yaml`, `compositions/`, and `examples/`. + +## Composition layout + +Every composition lives under `compositions//` and is decomposed into four kinds of file: + +```text +compositions// +├── composition.yaml # kind: Composition — schemaRef, defaultJob, defaultProfile, jobs[], profiles[] +├── schema.yaml # kind: ComponentSchema — JSON Schema (draft-07) for component parameters +├── jobs/.yaml # kind: JobTemplate — declares capabilities[] and the steps[] that implement them +└── profiles/

.yaml # kind: ExecutionProfile — selects a subset of a job's capabilities +``` + +Each step in a job template is tagged with a `capability`, and a profile lists the capabilities it +includes. That is how a plan-only lane and a release lane share one job template instead of +duplicating steps. Components pick a profile per environment: + +```yaml +spec: + type: cloudflare-pages + subscribe: + environments: + - name: staging + profile: verify + - name: production + profile: deploy +``` + ## Compositions -| Composition | Category | Purpose | -| --- | --- | --- | -| `cloudflare-pages` | hosting | Direct-upload Cloudflare Pages delivery | -| `cloudflare-pages-turbo` | hosting | Pages delivery from pnpm and Turbo monorepos | -| `cloudflare-pages-terraform` | platform | Terraform-managed Cloudflare Pages projects | -| `cloudflare-pages-turbo-terraform` | platform | Monorepo Pages delivery plus Terraform reconciliation | -| `cloudflare-worker` | edge | Cloudflare Worker validation and deploy jobs | -| `cloudflare-worker-turbo` | edge | Worker delivery from pnpm and Turbo monorepos | -| `terraform` | infrastructure | Terraform fmt, init, and validate jobs | -| `helm-chart` | kubernetes | Helm chart verification | -| `helm-values` | kubernetes | Helm values validation | -| `turbo-package` | developer-experience | Shared package verification in Turbo workspaces | -| `workspace` | developer-experience | Workspace-backed provider smoke jobs | - -Every composition now lives under `compositions//` so docs, examples, tests, and future registry metadata can grow beside the contract instead of around a flat root. - -## Blueprints - -| Blueprint | Uses | Focus | -| --- | --- | --- | -| `nextjs-cloudflare` | `workspace`, `turbo-package`, `cloudflare-pages-turbo`, `cloudflare-pages-terraform` | Edge-hosted Next.js monorepos with Terraform-managed Pages | -| `edge-worker-platform` | `workspace`, `terraform`, `cloudflare-worker`, `helm-values` | Worker-first delivery with infra and environment overlays | +| Composition | Category | Profiles (default first) | Purpose | +| --- | --- | --- | --- | +| `cloudflare-domain` | dns | `apply`, `plan-only` | Cloudflare zones plus Pages/Worker custom domain attachments, managed with Terraform | +| `cloudflare-pages` | hosting | `verify`, `pull-request`, `deploy` | Cloudflare Pages build, verify, and direct-upload deploy pipeline | +| `cloudflare-pages-turbo` | hosting | `verify`, `pull-request`, `deploy` | Cloudflare Pages deployment built from a pnpm and Turbo monorepo | +| `cloudflare-pages-terraform` | platform | `verify`, `pull-request`, `release` | Cloudflare Pages deployment managed with Terraform | +| `cloudflare-pages-turbo-terraform` | platform | `verify`, `pull-request`, `release` | Turbo monorepo Pages build reconciled with Terraform | +| `cloudflare-worker` | edge | `verify`, `pull-request`, `deploy` | Cloudflare Worker build, verify, and deploy pipeline | +| `cloudflare-worker-turbo` | edge | `verify`, `pull-request`, `deploy` | Cloudflare Worker delivery from a Turborepo build | +| `cloudflare-workers-assets-turbo` | edge | `verify`, `pull-request`, `deploy` | Worker + Static Assets single-bundle delivery for apps that emit a Worker entrypoint plus an `ASSETS` directory | +| `terraform` | infrastructure | `apply`, `plan-only`, `local` | Terraform validation and planning for multi-tenant SaaS infrastructure components | +| `db-migrate` | data | `apply`, `plan` | Database migration runner — plan on pull requests, apply on merge | +| `publish-stack` | release | `dry-run`, `verify`, `release` | Publish an Orun stack to an OCI registry with dry-run validation | +| `turbo-package` | developer-experience | `verify`, `quick-check` | Shared package verification in a pnpm and Turbo workspace | + +Most compositions carry their own `README.md` with parameter and profile detail beside the contract. ## Trust signals -- `scripts/verify-composition.sh` enforces that every exported composition keeps real examples and smoke fixtures beside its contract. -- `scripts/verify.sh` validates generated docs and scores, checks every composition fixture, and runs the stack OCI dry-run publish path. -- `scripts/score.sh` generates `registry/index.json` with maturity scores and grades. -- Composition fixtures are excerpted or adapted from `example-platform-repo` so the catalog documents real repo shapes instead of synthetic placeholders. -- GitHub workflows split per-composition fixture checks, full catalog verification, docs checks, scorecard generation, and releases into separate pipelines. +- `scripts/verify.sh` is the single catalog gate. It structurally validates every + `compositions/*/composition.yaml` (`metadata.name` and `spec.type` must equal the directory name, + and `schema.yaml` plus `jobs/` must exist), resolves the publish target with + `orun publish --dry-run`, then stages and packs the shipped layers and resolves the packed + artifact back through a throwaway consumer intent using `kind: archive`, asserting every + composition exports. +- Packing and re-resolving is the part that carries weight: `orun publish --dry-run` only resolves + the manifest and target, so on its own it is no evidence the package is loadable by a consumer. +- `.github/workflows/verify.yml` runs that script on every pull request and every push to `main`. +- `.github/workflows/release.yml` runs the same script before publishing a tag. +- Where a composition ships a smoke fixture under `compositions//tests/`, it is excerpted or + adapted from a real consumer repository so the contract is documented with a real repo shape + instead of a synthetic placeholder. Five of the twelve have one today; see + [docs/roadmap.md](docs/roadmap.md). ## Docs @@ -81,9 +111,12 @@ Every composition now lives under `compositions//` so docs, examples, test ## Release flow -1. Update `stack.yaml`. +1. Update `metadata.version` in `stack.yaml`. 2. Run `./scripts/verify.sh`. 3. Merge to `main`. -4. Push a matching tag like `v0.12.0`. +4. Push a matching tag like `v0.13.0`. -The release workflow publishes the OCI package, creates the GitHub release, and uploads the generated registry index. +The release workflow asserts the tag matches `stack.yaml`, reruns `./scripts/verify.sh`, creates the +GitHub release, then publishes the OCI package and confirms it is pullable with `orun fetch`. The +package is pushed after the release is created so the tag and release notes are the record of record +before the immutable artifact exists. diff --git a/blueprints/edge-worker-platform/README.md b/blueprints/edge-worker-platform/README.md deleted file mode 100644 index 5f46f23..0000000 --- a/blueprints/edge-worker-platform/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# edge-worker-platform - -Blueprint for worker-first services that still need shared infra validation and deploy-time overlays. - -## Uses - -- `workspace` -- `terraform` -- `cloudflare-worker` -- `helm-values` - -## Good fit for - -- API and edge routing services -- teams standardizing on Cloudflare Workers -- repos that keep infra and delivery config colocated diff --git a/blueprints/edge-worker-platform/blueprint.yaml b/blueprints/edge-worker-platform/blueprint.yaml deleted file mode 100644 index c30c1ac..0000000 --- a/blueprints/edge-worker-platform/blueprint.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: catalog.orun.dev/v1alpha1 -kind: Blueprint -metadata: - name: edge-worker-platform -spec: - summary: Edge-worker delivery with workspace verification, Terraform foundations, and deploy overlays. - uses: - - workspace - - terraform - - cloudflare-worker - - helm-values - outcomes: - - Worker validation and deployment - - Infra validation - - Environment configuration overlays diff --git a/blueprints/edge-worker-platform/examples/README.md b/blueprints/edge-worker-platform/examples/README.md deleted file mode 100644 index 4f4be71..0000000 --- a/blueprints/edge-worker-platform/examples/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# edge-worker-platform examples - -Use the starter intent in `examples/monorepo-platform/` as the consumer-side starting point for this blueprint. diff --git a/blueprints/nextjs-cloudflare/README.md b/blueprints/nextjs-cloudflare/README.md deleted file mode 100644 index d3a482c..0000000 --- a/blueprints/nextjs-cloudflare/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# nextjs-cloudflare - -Opinionated blueprint for teams running a pnpm and Turbo monorepo with Cloudflare Pages managed through Terraform. - -## Uses - -- `workspace` -- `turbo-package` -- `cloudflare-pages-turbo` -- `cloudflare-pages-terraform` - -## Good fit for - -- frontend-heavy platform repos -- monorepo standardization -- teams that want Pages infrastructure managed declaratively diff --git a/blueprints/nextjs-cloudflare/blueprint.yaml b/blueprints/nextjs-cloudflare/blueprint.yaml deleted file mode 100644 index 8d4aab9..0000000 --- a/blueprints/nextjs-cloudflare/blueprint.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: catalog.orun.dev/v1alpha1 -kind: Blueprint -metadata: - name: nextjs-cloudflare -spec: - summary: Next.js monorepo delivery on Cloudflare with Terraform-managed Pages resources. - uses: - - workspace - - turbo-package - - cloudflare-pages-turbo - - cloudflare-pages-terraform - outcomes: - - Shared workspace validation - - Monorepo package verification - - Git-backed Pages provisioning - - Edge-hosted frontend delivery diff --git a/blueprints/nextjs-cloudflare/examples/README.md b/blueprints/nextjs-cloudflare/examples/README.md deleted file mode 100644 index 08f1b5f..0000000 --- a/blueprints/nextjs-cloudflare/examples/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# nextjs-cloudflare examples - -Use the starter intent in `examples/simple-nextjs/` as the consumer-side entry point for this blueprint. diff --git a/compositions/cloudflare-domain/README.md b/compositions/cloudflare-domain/README.md new file mode 100644 index 0000000..8b9a5b3 --- /dev/null +++ b/compositions/cloudflare-domain/README.md @@ -0,0 +1,60 @@ +# cloudflare-domain composition + +Manages Cloudflare DNS zones and custom domain attachments for Pages and Worker +projects via Terraform. + +## Component Type + +`cloudflare-domain` + +## Parameters + +`schema.yaml` is the authoritative contract for this table. + +| Parameter | Required | Description | +|-----------|----------|-------------| +| `stackName` | yes | Terraform stack identifier | +| `terraformDir` | yes | Path to Terraform root relative to component | +| `terraformVersion` | yes | Terraform CLI version | +| `baseDomain` | yes | The root domain managed by this component (e.g. `example.com`) | +| `zoneMode` | yes | `existing` adopts a zone already present in Cloudflare (no zone creation); `managed` creates and manages the zone lifecycle via Terraform | +| `pagesProjectPrefix` | yes | Pages project name prefix. The full project name is derived as `{pagesProjectPrefix}-{environment}` at plan time | +| `awsAccountId` | no | AWS account ID hosting the GitHub-OIDC role this component assumes | +| `awsRegion` | no | AWS region for state backend | +| `orgName` | no | Organization name for state bucket | +| `owner` | no | GitHub repository owner | +| `repo` | no | GitHub repository name | +| `namespace` | no | Logical namespace | +| `namespacePrefix` | no | Environment-scoped prefix | + +## Zone Modes + +### `existing` (adopt) + +Use when the domain is already added to a Cloudflare account. The Terraform +module uses `data.cloudflare_zone` to look up the zone by name. No zone +creation or deletion occurs. + +### `managed` (create) + +Use when the domain has not been added to Cloudflare. The Terraform module +creates a `cloudflare_zone` resource and manages its full lifecycle. Delegation +(NS records at the registrar) must be completed manually after the first apply. + +## Profiles + +Defined in `composition.yaml` against the single job `cloudflare-domain` +(`jobs/cloudflare-domain-validate.yaml`). `apply` is the `defaultProfile`. + +- **plan-only**: setup → aws-credentials → env → context → fmt → init → + workspace → validate → plan. Used for PR validation. +- **apply**: the same steps plus `terraform apply`. Used on main-branch pushes. + +## Outputs + +Non-secret outputs reported by the Terraform module: + +- `zone_id` — Cloudflare zone identifier +- `zone_name` — Domain name of the zone +- `zone_status` — Zone activation status +- `pages_custom_domains` — Map of attached Pages custom domain hostnames and statuses diff --git a/compositions/cloudflare-domain/composition.yaml b/compositions/cloudflare-domain/composition.yaml new file mode 100644 index 0000000..f9998ca --- /dev/null +++ b/compositions/cloudflare-domain/composition.yaml @@ -0,0 +1,26 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-domain +spec: + type: cloudflare-domain + description: Manages Cloudflare zones and Pages/Worker custom domain attachments via Terraform + + schemaRef: + name: cloudflare-domain-component + + defaultJob: cloudflare-domain + defaultProfile: apply + + jobs: + - name: cloudflare-domain + templateRef: + name: cloudflare-domain-validate + + profiles: + - name: plan-only + profileRef: + name: cloudflare-domain-plan-only + - name: apply + profileRef: + name: cloudflare-domain-apply diff --git a/compositions/cloudflare-domain/jobs/cloudflare-domain-validate.yaml b/compositions/cloudflare-domain/jobs/cloudflare-domain-validate.yaml new file mode 100644 index 0000000..c8eea84 --- /dev/null +++ b/compositions/cloudflare-domain/jobs/cloudflare-domain-validate.yaml @@ -0,0 +1,125 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-domain-validate +spec: + description: Terraform fmt, init, validate, plan, and apply for Cloudflare domain management + runsOn: ubuntu-22.04 + timeout: 20m + retries: 0 + + labels: + scope: infra + + capabilities: + - cloudflare-domain.setup + - cloudflare-domain.aws-credentials + - cloudflare-domain.env + - cloudflare-domain.context + - cloudflare-domain.fmt + - cloudflare-domain.init + - cloudflare-domain.workspace + - cloudflare-domain.validate + - cloudflare-domain.plan + - cloudflare-domain.apply + + steps: + - id: setup-terraform + name: setup-terraform + capability: cloudflare-domain.setup + use: hashicorp/setup-terraform@v4 + with: + terraform_version: "{{.parameters.terraformVersion}}" + terraform_wrapper: "false" + + - id: aws-credentials + name: Configure AWS Credentials + capability: cloudflare-domain.aws-credentials + use: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan" + aws-region: "{{.parameters.awsRegion}}" + audience: sts.amazonaws.com + onFailure: stop + + - id: terraform-env + name: Export Terraform Env + capability: cloudflare-domain.env + shell: bash + run: | + { + {{- range $key, $value := .env }} + printf '%s=%s\n' '{{ $key }}' '{{ $value }}' + {{- end }} + + {{- range $key, $value := .parameters }} + printf 'TF_VAR_{{ $key }}=%s\n' '{{ $value }}' + {{- end }} + + printf 'TF_VAR_environment=%s\n' "{{ .orun.environment.name }}" + printf 'TF_VAR_component=%s\n' "{{ .orun.component.name }}" + } >> "$ORUN_ENV" + onFailure: stop + + - id: terraform-context + name: Terraform Context + capability: cloudflare-domain.context + shell: bash + run: | + terraform version + echo "Component: {{ .orun.component.name }}" + echo "Environment: {{ .orun.environment.name }}" + echo "Terraform directory: {{ .parameters.terraformDir }}" + echo "Base domain: {{ .parameters.baseDomain }}" + echo "Zone mode: {{ .parameters.zoneMode }}" + onFailure: stop + + - id: terraform-fmt-check + name: fmt Check + capability: cloudflare-domain.fmt + run: "terraform -chdir={{ .parameters.terraformDir }} fmt -check" + onFailure: stop + + - id: terraform-init + name: Init + capability: cloudflare-domain.init + shell: bash + run: | + set -euo pipefail + + terraform -chdir={{ .parameters.terraformDir }} init \ + -input=false \ + -reconfigure \ + -backend-config="bucket={{.parameters.orgName}}-{{.orun.environment.name}}" \ + -backend-config="key={{.parameters.repo}}/{{.orun.component.name}}/terraform.tfstate" \ + -backend-config="region=${AWS_REGION:-{{.parameters.awsRegion}}}" + onFailure: stop + + - id: terraform-workspace + name: Workspace + capability: cloudflare-domain.workspace + shell: bash + run: | + set -euo pipefail + + terraform -chdir={{ .parameters.terraformDir }} workspace select -or-create {{ .orun.environment.name }} + echo "TF_WORKSPACE={{ .orun.environment.name }}" >> "$ORUN_ENV" + onFailure: stop + + - id: terraform-validate + name: Validate + capability: cloudflare-domain.validate + run: "terraform -chdir={{ .parameters.terraformDir }} validate -no-color" + onFailure: stop + + - id: terraform-plan + name: Plan + capability: cloudflare-domain.plan + run: "terraform -chdir={{ .parameters.terraformDir }} plan -no-color" + onFailure: stop + + - id: terraform-apply + name: Apply + capability: cloudflare-domain.apply + run: "terraform -chdir={{ .parameters.terraformDir }} apply -no-color -auto-approve" + onFailure: stop diff --git a/compositions/cloudflare-domain/profiles/cloudflare-domain-apply.yaml b/compositions/cloudflare-domain/profiles/cloudflare-domain-apply.yaml new file mode 100644 index 0000000..47a836c --- /dev/null +++ b/compositions/cloudflare-domain/profiles/cloudflare-domain-apply.yaml @@ -0,0 +1,20 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-domain-apply +spec: + description: Full Terraform plan and apply for Cloudflare domain management + + jobs: + cloudflare-domain: + includeCapabilities: + - cloudflare-domain.setup + - cloudflare-domain.aws-credentials + - cloudflare-domain.env + - cloudflare-domain.context + - cloudflare-domain.fmt + - cloudflare-domain.init + - cloudflare-domain.workspace + - cloudflare-domain.validate + - cloudflare-domain.plan + - cloudflare-domain.apply diff --git a/compositions/cloudflare-domain/profiles/cloudflare-domain-plan-only.yaml b/compositions/cloudflare-domain/profiles/cloudflare-domain-plan-only.yaml new file mode 100644 index 0000000..9f89223 --- /dev/null +++ b/compositions/cloudflare-domain/profiles/cloudflare-domain-plan-only.yaml @@ -0,0 +1,19 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-domain-plan-only +spec: + description: PR Terraform plan with no apply for Cloudflare domain management + + jobs: + cloudflare-domain: + includeCapabilities: + - cloudflare-domain.setup + - cloudflare-domain.aws-credentials + - cloudflare-domain.env + - cloudflare-domain.context + - cloudflare-domain.fmt + - cloudflare-domain.init + - cloudflare-domain.workspace + - cloudflare-domain.validate + - cloudflare-domain.plan diff --git a/compositions/cloudflare-domain/schema.yaml b/compositions/cloudflare-domain/schema.yaml new file mode 100644 index 0000000..d79edd5 --- /dev/null +++ b/compositions/cloudflare-domain/schema.yaml @@ -0,0 +1,69 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-domain-component +spec: + type: cloudflare-domain + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Domain Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-domain + parameters: + type: object + required: + - stackName + - terraformDir + - terraformVersion + - baseDomain + - zoneMode + - pagesProjectPrefix + properties: + stackName: + type: string + terraformDir: + type: string + terraformVersion: + type: string + awsAccountId: + type: string + description: AWS account ID hosting the GitHub-OIDC role this component assumes + awsRegion: + type: string + orgName: + type: string + owner: + type: string + repo: + type: string + namespace: + type: string + namespacePrefix: + type: string + baseDomain: + type: string + description: The root domain managed by this component (e.g. example.com) + zoneMode: + type: string + enum: + - existing + - managed + description: >- + "existing" adopts a zone already present in Cloudflare (no zone creation). + "managed" creates and manages the zone lifecycle via Terraform. + pagesProjectPrefix: + type: string + description: >- + Pages project name prefix. The full project name is derived as + {pagesProjectPrefix}-{environment} at plan time. + additionalProperties: true + additionalProperties: true diff --git a/compositions/cloudflare-domain/tests/smoke/component.yaml b/compositions/cloudflare-domain/tests/smoke/component.yaml new file mode 100644 index 0000000..08520e9 --- /dev/null +++ b/compositions/cloudflare-domain/tests/smoke/component.yaml @@ -0,0 +1,31 @@ +apiVersion: sourceplane.io/v1 +kind: Component + +metadata: + name: cloudflare-domain-smoke + description: Smoke test fixture for cloudflare-domain composition validation + labels: + domain: infra + scope: composition-test + +spec: + type: cloudflare-domain + lifecycle: production + owner: platform + domain: infra + + parameters: + orgName: sourceplane + stackName: cloudflare-domain-smoke + terraformDir: terraform + terraformVersion: "1.15.3" + baseDomain: example.com + zoneMode: existing + pagesProjectPrefix: example-pages + + subscribe: + environments: + - name: stage + profile: plan-only + - name: prod + profile: plan-only diff --git a/compositions/cloudflare-pages-terraform/README.md b/compositions/cloudflare-pages-terraform/README.md index 8c03a29..fd9c43e 100644 --- a/compositions/cloudflare-pages-terraform/README.md +++ b/compositions/cloudflare-pages-terraform/README.md @@ -4,24 +4,42 @@ ## Purpose -Verify static site builds locally and reconcile a Git-backed Cloudflare Pages project with Terraform +Verify a static site build locally, then reconcile a Git-backed Cloudflare Pages +project with Terraform. There is no Wrangler upload here — the Pages project is +declared in the Terraform module under `terraformDir` and Cloudflare builds from +the connected repository using `cloudflareBuildCommand` and `rootDir`. ## Contract - **Type:** `cloudflare-pages-terraform` - **Path:** `compositions/cloudflare-pages-terraform` -- **Definition:** `compositions.yaml` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify-reconcile` (default) — `jobs/cloudflare-pages-terraform-verify-reconcile.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `appDir`, `installCommand`, + `buildCommand`, `outputDir`, `terraformDir`, `terraformVersion`, + `projectName`, `repoOwner`, `repoName`, `cloudflareBuildCommand`, `rootDir` +- **Optional parameters:** `deployBranch` (default `main`) -## Example fixtures +## Profiles -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. +Each file in `profiles/` selects steps from the job by capability. -- `examples/docs-site-git` +| Profile | Steps | +| ------------------ | ----- | +| `pull-request` | setup-node → install → build → verify-output → setup-terraform → terraform-fmt | +| `verify` (default) | `pull-request` steps + terraform-init → terraform-validate → terraform-plan | +| `release` | `pull-request` steps + terraform-init → terraform-validate → terraform-apply; requires approval and a clean git tree | ## Test fixtures -- `tests/smoke` +- `tests/smoke/component.yaml` ## Verification -`./scripts/verify-composition.sh cloudflare-pages-terraform` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `cloudflare-pages-terraform` exports from the packed +artifact. diff --git a/compositions/cloudflare-pages-terraform/composition.yaml b/compositions/cloudflare-pages-terraform/composition.yaml new file mode 100644 index 0000000..04d4ec8 --- /dev/null +++ b/compositions/cloudflare-pages-terraform/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-pages-terraform +spec: + type: cloudflare-pages-terraform + description: Cloudflare Pages deployment managed with Terraform + + schemaRef: + name: cloudflare-pages-terraform-component + + defaultJob: verify-reconcile + defaultProfile: verify + + jobs: + - name: verify-reconcile + templateRef: + name: cloudflare-pages-terraform-verify-reconcile + + profiles: + - name: pull-request + profileRef: + name: cloudflare-pages-terraform-pull-request + - name: verify + profileRef: + name: cloudflare-pages-terraform-verify + - name: release + profileRef: + name: cloudflare-pages-terraform-release diff --git a/compositions/cloudflare-pages-terraform/compositions.yaml b/compositions/cloudflare-pages-terraform/compositions.yaml deleted file mode 100644 index 273573e..0000000 --- a/compositions/cloudflare-pages-terraform/compositions.yaml +++ /dev/null @@ -1,168 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: cloudflare-pages-terraform -spec: - type: cloudflare-pages-terraform - description: Verify static site builds locally and reconcile a Git-backed Cloudflare Pages project with Terraform - defaultJob: verify-reconcile-cloudflare-pages-terraform - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Cloudflare Pages Terraform Component - description: Schema for Cloudflare Pages projects managed through Terraform-backed Git integration - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: cloudflare-pages-terraform - description: Component type identifier - inputs: - type: object - required: - - siteDir - - installCommand - - buildCommand - - cloudflareBuildCommand - - outputDir - - rootDir - - nodeVersion - - terraformDir - - terraformVersion - - projectName - - productionBranch - - repoOwner - - repoName - properties: - siteDir: - type: string - description: Path to the static site root relative to the component directory - installCommand: - type: string - description: Command used to install site dependencies before the local build - buildCommand: - type: string - description: Command used to produce the static site output locally - cloudflareBuildCommand: - type: string - description: Command Cloudflare Pages runs when building the Git-backed project - outputDir: - type: string - description: Directory produced by the static site build relative to siteDir - rootDir: - type: string - description: Repository-root relative directory Cloudflare Pages should build from - nodeVersion: - type: string - description: Node.js version provisioned for the local site build - terraformDir: - type: string - description: Terraform root directory used to reconcile the Pages project - terraformVersion: - type: string - description: Terraform version provisioned for the reconciliation job - projectName: - type: string - description: Cloudflare Pages project name managed by Terraform - productionBranch: - type: string - description: Branch used for production deploys in both GitHub and Cloudflare Pages - repoOwner: - type: string - description: GitHub owner connected to the Cloudflare Pages project - repoName: - type: string - description: GitHub repository name connected to the Cloudflare Pages project - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-reconcile-cloudflare-pages-terraform - description: Build static assets locally, validate Terraform, plan on branches, and apply on the production branch - runsOn: ubuntu-22.04 - timeout: 30m - retries: 0 - labels: - scope: infra - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - name: install-site-dependencies - shell: bash - run: | - cd "{{.siteDir}}" - {{.installCommand}} - onFailure: stop - - name: build-site - shell: bash - run: | - cd "{{.siteDir}}" - {{.buildCommand}} - onFailure: stop - - name: verify-build-output - shell: bash - run: | - cd "{{.siteDir}}" - test -d "{{.outputDir}}" - find "{{.outputDir}}" -maxdepth 2 -type f | head -n 20 - onFailure: stop - - id: setup-terraform - name: setup-terraform - use: hashicorp/setup-terraform@v4 - with: - terraform_version: "{{.terraformVersion}}" - terraform_wrapper: "false" - - name: terraform-context - shell: bash - run: | - terraform version - echo "Reconciling Cloudflare Pages project {{.projectName}} from {{.terraformDir}}" - onFailure: stop - - name: terraform-fmt-check - run: terraform -chdir={{.terraformDir}} fmt -check - onFailure: stop - - name: terraform-init - run: terraform -chdir={{.terraformDir}} init -input=false - onFailure: stop - - name: terraform-validate - run: terraform -chdir={{.terraformDir}} validate -no-color - onFailure: stop - - name: terraform-plan-or-apply - shell: bash - run: | - cloudflare_account_id="${CLOUDFLARE_ACCOUNT_ID:-00000000000000000000000000000000}" - - terraform_args=( - "-input=false" - "-var=account_id=${cloudflare_account_id}" - "-var=project_name={{.projectName}}" - "-var=production_branch={{.productionBranch}}" - "-var=repo_owner={{.repoOwner}}" - "-var=repo_name={{.repoName}}" - "-var=build_command={{.cloudflareBuildCommand}}" - "-var=destination_dir={{.outputDir}}" - "-var=root_dir={{.rootDir}}" - ) - - if [ "{{.Environment}}" = "production" ] && [ "${GITHUB_REF:-}" = "refs/heads/{{.productionBranch}}" ]; then - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for apply}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for apply}" - terraform -chdir={{.terraformDir}} apply -auto-approve "${terraform_args[@]}" - exit 0 - fi - - if [ -z "${CLOUDFLARE_API_TOKEN:-}" ] || [ -z "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then - echo "Skipping terraform plan because Cloudflare credentials are not available outside deployment contexts." - exit 0 - fi - - terraform -chdir={{.terraformDir}} plan -lock=false -no-color "${terraform_args[@]}" - onFailure: stop \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/examples/README.md b/compositions/cloudflare-pages-terraform/examples/README.md deleted file mode 100644 index 0916391..0000000 --- a/compositions/cloudflare-pages-terraform/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for cloudflare-pages-terraform - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `cloudflare-pages-terraform` looks inside a consumer repository. - -- `examples/docs-site-git` diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/infra/cloudflare-pages-terraform/component.yaml b/compositions/cloudflare-pages-terraform/examples/docs-site-git/infra/cloudflare-pages-terraform/component.yaml deleted file mode 100644 index bef7993..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/infra/cloudflare-pages-terraform/component.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: docs-site-git-source - -spec: - type: cloudflare-pages-terraform - domain: platform-docs - subscribe: - environments: - - production - inputs: - siteDir: ../../website - installCommand: npm ci - buildCommand: npm run docs:build - cloudflareBuildCommand: npm ci && npm run docs:build - outputDir: docs-build - rootDir: website - nodeVersion: "20" - terraformDir: . - terraformVersion: 1.9.8 - projectName: example-platform-docs-terraform - productionBranch: main - repoOwner: sourceplane - repoName: example-platform-repo - labels: - team: platform - layer: foundation - surface: docs - runtime: cloudflare \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/infra/cloudflare-pages-terraform/main.tf b/compositions/cloudflare-pages-terraform/examples/docs-site-git/infra/cloudflare-pages-terraform/main.tf deleted file mode 100644 index de0cd30..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/infra/cloudflare-pages-terraform/main.tf +++ /dev/null @@ -1,87 +0,0 @@ -terraform { - required_version = ">= 1.6.0" - - required_providers { - cloudflare = { - source = "cloudflare/cloudflare" - version = "~> 4.32" - } - } -} - -variable "account_id" { - description = "Cloudflare account identifier used by the Pages project" - type = string -} - -variable "project_name" { - description = "Cloudflare Pages project name" - type = string -} - -variable "production_branch" { - description = "Git branch used for production deployments" - type = string -} - -variable "repo_owner" { - description = "GitHub owner connected to the Cloudflare Pages project" - type = string -} - -variable "repo_name" { - description = "GitHub repository connected to the Cloudflare Pages project" - type = string -} - -variable "build_command" { - description = "Build command Cloudflare Pages runs for the site" - type = string -} - -variable "destination_dir" { - description = "Directory Cloudflare Pages publishes after the build" - type = string -} - -variable "root_dir" { - description = "Repository-root relative directory Cloudflare Pages builds from" - type = string -} - -resource "cloudflare_pages_project" "docs" { - account_id = var.account_id - name = var.project_name - production_branch = var.production_branch - - source { - type = "github" - - config { - owner = var.repo_owner - repo_name = var.repo_name - production_branch = var.production_branch - deployments_enabled = true - production_deployment_enabled = true - preview_deployment_setting = "all" - pr_comments_enabled = true - } - } - - build_config { - build_caching = true - build_command = var.build_command - destination_dir = var.destination_dir - root_dir = var.root_dir - } -} - -output "pages_project_name" { - value = cloudflare_pages_project.docs.name - description = "Cloudflare Pages project name" -} - -output "pages_subdomain" { - value = cloudflare_pages_project.docs.subdomain - description = "Cloudflare Pages subdomain assigned to the project" -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docs/deployment-paths.md b/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docs/deployment-paths.md deleted file mode 100644 index 98f116b..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docs/deployment-paths.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: Deployment Paths ---- - -## Wrangler direct upload {#wrangler-direct-upload} - -The `cloudflare-pages` composition builds the site in CI and then uses `wrangler pages deploy` to -push the generated `docs-build/` directory to a Direct Upload Pages project. - -Key inputs: - -- `siteDir` -- `installCommand` -- `buildCommand` -- `outputDir` -- `projectName` -- `productionBranch` - -That path is useful when you want deployment to follow the build artifact produced by Gluon. - -## Turbo worker deploy {#turbo-worker-deploy} - -The `cloudflare-worker-turbo` composition installs pnpm, runs workspace-level install, build, and -typecheck commands, then uses the app-local Wrangler config to publish a Worker from `apps/*`. - -Key inputs: - -- `workspaceDir` -- `appDir` -- `installCommand` -- `buildCommand` -- `typecheckCommand` -- `deployCommand` -- `pnpmVersion` - -That path is useful when each Worker app owns its own `component.yaml` and `wrangler.jsonc`, but the -real install and build still need to happen from the monorepo root. - -## Turbo Pages direct upload {#turbo-pages-direct-upload} - -The `cloudflare-pages-turbo` composition follows the same workspace-root install and build pattern, -then direct-uploads an app-specific output directory such as `apps/web-console/dist`. - -Key inputs: - -- `workspaceDir` -- `appDir` -- `installCommand` -- `buildCommand` -- `outputDir` -- `projectName` -- `pnpmVersion` - -That path is useful when the Pages app lives under `apps/`, the component manifest should stay next -to the app, and Gluon should still own the final build artifact. - -## Terraform Git source {#terraform-git-source} - -The `cloudflare-pages-terraform` composition validates the same local site build, then reconciles a -`cloudflare_pages_project` resource that points Cloudflare Pages at this GitHub repository. - -Key inputs: - -- `terraformDir` -- `rootDir` -- `cloudflareBuildCommand` -- `repoOwner` -- `repoName` -- `projectName` - -That path is useful when you want the Pages project itself versioned as infrastructure and let -Cloudflare build from Git after the project is connected. - -## Turbo Pages Terraform {#turbo-pages-terraform} - -The `cloudflare-pages-turbo-terraform` composition keeps the component manifest inside an `apps/*` -directory, performs the local pnpm and Turbo build from the workspace root, and then points Terraform -at an `infra/*` directory that owns the Cloudflare Pages project contract. - -Key inputs: - -- `workspaceDir` -- `appDir` -- `outputDir` -- `destinationDir` -- `rootDir` -- `terraformDir` -- `cloudflareBuildCommand` -- `pnpmVersion` - -That path is useful when platform teams want app-local manifests for discovery and ownership, but -still want the Cloudflare Pages project itself versioned under infrastructure code. - -## Choosing between them - -- Use Wrangler when Gluon should own the build artifact and publish it directly. -- Use Terraform when Gluon should manage the Pages project contract and let Cloudflare own the Git-triggered deploys. -- Use the Turbo variants when the reusable manifest should live inside an app or package directory while the install and build still need the monorepo root. \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docs/getting-started.md b/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docs/getting-started.md deleted file mode 100644 index d5bc169..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docs/getting-started.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: Getting Started ---- - -## Local build - -Run the docs site the same way the compositions do: - -```bash -cd website -npm ci -npm run docs:build -npm run docs:serve -``` - -The production build is written to `website/docs-build/`. - -## Turbo example builds - -The new `apps/` and `packages/` examples use pnpm and Turbo from the monorepo root: - -```bash -corepack enable -pnpm install --no-frozen-lockfile -pnpm turbo run build --filter=@example/web-console -pnpm turbo run typecheck --filter=@example/api-edge -``` - -Those commands mirror the inputs used by the `cloudflare-worker-turbo`, `cloudflare-pages-turbo`, -`cloudflare-pages-turbo-terraform`, and `turbo-package` compositions. - -## Why Docusaurus here - -Docusaurus is a good fit for this sample because it produces a plain static directory while still -exercising a realistic Node-based documentation toolchain. That makes it useful for both: - -- direct upload workflows that publish prebuilt assets -- Git-connected Pages projects that build inside Cloudflare - -## Credentials used in CI - -The repository expects these secrets in GitHub Actions: - -- `CLOUDFLARE_ACCOUNT_ID` -- `CLOUDFLARE_API_TOKEN` - -The direct-upload job only uses them when it is allowed to publish. The Terraform-backed job uses -the same variables when it needs to plan against or apply Cloudflare resources. - -Worker deploys use the same Cloudflare credentials because Wrangler creates the worker directly from -the app-local manifest under `apps/`. \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docusaurus.config.js b/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docusaurus.config.js deleted file mode 100644 index edbc568..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/docusaurus.config.js +++ /dev/null @@ -1,81 +0,0 @@ -const config = { - title: 'Example Platform Docs', - tagline: 'Static docs deploy paths for Cloudflare Pages through Gluon compositions', - url: 'https://example-platform-docs.pages.dev', - baseUrl: '/', - organizationName: 'sourceplane', - projectName: 'example-platform-repo', - onBrokenLinks: 'throw', - onDuplicateRoutes: 'throw', - markdown: { - hooks: { - onBrokenMarkdownLinks: 'throw', - }, - }, - i18n: { - defaultLocale: 'en', - locales: ['en'], - }, - presets: [ - [ - 'classic', - { - docs: { - path: 'docs', - routeBasePath: '/', - sidebarPath: require.resolve('./sidebars.js'), - }, - blog: false, - theme: { - customCss: require.resolve('./src/css/custom.css'), - }, - }, - ], - ], - themeConfig: { - colorMode: { - defaultMode: 'light', - respectPrefersColorScheme: true, - }, - navbar: { - title: 'Example Platform', - items: [ - { - to: '/', - label: 'Docs', - position: 'left', - }, - { - href: 'https://github.com/sourceplane/example-platform-repo', - label: 'GitHub', - position: 'right', - }, - ], - }, - footer: { - style: 'dark', - links: [ - { - title: 'Paths', - items: [ - { label: 'Wrangler Direct Upload', to: '/deployment-paths#wrangler-direct-upload' }, - { label: 'Terraform Git Source', to: '/deployment-paths#terraform-git-source' }, - ], - }, - { - title: 'Repo', - items: [ - { label: 'Intent', href: 'https://github.com/sourceplane/example-platform-repo/blob/main/intent.yaml' }, - { label: 'Compositions', href: 'https://github.com/sourceplane/example-platform-repo/tree/main/compositions' }, - ], - }, - ], - copyright: `Copyright ${new Date().getFullYear()} sourceplane`, - }, - prism: { - additionalLanguages: ['bash', 'json', 'yaml'], - }, - }, -}; - -module.exports = config; diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/package.json b/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/package.json deleted file mode 100644 index 2cf01d8..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "example-platform-docs", - "version": "1.0.0", - "private": true, - "description": "Minimal Docusaurus site used to verify Cloudflare Pages compositions in example-platform-repo", - "scripts": { - "docs:start": "docusaurus start", - "docs:build": "docusaurus build --out-dir docs-build", - "docs:serve": "docusaurus serve --dir docs-build" - }, - "overrides": { - "webpack": "5.105.4", - "html-webpack-plugin": "5.6.6" - }, - "dependencies": { - "@docusaurus/core": "3.9.2", - "@docusaurus/preset-classic": "3.9.2", - "@mdx-js/react": "3.1.1", - "react": "19.2.4", - "react-dom": "19.2.4" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/sidebars.js b/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/sidebars.js deleted file mode 100644 index 2aea2f9..0000000 --- a/compositions/cloudflare-pages-terraform/examples/docs-site-git/website/sidebars.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - docsSidebar: ['intro', 'getting-started', 'deployment-paths'], -}; \ No newline at end of file diff --git a/compositions/cloudflare-pages-terraform/jobs/cloudflare-pages-terraform-verify-reconcile.yaml b/compositions/cloudflare-pages-terraform/jobs/cloudflare-pages-terraform-verify-reconcile.yaml new file mode 100644 index 0000000..a2ed4ee --- /dev/null +++ b/compositions/cloudflare-pages-terraform/jobs/cloudflare-pages-terraform-verify-reconcile.yaml @@ -0,0 +1,134 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-pages-terraform-verify-reconcile +spec: + description: Capability-tagged atomic steps for Terraform-managed Cloudflare Pages + runsOn: ubuntu-22.04 + timeout: 30m + retries: 0 + + labels: + scope: infra + + capabilities: + - cloudflare-pages-terraform.setup-node + - cloudflare-pages-terraform.install + - cloudflare-pages-terraform.build + - cloudflare-pages-terraform.verify-output + - cloudflare-pages-terraform.setup-terraform + - cloudflare-pages-terraform.terraform-fmt + - cloudflare-pages-terraform.terraform-init + - cloudflare-pages-terraform.terraform-validate + - cloudflare-pages-terraform.terraform-plan + - cloudflare-pages-terraform.terraform-apply + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-pages-terraform.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: install-site-dependencies + name: install-site-dependencies + capability: cloudflare-pages-terraform.install + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: build-site + name: build-site + capability: cloudflare-pages-terraform.build + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.buildCommand }}" + onFailure: stop + + - id: verify-build-output + name: verify-build-output + capability: cloudflare-pages-terraform.verify-output + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: | + test -d "{{ .parameters.outputDir }}" + find "{{ .parameters.outputDir }}" -maxdepth 2 -type f | head -n 20 + onFailure: stop + + - id: setup-terraform + name: setup-terraform + capability: cloudflare-pages-terraform.setup-terraform + use: hashicorp/setup-terraform@v4 + with: + terraform_version: "{{ .parameters.terraformVersion }}" + terraform_wrapper: "false" + + - id: terraform-fmt-check + name: terraform-fmt-check + capability: cloudflare-pages-terraform.terraform-fmt + run: terraform -chdir={{ .parameters.terraformDir }} fmt -check + onFailure: stop + + - id: terraform-init + name: terraform-init + capability: cloudflare-pages-terraform.terraform-init + run: terraform -chdir={{ .parameters.terraformDir }} init -input=false + onFailure: stop + + - id: terraform-validate + name: terraform-validate + capability: cloudflare-pages-terraform.terraform-validate + run: terraform -chdir={{ .parameters.terraformDir }} validate -no-color + onFailure: stop + + - id: terraform-plan + name: terraform-plan + capability: cloudflare-pages-terraform.terraform-plan + shell: bash + run: | + cloudflare_account_id="${CLOUDFLARE_ACCOUNT_ID:-00000000000000000000000000000000}" + + terraform_args=( + "-input=false" + "-var=account_id=${cloudflare_account_id}" + "-var=project_name={{ .parameters.projectName }}" + "-var=production_branch={{ .parameters.deployBranch }}" + "-var=repo_owner={{ .parameters.repoOwner }}" + "-var=repo_name={{ .parameters.repoName }}" + "-var=build_command={{ .parameters.cloudflareBuildCommand }}" + "-var=destination_dir={{ .parameters.outputDir }}" + "-var=root_dir={{ .parameters.rootDir }}" + ) + + if [ -z "${CLOUDFLARE_API_TOKEN:-}" ] || [ -z "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then + echo "Skipping terraform plan — Cloudflare credentials not available." + exit 0 + fi + + terraform -chdir={{ .parameters.terraformDir }} plan -lock=false -no-color "${terraform_args[@]}" + onFailure: stop + + - id: terraform-apply + name: terraform-apply + capability: cloudflare-pages-terraform.terraform-apply + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for apply}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for apply}" + + terraform_args=( + "-input=false" + "-var=account_id=${CLOUDFLARE_ACCOUNT_ID}" + "-var=project_name={{ .parameters.projectName }}" + "-var=production_branch={{ .parameters.deployBranch }}" + "-var=repo_owner={{ .parameters.repoOwner }}" + "-var=repo_name={{ .parameters.repoName }}" + "-var=build_command={{ .parameters.cloudflareBuildCommand }}" + "-var=destination_dir={{ .parameters.outputDir }}" + "-var=root_dir={{ .parameters.rootDir }}" + ) + + terraform -chdir={{ .parameters.terraformDir }} apply -auto-approve "${terraform_args[@]}" + onFailure: stop diff --git a/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-pull-request.yaml b/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-pull-request.yaml new file mode 100644 index 0000000..653ccb0 --- /dev/null +++ b/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-pull-request.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-terraform-pull-request +spec: + description: Fast PR validation with site build and Terraform format check + + jobs: + verify-reconcile: + includeCapabilities: + - cloudflare-pages-terraform.setup-node + - cloudflare-pages-terraform.install + - cloudflare-pages-terraform.build + - cloudflare-pages-terraform.verify-output + - cloudflare-pages-terraform.setup-terraform + - cloudflare-pages-terraform.terraform-fmt diff --git a/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-release.yaml b/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-release.yaml new file mode 100644 index 0000000..9a402eb --- /dev/null +++ b/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-release.yaml @@ -0,0 +1,23 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-terraform-release +spec: + description: Full pipeline including Terraform apply for production releases + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-reconcile: + includeCapabilities: + - cloudflare-pages-terraform.setup-node + - cloudflare-pages-terraform.install + - cloudflare-pages-terraform.build + - cloudflare-pages-terraform.verify-output + - cloudflare-pages-terraform.setup-terraform + - cloudflare-pages-terraform.terraform-fmt + - cloudflare-pages-terraform.terraform-init + - cloudflare-pages-terraform.terraform-validate + - cloudflare-pages-terraform.terraform-apply diff --git a/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-verify.yaml b/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-verify.yaml new file mode 100644 index 0000000..740919c --- /dev/null +++ b/compositions/cloudflare-pages-terraform/profiles/cloudflare-pages-terraform-verify.yaml @@ -0,0 +1,19 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-terraform-verify +spec: + description: Full verification with Terraform validate and plan (no apply) + + jobs: + verify-reconcile: + includeCapabilities: + - cloudflare-pages-terraform.setup-node + - cloudflare-pages-terraform.install + - cloudflare-pages-terraform.build + - cloudflare-pages-terraform.verify-output + - cloudflare-pages-terraform.setup-terraform + - cloudflare-pages-terraform.terraform-fmt + - cloudflare-pages-terraform.terraform-init + - cloudflare-pages-terraform.terraform-validate + - cloudflare-pages-terraform.terraform-plan diff --git a/compositions/cloudflare-pages-terraform/schema.yaml b/compositions/cloudflare-pages-terraform/schema.yaml new file mode 100644 index 0000000..f2c4142 --- /dev/null +++ b/compositions/cloudflare-pages-terraform/schema.yaml @@ -0,0 +1,82 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-pages-terraform-component +spec: + type: cloudflare-pages-terraform + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Pages Terraform Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-pages-terraform + parameters: + type: object + required: + - nodeVersion + - appDir + - installCommand + - buildCommand + - outputDir + - terraformDir + - terraformVersion + - projectName + - repoOwner + - repoName + - cloudflareBuildCommand + - rootDir + properties: + nodeVersion: + type: string + + appDir: + type: string + description: Path from the component job path to the site directory + + installCommand: + type: string + buildCommand: + type: string + + cloudflareBuildCommand: + type: string + description: Build command configured in the Cloudflare Pages project + + outputDir: + type: string + description: Build output directory relative to appDir + + rootDir: + type: string + description: Root directory for Pages project + + terraformDir: + type: string + description: Path to the Terraform module directory + + terraformVersion: + type: string + + projectName: + type: string + description: Cloudflare Pages project name + + deployBranch: + type: string + description: Production branch for the Pages project + default: main + + repoOwner: + type: string + repoName: + type: string + additionalProperties: false + additionalProperties: true diff --git a/compositions/cloudflare-pages-terraform/tests/smoke/component.yaml b/compositions/cloudflare-pages-terraform/tests/smoke/component.yaml index bef7993..1655668 100644 --- a/compositions/cloudflare-pages-terraform/tests/smoke/component.yaml +++ b/compositions/cloudflare-pages-terraform/tests/smoke/component.yaml @@ -6,26 +6,30 @@ metadata: spec: type: cloudflare-pages-terraform + lifecycle: production + owner: platform domain: platform-docs + path: infra/cloudflare-pages-docs subscribe: environments: - - production - inputs: - siteDir: ../../website + - name: production + profile: release + parameters: + nodeVersion: "20" + appDir: ../../website installCommand: npm ci buildCommand: npm run docs:build cloudflareBuildCommand: npm ci && npm run docs:build outputDir: docs-build rootDir: website - nodeVersion: "20" terraformDir: . terraformVersion: 1.9.8 projectName: example-platform-docs-terraform - productionBranch: main + deployBranch: main repoOwner: sourceplane repoName: example-platform-repo labels: team: platform layer: foundation surface: docs - runtime: cloudflare \ No newline at end of file + runtime: cloudflare diff --git a/compositions/cloudflare-pages-turbo-terraform/README.md b/compositions/cloudflare-pages-turbo-terraform/README.md index 2b1f832..b077696 100644 --- a/compositions/cloudflare-pages-turbo-terraform/README.md +++ b/compositions/cloudflare-pages-turbo-terraform/README.md @@ -4,24 +4,46 @@ ## Purpose -Verify a static app with Turbo locally and reconcile a Git-backed Cloudflare Pages project with Terraform +Verify a Turborepo-built static app locally, then reconcile a Git-backed +Cloudflare Pages project with Terraform. There is no Wrangler upload here — the +Pages project is declared in the Terraform module under `terraformDir` and +Cloudflare builds from the connected repository using `cloudflareBuildCommand`, +`rootDir`, and `destinationDir`. ## Contract - **Type:** `cloudflare-pages-turbo-terraform` - **Path:** `compositions/cloudflare-pages-turbo-terraform` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/admin-console-git` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify-reconcile` (default) — `jobs/cloudflare-pages-turbo-terraform-verify-reconcile.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `pnpmVersion`, `workspaceDir`, + `appDir`, `turboFilter`, `outputDir`, `terraformDir`, `terraformVersion`, + `projectName`, `repoOwner`, `repoName`, `cloudflareBuildCommand`, + `destinationDir`, `rootDir` +- **Optional parameters:** `installCommand` (default + `pnpm install --frozen-lockfile`), `buildCommand`, `deployBranch` (default + `main`) + +## Profiles + +Each file in `profiles/` selects steps from the job by capability. + +| Profile | Steps | +| ------------------ | ----- | +| `pull-request` | setup-node → setup-pnpm → install → verify-structure → build → verify-output → setup-terraform → terraform-fmt | +| `verify` (default) | `pull-request` steps + terraform-init → terraform-validate → terraform-plan | +| `release` | `pull-request` steps + terraform-init → terraform-validate → terraform-apply; requires approval and a clean git tree | ## Test fixtures -- `tests/smoke` +- `tests/smoke/component.yaml` ## Verification -`./scripts/verify-composition.sh cloudflare-pages-turbo-terraform` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `cloudflare-pages-turbo-terraform` exports from the packed +artifact. diff --git a/compositions/cloudflare-pages-turbo-terraform/composition.yaml b/compositions/cloudflare-pages-turbo-terraform/composition.yaml new file mode 100644 index 0000000..ea130ba --- /dev/null +++ b/compositions/cloudflare-pages-turbo-terraform/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-pages-turbo-terraform +spec: + type: cloudflare-pages-turbo-terraform + description: Cloudflare Pages deployment using Turbo monorepo builds managed with Terraform + + schemaRef: + name: cloudflare-pages-turbo-terraform-component + + defaultJob: verify-reconcile + defaultProfile: verify + + jobs: + - name: verify-reconcile + templateRef: + name: cloudflare-pages-turbo-terraform-verify-reconcile + + profiles: + - name: pull-request + profileRef: + name: cloudflare-pages-turbo-terraform-pull-request + - name: verify + profileRef: + name: cloudflare-pages-turbo-terraform-verify + - name: release + profileRef: + name: cloudflare-pages-turbo-terraform-release diff --git a/compositions/cloudflare-pages-turbo-terraform/compositions.yaml b/compositions/cloudflare-pages-turbo-terraform/compositions.yaml deleted file mode 100644 index af6927f..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/compositions.yaml +++ /dev/null @@ -1,180 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: cloudflare-pages-turbo-terraform -spec: - type: cloudflare-pages-turbo-terraform - description: Verify a static app with Turbo locally and reconcile a Git-backed Cloudflare Pages project with Terraform - defaultJob: verify-reconcile-cloudflare-pages-turbo-terraform - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Cloudflare Pages Turbo Terraform Component - description: Schema for Git-backed Cloudflare Pages projects in a pnpm and Turbo monorepo - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: cloudflare-pages-turbo-terraform - description: Component type identifier - inputs: - type: object - required: - - cloudflareBuildCommand - - outputDir - - destinationDir - - rootDir - - nodeVersion - - pnpmVersion - - terraformDir - - terraformVersion - - projectName - - productionBranch - - repoOwner - - repoName - properties: - cloudflareBuildCommand: - type: string - description: Build command Cloudflare Pages runs when building the Git-backed project - outputDir: - type: string - description: Build output directory relative to the component directory - destinationDir: - type: string - description: Cloudflare rootDir-relative output directory published after the build - rootDir: - type: string - description: Repository-root relative directory Cloudflare Pages should build from - nodeVersion: - type: string - description: Node.js version - pnpmVersion: - type: string - description: pnpm version - terraformDir: - type: string - description: Terraform root directory relative to the component directory - terraformVersion: - type: string - description: Terraform version - projectName: - type: string - description: Cloudflare Pages project name managed by Terraform - productionBranch: - type: string - description: Branch used for production deploys in both GitHub and Cloudflare Pages - repoOwner: - type: string - description: GitHub owner connected to the Cloudflare Pages project - repoName: - type: string - description: GitHub repository name connected to the Cloudflare Pages project - preBuildCommand: - type: string - description: Optional command to run before the build (e.g. codegen, schema generation) - buildCommand: - type: string - description: Override the default turbo build command - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-reconcile-cloudflare-pages-turbo-terraform - description: Verify a Pages app locally and reconcile the Git-backed Pages project - runsOn: ubuntu-22.04 - timeout: 35m - retries: 0 - labels: - scope: infra - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - id: setup-pnpm - name: setup-pnpm - use: pnpm/action-setup@v4 - with: - version: "{{.pnpmVersion}}" - - name: install-workspace-dependencies - run: pnpm install --no-frozen-lockfile - onFailure: stop - - name: pre-build - shell: bash - run: | - {{if .preBuildCommand}} - {{.preBuildCommand}} - {{else}} - echo "Skipping pre-build." - {{end}} - onFailure: stop - - name: verify-pages-app-structure - run: test -f package.json - onFailure: stop - - name: build-pages-app - run: "{{if .buildCommand}}{{.buildCommand}}{{else}}pnpm exec turbo run build --filter=./{{end}}" - onFailure: stop - - name: verify-build-output - shell: bash - run: | - test -d "{{.outputDir}}" - find "{{.outputDir}}" -maxdepth 2 -type f | head -n 20 - onFailure: stop - - id: setup-terraform - name: setup-terraform - use: hashicorp/setup-terraform@v4 - with: - terraform_version: "{{.terraformVersion}}" - terraform_wrapper: "false" - - name: terraform-context - shell: bash - run: | - terraform version - echo "Reconciling Cloudflare Pages project {{.projectName}} from {{.terraformDir}}" - onFailure: stop - - name: terraform-fmt-check - run: terraform -chdir={{.terraformDir}} fmt -check - onFailure: stop - - name: terraform-init - run: terraform -chdir={{.terraformDir}} init -input=false - onFailure: stop - - name: terraform-validate - run: terraform -chdir={{.terraformDir}} validate -no-color - onFailure: stop - - name: terraform-plan-or-apply - shell: bash - run: | - cloudflare_account_id="${CLOUDFLARE_ACCOUNT_ID:-00000000000000000000000000000000}" - - terraform_args=( - "-input=false" - "-var=account_id=${cloudflare_account_id}" - "-var=project_name={{.projectName}}" - "-var=production_branch={{.productionBranch}}" - "-var=repo_owner={{.repoOwner}}" - "-var=repo_name={{.repoName}}" - "-var=build_command={{.cloudflareBuildCommand}}" - "-var=destination_dir={{.destinationDir}}" - "-var=root_dir={{.rootDir}}" - ) - - if [ "{{.Environment}}" = "production" ] && [ "${GITHUB_REF:-}" = "refs/heads/{{.productionBranch}}" ]; then - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for apply}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for apply}" - terraform -chdir={{.terraformDir}} apply -auto-approve "${terraform_args[@]}" - exit 0 - fi - - if [ -z "${CLOUDFLARE_API_TOKEN:-}" ] || [ -z "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then - echo "Skipping terraform plan because Cloudflare credentials are not available outside deployment contexts." - exit 0 - fi - - terraform -chdir={{.terraformDir}} plan -lock=false -no-color "${terraform_args[@]}" - onFailure: stop diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/README.md b/compositions/cloudflare-pages-turbo-terraform/examples/README.md deleted file mode 100644 index b1d6172..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for cloudflare-pages-turbo-terraform - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `cloudflare-pages-turbo-terraform` looks inside a consumer repository. - -- `examples/admin-console-git` diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/component.yaml b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/component.yaml deleted file mode 100644 index 770db61..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/component.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: admin-console-pages-git - -spec: - type: cloudflare-pages-turbo-terraform - domain: platform-ui - subscribe: - environments: - - staging - - production - inputs: - cloudflareBuildCommand: corepack enable && pnpm turbo run build --filter=@example/admin-console - outputDir: dist - destinationDir: dist - rootDir: . - nodeVersion: "20" - pnpmVersion: "10.12.1" - terraformDir: ../../infra/cloudflare-pages-admin-console - terraformVersion: 1.9.8 - projectName: example-platform-admin-console - productionBranch: main - repoOwner: sourceplane - repoName: example-platform-repo - labels: - team: platform - layer: foundation - surface: admin-console - runtime: cloudflare \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/package.json b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/package.json deleted file mode 100644 index e601fe4..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@example/admin-console", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "build": "node ./scripts/build.mjs" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/src/app.js b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/src/app.js deleted file mode 100644 index 25c37e6..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/src/app.js +++ /dev/null @@ -1,8 +0,0 @@ -const panel = document.querySelector(".panel"); - -if (panel) { - const stamp = document.createElement("p"); - stamp.className = "timestamp"; - stamp.textContent = "Managed in Cloudflare through Terraform after Gluon planning."; - panel.append(stamp); -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/wrangler.jsonc b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/wrangler.jsonc deleted file mode 100644 index e2f68c3..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/apps/admin-console/wrangler.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "../../node_modules/wrangler/config-schema.json", - "name": "example-platform-admin-console", - "compatibility_date": "2026-04-25", - "pages_build_output_dir": "dist" -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/infra/cloudflare-pages-admin-console/main.tf b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/infra/cloudflare-pages-admin-console/main.tf deleted file mode 100644 index f4eb061..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/infra/cloudflare-pages-admin-console/main.tf +++ /dev/null @@ -1,87 +0,0 @@ -terraform { - required_version = ">= 1.6.0" - - required_providers { - cloudflare = { - source = "cloudflare/cloudflare" - version = "~> 4.32" - } - } -} - -variable "account_id" { - description = "Cloudflare account identifier used by the Pages project" - type = string -} - -variable "project_name" { - description = "Cloudflare Pages project name" - type = string -} - -variable "production_branch" { - description = "Git branch used for production deployments" - type = string -} - -variable "repo_owner" { - description = "GitHub owner connected to the Cloudflare Pages project" - type = string -} - -variable "repo_name" { - description = "GitHub repository connected to the Cloudflare Pages project" - type = string -} - -variable "build_command" { - description = "Build command Cloudflare Pages runs for the site" - type = string -} - -variable "destination_dir" { - description = "Directory Cloudflare Pages publishes after the build" - type = string -} - -variable "root_dir" { - description = "Repository-root relative directory Cloudflare Pages builds from" - type = string -} - -resource "cloudflare_pages_project" "admin_console" { - account_id = var.account_id - name = var.project_name - production_branch = var.production_branch - - source { - type = "github" - - config { - owner = var.repo_owner - repo_name = var.repo_name - production_branch = var.production_branch - deployments_enabled = true - production_deployment_enabled = true - preview_deployment_setting = "all" - pr_comments_enabled = true - } - } - - build_config { - build_caching = true - build_command = var.build_command - destination_dir = var.destination_dir - root_dir = var.root_dir - } -} - -output "pages_project_name" { - value = cloudflare_pages_project.admin_console.name - description = "Cloudflare Pages project name" -} - -output "pages_subdomain" { - value = cloudflare_pages_project.admin_console.subdomain - description = "Cloudflare Pages subdomain assigned to the project" -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/package.json b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/package.json deleted file mode 100644 index d65acec..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "example-platform-repo", - "private": true, - "version": "1.0.0", - "description": "Turbo-style Cloudflare deployment examples for gluon component discovery", - "packageManager": "pnpm@10.12.1", - "scripts": { - "build": "turbo run build", - "typecheck": "turbo run typecheck", - "deploy": "turbo run deploy" - }, - "devDependencies": { - "turbo": "2.5.8", - "typescript": "5.9.3", - "wrangler": "4.13.2" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/pnpm-workspace.yaml b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/pnpm-workspace.yaml deleted file mode 100644 index c7eaed9..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - apps/* - - packages/* \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/tsconfig.base.json b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/tsconfig.base.json deleted file mode 100644 index e7910f3..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/tsconfig.base.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "noEmit": true, - "lib": [ - "ES2022", - "DOM" - ] - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/turbo.json b/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/turbo.json deleted file mode 100644 index f24d8d7..0000000 --- a/compositions/cloudflare-pages-turbo-terraform/examples/admin-console-git/turbo.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://turborepo.com/schema.json", - "tasks": { - "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**", - ".wrangler/**" - ] - }, - "typecheck": { - "dependsOn": [ - "^typecheck" - ], - "outputs": [] - }, - "deploy": { - "dependsOn": [ - "build" - ], - "cache": false, - "outputs": [] - } - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo-terraform/jobs/cloudflare-pages-turbo-terraform-verify-reconcile.yaml b/compositions/cloudflare-pages-turbo-terraform/jobs/cloudflare-pages-turbo-terraform-verify-reconcile.yaml new file mode 100644 index 0000000..db90d1f --- /dev/null +++ b/compositions/cloudflare-pages-turbo-terraform/jobs/cloudflare-pages-turbo-terraform-verify-reconcile.yaml @@ -0,0 +1,147 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-pages-turbo-terraform-verify-reconcile +spec: + description: Capability-tagged atomic steps for Terraform-managed Cloudflare Pages with Turborepo + runsOn: ubuntu-22.04 + timeout: 35m + retries: 0 + + labels: + scope: infra + + capabilities: + - cloudflare-pages-turbo-terraform.setup-node + - cloudflare-pages-turbo-terraform.setup-pnpm + - cloudflare-pages-turbo-terraform.install + - cloudflare-pages-turbo-terraform.verify-structure + - cloudflare-pages-turbo-terraform.build + - cloudflare-pages-turbo-terraform.verify-output + - cloudflare-pages-turbo-terraform.setup-terraform + - cloudflare-pages-turbo-terraform.terraform-fmt + - cloudflare-pages-turbo-terraform.terraform-init + - cloudflare-pages-turbo-terraform.terraform-validate + - cloudflare-pages-turbo-terraform.terraform-plan + - cloudflare-pages-turbo-terraform.terraform-apply + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-pages-turbo-terraform.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: setup-pnpm + name: setup-pnpm + capability: cloudflare-pages-turbo-terraform.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{ .parameters.pnpmVersion }}" + + - id: install-workspace-dependencies + name: install-workspace-dependencies + capability: cloudflare-pages-turbo-terraform.install + shell: bash + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: verify-pages-app-structure + name: verify-pages-app-structure + capability: cloudflare-pages-turbo-terraform.verify-structure + shell: bash + run: test -f package.json + onFailure: stop + + - id: build-pages-app + name: build-pages-app + capability: cloudflare-pages-turbo-terraform.build + shell: bash + run: "{{ .parameters.buildCommand }}" + onFailure: stop + + - id: verify-build-output + name: verify-build-output + capability: cloudflare-pages-turbo-terraform.verify-output + shell: bash + run: | + test -d "{{ .parameters.outputDir }}" + find "{{ .parameters.outputDir }}" -maxdepth 2 -type f | head -n 20 + onFailure: stop + + - id: setup-terraform + name: setup-terraform + capability: cloudflare-pages-turbo-terraform.setup-terraform + use: hashicorp/setup-terraform@v4 + with: + terraform_version: "{{ .parameters.terraformVersion }}" + terraform_wrapper: "false" + + - id: terraform-fmt-check + name: terraform-fmt-check + capability: cloudflare-pages-turbo-terraform.terraform-fmt + run: terraform -chdir={{ .parameters.terraformDir }} fmt -check + onFailure: stop + + - id: terraform-init + name: terraform-init + capability: cloudflare-pages-turbo-terraform.terraform-init + run: terraform -chdir={{ .parameters.terraformDir }} init -input=false + onFailure: stop + + - id: terraform-validate + name: terraform-validate + capability: cloudflare-pages-turbo-terraform.terraform-validate + run: terraform -chdir={{ .parameters.terraformDir }} validate -no-color + onFailure: stop + + - id: terraform-plan + name: terraform-plan + capability: cloudflare-pages-turbo-terraform.terraform-plan + shell: bash + run: | + cloudflare_account_id="${CLOUDFLARE_ACCOUNT_ID:-00000000000000000000000000000000}" + + terraform_args=( + "-input=false" + "-var=account_id=${cloudflare_account_id}" + "-var=project_name={{ .parameters.projectName }}" + "-var=production_branch={{ .parameters.deployBranch }}" + "-var=repo_owner={{ .parameters.repoOwner }}" + "-var=repo_name={{ .parameters.repoName }}" + "-var=build_command={{ .parameters.cloudflareBuildCommand }}" + "-var=destination_dir={{ .parameters.destinationDir }}" + "-var=root_dir={{ .parameters.rootDir }}" + ) + + if [ -z "${CLOUDFLARE_API_TOKEN:-}" ] || [ -z "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then + echo "Skipping terraform plan — Cloudflare credentials not available." + exit 0 + fi + + terraform -chdir={{ .parameters.terraformDir }} plan -lock=false -no-color "${terraform_args[@]}" + onFailure: stop + + - id: terraform-apply + name: terraform-apply + capability: cloudflare-pages-turbo-terraform.terraform-apply + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for apply}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for apply}" + + terraform_args=( + "-input=false" + "-var=account_id=${CLOUDFLARE_ACCOUNT_ID}" + "-var=project_name={{ .parameters.projectName }}" + "-var=production_branch={{ .parameters.deployBranch }}" + "-var=repo_owner={{ .parameters.repoOwner }}" + "-var=repo_name={{ .parameters.repoName }}" + "-var=build_command={{ .parameters.cloudflareBuildCommand }}" + "-var=destination_dir={{ .parameters.destinationDir }}" + "-var=root_dir={{ .parameters.rootDir }}" + ) + + terraform -chdir={{ .parameters.terraformDir }} apply -auto-approve "${terraform_args[@]}" + onFailure: stop diff --git a/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-pull-request.yaml b/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-pull-request.yaml new file mode 100644 index 0000000..e99cd8d --- /dev/null +++ b/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-pull-request.yaml @@ -0,0 +1,18 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-turbo-terraform-pull-request +spec: + description: Fast PR validation with Turbo build and Terraform format check + + jobs: + verify-reconcile: + includeCapabilities: + - cloudflare-pages-turbo-terraform.setup-node + - cloudflare-pages-turbo-terraform.setup-pnpm + - cloudflare-pages-turbo-terraform.install + - cloudflare-pages-turbo-terraform.verify-structure + - cloudflare-pages-turbo-terraform.build + - cloudflare-pages-turbo-terraform.verify-output + - cloudflare-pages-turbo-terraform.setup-terraform + - cloudflare-pages-turbo-terraform.terraform-fmt diff --git a/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-release.yaml b/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-release.yaml new file mode 100644 index 0000000..1227457 --- /dev/null +++ b/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-release.yaml @@ -0,0 +1,25 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-turbo-terraform-release +spec: + description: Full pipeline including Terraform apply for production releases + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-reconcile: + includeCapabilities: + - cloudflare-pages-turbo-terraform.setup-node + - cloudflare-pages-turbo-terraform.setup-pnpm + - cloudflare-pages-turbo-terraform.install + - cloudflare-pages-turbo-terraform.verify-structure + - cloudflare-pages-turbo-terraform.build + - cloudflare-pages-turbo-terraform.verify-output + - cloudflare-pages-turbo-terraform.setup-terraform + - cloudflare-pages-turbo-terraform.terraform-fmt + - cloudflare-pages-turbo-terraform.terraform-init + - cloudflare-pages-turbo-terraform.terraform-validate + - cloudflare-pages-turbo-terraform.terraform-apply diff --git a/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-verify.yaml b/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-verify.yaml new file mode 100644 index 0000000..0e40440 --- /dev/null +++ b/compositions/cloudflare-pages-turbo-terraform/profiles/cloudflare-pages-turbo-terraform-verify.yaml @@ -0,0 +1,21 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-turbo-terraform-verify +spec: + description: Full verification with Terraform validate and plan (no apply) + + jobs: + verify-reconcile: + includeCapabilities: + - cloudflare-pages-turbo-terraform.setup-node + - cloudflare-pages-turbo-terraform.setup-pnpm + - cloudflare-pages-turbo-terraform.install + - cloudflare-pages-turbo-terraform.verify-structure + - cloudflare-pages-turbo-terraform.build + - cloudflare-pages-turbo-terraform.verify-output + - cloudflare-pages-turbo-terraform.setup-terraform + - cloudflare-pages-turbo-terraform.terraform-fmt + - cloudflare-pages-turbo-terraform.terraform-init + - cloudflare-pages-turbo-terraform.terraform-validate + - cloudflare-pages-turbo-terraform.terraform-plan diff --git a/compositions/cloudflare-pages-turbo-terraform/schema.yaml b/compositions/cloudflare-pages-turbo-terraform/schema.yaml new file mode 100644 index 0000000..6637731 --- /dev/null +++ b/compositions/cloudflare-pages-turbo-terraform/schema.yaml @@ -0,0 +1,100 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-pages-turbo-terraform-component +spec: + type: cloudflare-pages-turbo-terraform + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Pages Turbo Terraform Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-pages-turbo-terraform + parameters: + type: object + required: + - nodeVersion + - pnpmVersion + - workspaceDir + - appDir + - turboFilter + - outputDir + - terraformDir + - terraformVersion + - projectName + - repoOwner + - repoName + - cloudflareBuildCommand + - destinationDir + - rootDir + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + + workspaceDir: + type: string + description: Path from the component job path to the monorepo root + + appDir: + type: string + description: Path from the component job path to the Pages app directory + + turboFilter: + type: string + description: Turborepo filter for this Pages package + + outputDir: + type: string + description: Build output directory relative to appDir + + destinationDir: + type: string + description: Cloudflare Pages destination directory + + rootDir: + type: string + description: Root directory for Pages project + + terraformDir: + type: string + description: Path to the Terraform module directory + + terraformVersion: + type: string + + projectName: + type: string + description: Cloudflare Pages project name + + deployBranch: + type: string + description: Production branch for the Pages project + default: main + + repoOwner: + type: string + repoName: + type: string + + cloudflareBuildCommand: + type: string + description: Build command configured in the Cloudflare Pages project + + installCommand: + type: string + default: pnpm install --frozen-lockfile + + buildCommand: + type: string + additionalProperties: false + additionalProperties: true diff --git a/compositions/cloudflare-pages-turbo-terraform/tests/smoke/component.yaml b/compositions/cloudflare-pages-turbo-terraform/tests/smoke/component.yaml index 770db61..1f91e8e 100644 --- a/compositions/cloudflare-pages-turbo-terraform/tests/smoke/component.yaml +++ b/compositions/cloudflare-pages-turbo-terraform/tests/smoke/component.yaml @@ -6,26 +6,36 @@ metadata: spec: type: cloudflare-pages-turbo-terraform + lifecycle: production + owner: platform domain: platform-ui + path: apps/admin-console subscribe: environments: - - staging - - production - inputs: - cloudflareBuildCommand: corepack enable && pnpm turbo run build --filter=@example/admin-console + - name: staging + profile: verify + - name: production + profile: release + parameters: + nodeVersion: "20" + pnpmVersion: "10.12.1" + workspaceDir: ../.. + appDir: . + turboFilter: "@example/admin-console" outputDir: dist destinationDir: dist rootDir: . - nodeVersion: "20" - pnpmVersion: "10.12.1" terraformDir: ../../infra/cloudflare-pages-admin-console terraformVersion: 1.9.8 projectName: example-platform-admin-console - productionBranch: main + deployBranch: main repoOwner: sourceplane repoName: example-platform-repo + cloudflareBuildCommand: corepack enable && pnpm turbo run build --filter=@example/admin-console + installCommand: pnpm install --frozen-lockfile + buildCommand: pnpm exec turbo run build --filter=@example/admin-console labels: team: platform layer: foundation surface: admin-console - runtime: cloudflare \ No newline at end of file + runtime: cloudflare diff --git a/compositions/cloudflare-pages-turbo/README.md b/compositions/cloudflare-pages-turbo/README.md index d173e7d..62eaa11 100644 --- a/compositions/cloudflare-pages-turbo/README.md +++ b/compositions/cloudflare-pages-turbo/README.md @@ -4,24 +4,46 @@ ## Purpose -Build a static app with Turbo and direct-upload it to Cloudflare Pages +Build a static app inside a pnpm + Turborepo monorepo and direct-upload it to +Cloudflare Pages. The deploy profile reconciles the Pages project through the +Cloudflare API before uploading `outputDir`. ## Contract - **Type:** `cloudflare-pages-turbo` - **Path:** `compositions/cloudflare-pages-turbo` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/web-console` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify-deploy` (default) — `jobs/cloudflare-pages-turbo-verify-deploy.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `pnpmVersion`, `workspaceDir`, + `appDir`, `turboFilter`, `outputDir`, `projectName` +- **Optional parameters:** `installCommand` (default + `pnpm install --frozen-lockfile`), `buildCommand`, `deployBranch` (default + `main`), `smokeCommand`, `environmentAwareProjectName`, `environmentBuildVar` +- **Per-env naming:** `environmentAwareProjectName: true` appends the Orun + environment name as a suffix to `projectName` (e.g. `my-app` becomes + `my-app-stage` in the stage environment). +- **Build-time env:** `environmentBuildVar` names a Vite-compatible variable + (e.g. `VITE_DEPLOY_ENV`) exported with the Orun environment name during build. + +## Profiles + +Each file in `profiles/` selects steps from the job by capability. + +| Profile | Steps | +| ------------------ | ----- | +| `pull-request` | setup-node → setup-pnpm → install → verify-structure → build → verify-output | +| `verify` (default) | same steps as `pull-request` — full non-mutating verification | +| `deploy` | `verify` steps + provision → deploy → smoke; requires approval and a clean git tree | ## Test fixtures -- `tests/smoke` +- `tests/smoke/component.yaml` ## Verification -`./scripts/verify-composition.sh cloudflare-pages-turbo` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `cloudflare-pages-turbo` exports from the packed artifact. diff --git a/compositions/cloudflare-pages-turbo/composition.yaml b/compositions/cloudflare-pages-turbo/composition.yaml new file mode 100644 index 0000000..e2cdcf4 --- /dev/null +++ b/compositions/cloudflare-pages-turbo/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-pages-turbo +spec: + type: cloudflare-pages-turbo + description: Cloudflare Pages deployment using Turbo monorepo builds + + schemaRef: + name: cloudflare-pages-turbo-component + + defaultJob: verify-deploy + defaultProfile: verify + + jobs: + - name: verify-deploy + templateRef: + name: cloudflare-pages-turbo-verify-deploy + + profiles: + - name: pull-request + profileRef: + name: cloudflare-pages-turbo-pull-request + - name: verify + profileRef: + name: cloudflare-pages-turbo-verify + - name: deploy + profileRef: + name: cloudflare-pages-turbo-deploy diff --git a/compositions/cloudflare-pages-turbo/compositions.yaml b/compositions/cloudflare-pages-turbo/compositions.yaml deleted file mode 100644 index ab3d0a6..0000000 --- a/compositions/cloudflare-pages-turbo/compositions.yaml +++ /dev/null @@ -1,168 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: cloudflare-pages-turbo -spec: - type: cloudflare-pages-turbo - description: Build a static app with Turbo and direct-upload it to Cloudflare Pages - defaultJob: verify-deploy-cloudflare-pages-turbo - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Cloudflare Pages Turbo Component - description: Schema for Cloudflare Pages direct upload apps in a pnpm and Turbo monorepo - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: cloudflare-pages-turbo - description: Component type identifier - inputs: - type: object - required: - - outputDir - - projectName - - nodeVersion - - pnpmVersion - - productionBranch - properties: - outputDir: - type: string - description: Build output directory relative to the component directory - projectName: - type: string - description: Cloudflare Pages project name used for direct upload - nodeVersion: - type: string - description: Node.js version - pnpmVersion: - type: string - description: pnpm version - productionBranch: - type: string - description: Branch that is allowed to publish the Pages app - preBuildCommand: - type: string - description: Optional command to run before the build (e.g. codegen, schema generation) - buildCommand: - type: string - description: Override the default turbo build command - smokeCommand: - type: string - description: Post-deploy verification command (e.g. curl the live Pages URL) - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-deploy-cloudflare-pages-turbo - description: Build a Pages app and direct-upload it from the production branch - runsOn: ubuntu-22.04 - timeout: 30m - retries: 0 - labels: - scope: delivery - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - id: setup-pnpm - name: setup-pnpm - use: pnpm/action-setup@v4 - with: - version: "{{.pnpmVersion}}" - - name: install-workspace-dependencies - run: pnpm install --no-frozen-lockfile - onFailure: stop - - name: pre-build - shell: bash - run: | - {{if .preBuildCommand}} - {{.preBuildCommand}} - {{else}} - echo "Skipping pre-build." - {{end}} - onFailure: stop - - name: verify-pages-app-structure - run: test -f package.json - onFailure: stop - - name: build-pages-app - run: "{{if .buildCommand}}{{.buildCommand}}{{else}}pnpm exec turbo run build --filter=./{{end}}" - onFailure: stop - - name: verify-build-output - shell: bash - run: | - test -d "{{.outputDir}}" - find "{{.outputDir}}" -maxdepth 2 -type f | head -n 20 - onFailure: stop - - name: ensure-pages-project - shell: bash - run: | - if [ "{{.Environment}}" != "production" ] || [ "${GITHUB_REF:-}" != "refs/heads/{{.productionBranch}}" ]; then - echo "::notice::SKIPPED: Cloudflare Pages project reconciliation for {{.Component}} in {{.Environment}} on ${GITHUB_REF:-local} (not production branch)." - exit 0 - fi - - echo "::group::Validate Cloudflare credentials" - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deployment}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deployment}" - echo "CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN are set." - echo "::endgroup::" - - api_root="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects" - response_file="${RUNNER_TEMP:-/tmp}/cloudflare-pages-project.json" - status="$(curl -sS -o "${response_file}" -w "%{http_code}" \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -H "Content-Type: application/json" \ - "${api_root}/{{.projectName}}")" - - if [ "${status}" = "200" ]; then - echo "Pages project {{.projectName}} already exists." - elif [ "${status}" = "404" ]; then - curl -sS --fail -X POST \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -H "Content-Type: application/json" \ - --data '{"name":"{{.projectName}}","production_branch":"{{.productionBranch}}"}' \ - "${api_root}" >/dev/null - echo "Created Pages project {{.projectName}}." - else - cat "${response_file}" - exit 1 - fi - - curl -sS --fail -X PATCH \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -H "Content-Type: application/json" \ - --data '{"production_branch":"{{.productionBranch}}"}' \ - "${api_root}/{{.projectName}}" >/dev/null - onFailure: stop - - name: deploy-pages-artifact - shell: bash - run: | - if [ "{{.Environment}}" != "production" ] || [ "${GITHUB_REF:-}" != "refs/heads/{{.productionBranch}}" ]; then - echo "::notice::SKIPPED: Cloudflare Pages deploy for {{.Component}} in {{.Environment}} on ${GITHUB_REF:-local} (not production branch)." - exit 0 - fi - - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deployment}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deployment}" - - echo "::notice::LIVE DEPLOY: Uploading {{.Component}} to Cloudflare Pages from ${GITHUB_REF:-}." - pnpm exec wrangler pages deploy "{{.outputDir}}" \ - --project-name "{{.projectName}}" \ - --branch "{{.productionBranch}}" - - {{if .smokeCommand}} - echo "::group::Post-deploy smoke test" - {{.smokeCommand}} - echo "::endgroup::" - {{end}} - - echo "::notice::DEPLOY SUCCESS: {{.Component}} deployed to Cloudflare Pages." - onFailure: stop diff --git a/compositions/cloudflare-pages-turbo/examples/README.md b/compositions/cloudflare-pages-turbo/examples/README.md deleted file mode 100644 index b08e76f..0000000 --- a/compositions/cloudflare-pages-turbo/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for cloudflare-pages-turbo - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `cloudflare-pages-turbo` looks inside a consumer repository. - -- `examples/web-console` diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/component.yaml b/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/component.yaml deleted file mode 100644 index e537dc1..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/component.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: web-console-pages - -spec: - type: cloudflare-pages-turbo - domain: platform-ui - subscribe: - environments: - - preview - - staging - - production - inputs: - outputDir: dist - projectName: example-platform-web-console - nodeVersion: "20" - pnpmVersion: "10.12.1" - productionBranch: main - labels: - team: platform - layer: delivery - surface: web-console - runtime: cloudflare \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/package.json b/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/package.json deleted file mode 100644 index 40aaaa2..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@example/web-console", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "build": "node ./scripts/build.mjs" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/src/app.js b/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/src/app.js deleted file mode 100644 index ad59686..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/src/app.js +++ /dev/null @@ -1,8 +0,0 @@ -const panel = document.querySelector(".panel"); - -if (panel) { - const stamp = document.createElement("p"); - stamp.className = "timestamp"; - stamp.textContent = `Build source: apps/web-console at ${new Date().toISOString()}`; - panel.append(stamp); -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/wrangler.jsonc b/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/wrangler.jsonc deleted file mode 100644 index 67e99e2..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/apps/web-console/wrangler.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "../../node_modules/wrangler/config-schema.json", - "name": "example-platform-web-console", - "compatibility_date": "2026-04-25", - "pages_build_output_dir": "dist" -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/package.json b/compositions/cloudflare-pages-turbo/examples/web-console/package.json deleted file mode 100644 index d65acec..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "example-platform-repo", - "private": true, - "version": "1.0.0", - "description": "Turbo-style Cloudflare deployment examples for gluon component discovery", - "packageManager": "pnpm@10.12.1", - "scripts": { - "build": "turbo run build", - "typecheck": "turbo run typecheck", - "deploy": "turbo run deploy" - }, - "devDependencies": { - "turbo": "2.5.8", - "typescript": "5.9.3", - "wrangler": "4.13.2" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/pnpm-workspace.yaml b/compositions/cloudflare-pages-turbo/examples/web-console/pnpm-workspace.yaml deleted file mode 100644 index c7eaed9..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - apps/* - - packages/* \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/tsconfig.base.json b/compositions/cloudflare-pages-turbo/examples/web-console/tsconfig.base.json deleted file mode 100644 index e7910f3..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/tsconfig.base.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "noEmit": true, - "lib": [ - "ES2022", - "DOM" - ] - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/examples/web-console/turbo.json b/compositions/cloudflare-pages-turbo/examples/web-console/turbo.json deleted file mode 100644 index f24d8d7..0000000 --- a/compositions/cloudflare-pages-turbo/examples/web-console/turbo.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://turborepo.com/schema.json", - "tasks": { - "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**", - ".wrangler/**" - ] - }, - "typecheck": { - "dependsOn": [ - "^typecheck" - ], - "outputs": [] - }, - "deploy": { - "dependsOn": [ - "build" - ], - "cache": false, - "outputs": [] - } - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages-turbo/jobs/cloudflare-pages-turbo-verify-deploy.yaml b/compositions/cloudflare-pages-turbo/jobs/cloudflare-pages-turbo-verify-deploy.yaml new file mode 100644 index 0000000..91756e3 --- /dev/null +++ b/compositions/cloudflare-pages-turbo/jobs/cloudflare-pages-turbo-verify-deploy.yaml @@ -0,0 +1,147 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-pages-turbo-verify-deploy +spec: + description: Capability-tagged atomic steps for Cloudflare Pages with Turborepo + runsOn: ubuntu-22.04 + timeout: 30m + retries: 0 + + labels: + scope: delivery + + capabilities: + - cloudflare-pages-turbo.setup-node + - cloudflare-pages-turbo.setup-pnpm + - cloudflare-pages-turbo.install + - cloudflare-pages-turbo.verify-structure + - cloudflare-pages-turbo.build + - cloudflare-pages-turbo.verify-output + - cloudflare-pages-turbo.provision + - cloudflare-pages-turbo.deploy + - cloudflare-pages-turbo.smoke + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-pages-turbo.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: setup-pnpm + name: setup-pnpm + capability: cloudflare-pages-turbo.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{ .parameters.pnpmVersion }}" + + - id: install-workspace-dependencies + name: install-workspace-dependencies + capability: cloudflare-pages-turbo.install + shell: bash + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: verify-pages-app-structure + name: verify-pages-app-structure + capability: cloudflare-pages-turbo.verify-structure + shell: bash + run: test -f package.json + onFailure: stop + + - id: build-pages-app + name: build-pages-app + capability: cloudflare-pages-turbo.build + shell: bash + run: | + {{- if .parameters.environmentBuildVar }} + export {{ .parameters.environmentBuildVar }}="{{ .orun.environment.name }}" + {{- end }} + {{ .parameters.buildCommand }} + onFailure: stop + + - id: verify-build-output + name: verify-build-output + capability: cloudflare-pages-turbo.verify-output + shell: bash + run: | + test -d "{{ .parameters.outputDir }}" + find "{{ .parameters.outputDir }}" -maxdepth 2 -type f | head -n 20 + onFailure: stop + + - id: ensure-pages-project + name: ensure-pages-project + capability: cloudflare-pages-turbo.provision + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + + {{- if .parameters.environmentAwareProjectName }} + PROJECT_NAME="{{ .parameters.projectName }}-{{ .orun.environment.name }}" + {{- else }} + PROJECT_NAME="{{ .parameters.projectName }}" + {{- end }} + + api_root="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects" + response_file="${RUNNER_TEMP:-/tmp}/cloudflare-pages-project.json" + status="$(curl -sS -o "${response_file}" -w "%{http_code}" \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json" \ + "${api_root}/${PROJECT_NAME}")" + + if [ "${status}" = "200" ]; then + echo "Pages project ${PROJECT_NAME} already exists." + elif [ "${status}" = "404" ]; then + curl -sS --fail -X POST \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json" \ + --data "{\"name\":\"${PROJECT_NAME}\",\"production_branch\":\"{{ .parameters.deployBranch }}\"}" \ + "${api_root}" >/dev/null + echo "Created Pages project ${PROJECT_NAME}." + else + cat "${response_file}" + exit 1 + fi + + curl -sS --fail -X PATCH \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json" \ + --data '{"production_branch":"{{ .parameters.deployBranch }}"}' \ + "${api_root}/${PROJECT_NAME}" >/dev/null + onFailure: stop + + - id: deploy-pages-artifact + name: deploy-pages-artifact + capability: cloudflare-pages-turbo.deploy + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + + {{- if .parameters.environmentAwareProjectName }} + PROJECT_NAME="{{ .parameters.projectName }}-{{ .orun.environment.name }}" + {{- else }} + PROJECT_NAME="{{ .parameters.projectName }}" + {{- end }} + + pnpm exec wrangler pages deploy "{{ .parameters.outputDir }}" \ + --project-name "${PROJECT_NAME}" \ + --branch "{{ .parameters.deployBranch }}" + onFailure: stop + + - id: smoke + name: smoke + capability: cloudflare-pages-turbo.smoke + shell: bash + run: | + export ORUN_ENVIRONMENT="{{ .orun.environment.name }}" + {{- if .parameters.environmentAwareProjectName }} + export EFFECTIVE_PROJECT_NAME="{{ .parameters.projectName }}-{{ .orun.environment.name }}" + {{- else }} + export EFFECTIVE_PROJECT_NAME="{{ .parameters.projectName }}" + {{- end }} + {{ .parameters.smokeCommand }} + onFailure: stop diff --git a/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-deploy.yaml b/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-deploy.yaml new file mode 100644 index 0000000..7500cdb --- /dev/null +++ b/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-deploy.yaml @@ -0,0 +1,23 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-turbo-deploy +spec: + description: Full pipeline including provisioning, deployment, and smoke test + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-pages-turbo.setup-node + - cloudflare-pages-turbo.setup-pnpm + - cloudflare-pages-turbo.install + - cloudflare-pages-turbo.verify-structure + - cloudflare-pages-turbo.build + - cloudflare-pages-turbo.verify-output + - cloudflare-pages-turbo.provision + - cloudflare-pages-turbo.deploy + - cloudflare-pages-turbo.smoke diff --git a/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-pull-request.yaml b/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-pull-request.yaml new file mode 100644 index 0000000..a6ff95a --- /dev/null +++ b/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-pull-request.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-turbo-pull-request +spec: + description: Fast PR validation without provisioning or deployment + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-pages-turbo.setup-node + - cloudflare-pages-turbo.setup-pnpm + - cloudflare-pages-turbo.install + - cloudflare-pages-turbo.verify-structure + - cloudflare-pages-turbo.build + - cloudflare-pages-turbo.verify-output diff --git a/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-verify.yaml b/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-verify.yaml new file mode 100644 index 0000000..f29f95e --- /dev/null +++ b/compositions/cloudflare-pages-turbo/profiles/cloudflare-pages-turbo-verify.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-turbo-verify +spec: + description: Full non-mutating verification of build output + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-pages-turbo.setup-node + - cloudflare-pages-turbo.setup-pnpm + - cloudflare-pages-turbo.install + - cloudflare-pages-turbo.verify-structure + - cloudflare-pages-turbo.build + - cloudflare-pages-turbo.verify-output diff --git a/compositions/cloudflare-pages-turbo/schema.yaml b/compositions/cloudflare-pages-turbo/schema.yaml new file mode 100644 index 0000000..a738055 --- /dev/null +++ b/compositions/cloudflare-pages-turbo/schema.yaml @@ -0,0 +1,89 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-pages-turbo-component +spec: + type: cloudflare-pages-turbo + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Pages Turbo Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-pages-turbo + parameters: + type: object + required: + - nodeVersion + - pnpmVersion + - workspaceDir + - appDir + - turboFilter + - outputDir + - projectName + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + + workspaceDir: + type: string + description: Path from the component job path to the monorepo root + + appDir: + type: string + description: Path from the component job path to the Pages app directory + + turboFilter: + type: string + description: Turborepo filter for this Pages package + + outputDir: + type: string + description: Build output directory relative to appDir + + projectName: + type: string + description: Cloudflare Pages project name + + deployBranch: + type: string + description: Branch name passed to wrangler pages deploy + default: main + + installCommand: + type: string + default: pnpm install --frozen-lockfile + + buildCommand: + type: string + smokeCommand: + type: string + default: "echo 'No smoke test configured.'" + + environmentAwareProjectName: + type: boolean + description: >- + When true, appends the Orun environment name as a suffix to + projectName (e.g. "my-app" becomes "my-app-stage" in the stage + environment). Useful for deploying per-environment Pages projects + from a single component definition. + default: false + + environmentBuildVar: + type: string + description: >- + Optional Vite-compatible environment variable name (e.g. + VITE_DEPLOY_ENV) that will be exported with the Orun environment + name during the build step, allowing the app to lock its + configuration to the target environment at build time. + additionalProperties: false + additionalProperties: true diff --git a/compositions/cloudflare-pages-turbo/tests/smoke/component.yaml b/compositions/cloudflare-pages-turbo/tests/smoke/component.yaml index e537dc1..4e35095 100644 --- a/compositions/cloudflare-pages-turbo/tests/smoke/component.yaml +++ b/compositions/cloudflare-pages-turbo/tests/smoke/component.yaml @@ -6,20 +6,31 @@ metadata: spec: type: cloudflare-pages-turbo + lifecycle: production + owner: platform domain: platform-ui + path: apps/web-console subscribe: environments: - - preview - - staging - - production - inputs: - outputDir: dist - projectName: example-platform-web-console + - name: preview + profile: pull-request + - name: staging + profile: verify + - name: production + profile: deploy + parameters: nodeVersion: "20" pnpmVersion: "10.12.1" - productionBranch: main + workspaceDir: ../.. + appDir: . + turboFilter: "@example/web-console" + outputDir: dist + projectName: example-platform-web-console + deployBranch: main + installCommand: pnpm install --frozen-lockfile + buildCommand: pnpm exec turbo run build --filter=@example/web-console labels: team: platform layer: delivery surface: web-console - runtime: cloudflare \ No newline at end of file + runtime: cloudflare diff --git a/compositions/cloudflare-pages/README.md b/compositions/cloudflare-pages/README.md index da7b056..2528e24 100644 --- a/compositions/cloudflare-pages/README.md +++ b/compositions/cloudflare-pages/README.md @@ -4,24 +4,40 @@ ## Purpose -Build static site assets and direct-upload them to Cloudflare Pages with Wrangler +Build static site assets and direct-upload them to Cloudflare Pages with +Wrangler (`wrangler pages deploy`). The deploy profile first reconciles the +Pages project through the Cloudflare API — creating it if it is missing and +pinning its production branch — before uploading `outputDir`. ## Contract - **Type:** `cloudflare-pages` - **Path:** `compositions/cloudflare-pages` -- **Definition:** `compositions.yaml` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify-deploy` (default) — `jobs/cloudflare-pages-verify-deploy.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `appDir`, `installCommand`, + `buildCommand`, `outputDir`, `projectName` +- **Optional parameters:** `deployBranch` (default `main`), `smokeCommand` -## Example fixtures +## Profiles -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. +Each file in `profiles/` selects steps from the job by capability. -- `examples/docs-site` +| Profile | Steps | +| ------------------ | ----- | +| `pull-request` | setup-node → install → build → verify-output | +| `verify` (default) | same steps as `pull-request` — full non-mutating verification | +| `deploy` | `verify` steps + provision → deploy → smoke; requires approval and a clean git tree | ## Test fixtures -- `tests/smoke` +- `tests/smoke/component.yaml` ## Verification -`./scripts/verify-composition.sh cloudflare-pages` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `cloudflare-pages` exports from the packed artifact. diff --git a/compositions/cloudflare-pages/composition.yaml b/compositions/cloudflare-pages/composition.yaml new file mode 100644 index 0000000..b1ed946 --- /dev/null +++ b/compositions/cloudflare-pages/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-pages +spec: + type: cloudflare-pages + description: Cloudflare Pages build, verify, and deploy pipeline + + schemaRef: + name: cloudflare-pages-component + + defaultJob: verify-deploy + defaultProfile: verify + + jobs: + - name: verify-deploy + templateRef: + name: cloudflare-pages-verify-deploy + + profiles: + - name: pull-request + profileRef: + name: cloudflare-pages-pull-request + - name: verify + profileRef: + name: cloudflare-pages-verify + - name: deploy + profileRef: + name: cloudflare-pages-deploy diff --git a/compositions/cloudflare-pages/compositions.yaml b/compositions/cloudflare-pages/compositions.yaml deleted file mode 100644 index 2ef7ca6..0000000 --- a/compositions/cloudflare-pages/compositions.yaml +++ /dev/null @@ -1,146 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: cloudflare-pages -spec: - type: cloudflare-pages - description: Build static site assets and direct-upload them to Cloudflare Pages with Wrangler - defaultJob: verify-deploy-cloudflare-pages - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Cloudflare Pages Direct Upload Component - description: Schema for static site deployments that build locally and publish with Wrangler - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: cloudflare-pages - description: Component type identifier - inputs: - type: object - required: - - siteDir - - installCommand - - buildCommand - - outputDir - - projectName - - nodeVersion - - productionBranch - properties: - siteDir: - type: string - description: Path to the static site root relative to the component directory - installCommand: - type: string - description: Command used to install site dependencies before the build - buildCommand: - type: string - description: Command used to generate the static site output - outputDir: - type: string - description: Directory produced by the static site build relative to siteDir - projectName: - type: string - description: Cloudflare Pages project name used for direct upload - nodeVersion: - type: string - description: Node.js version provisioned for the site build - productionBranch: - type: string - description: Branch that is allowed to perform Cloudflare deployments - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-deploy-cloudflare-pages - description: Build static assets everywhere and deploy them to Cloudflare Pages from the production branch - runsOn: ubuntu-22.04 - timeout: 25m - retries: 0 - labels: - scope: delivery - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - name: install-site-dependencies - shell: bash - run: | - cd "{{.siteDir}}" - {{.installCommand}} - onFailure: stop - - name: build-site - shell: bash - run: | - cd "{{.siteDir}}" - {{.buildCommand}} - onFailure: stop - - name: verify-build-output - shell: bash - run: | - cd "{{.siteDir}}" - test -d "{{.outputDir}}" - find "{{.outputDir}}" -maxdepth 2 -type f | head -n 20 - onFailure: stop - - name: ensure-pages-project - shell: bash - run: | - if [ "{{.Environment}}" != "production" ] || [ "${GITHUB_REF:-}" != "refs/heads/{{.productionBranch}}" ]; then - echo "Skipping Cloudflare Pages project reconciliation for {{.Environment}} on ${GITHUB_REF:-local}." - exit 0 - fi - - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deployment}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deployment}" - - api_root="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects" - response_file="${RUNNER_TEMP:-/tmp}/cloudflare-pages-project.json" - status="$(curl -sS -o "${response_file}" -w "%{http_code}" \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -H "Content-Type: application/json" \ - "${api_root}/{{.projectName}}")" - - if [ "${status}" = "200" ]; then - echo "Pages project {{.projectName}} already exists." - elif [ "${status}" = "404" ]; then - curl -sS --fail -X POST \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -H "Content-Type: application/json" \ - --data '{"name":"{{.projectName}}","production_branch":"{{.productionBranch}}"}' \ - "${api_root}" >/dev/null - echo "Created Pages project {{.projectName}}." - else - cat "${response_file}" - exit 1 - fi - - curl -sS --fail -X PATCH \ - -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ - -H "Content-Type: application/json" \ - --data '{"production_branch":"{{.productionBranch}}"}' \ - "${api_root}/{{.projectName}}" >/dev/null - onFailure: stop - - name: deploy-pages-artifact - shell: bash - run: | - if [ "{{.Environment}}" != "production" ] || [ "${GITHUB_REF:-}" != "refs/heads/{{.productionBranch}}" ]; then - echo "Skipping Cloudflare Pages deploy for {{.Environment}} on ${GITHUB_REF:-local}." - exit 0 - fi - - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deployment}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deployment}" - - cd "{{.siteDir}}" - npx wrangler pages deploy "{{.outputDir}}" \ - --project-name "{{.projectName}}" \ - --branch "{{.productionBranch}}" - onFailure: stop \ No newline at end of file diff --git a/compositions/cloudflare-pages/examples/README.md b/compositions/cloudflare-pages/examples/README.md deleted file mode 100644 index 53b3594..0000000 --- a/compositions/cloudflare-pages/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for cloudflare-pages - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `cloudflare-pages` looks inside a consumer repository. - -- `examples/docs-site` diff --git a/compositions/cloudflare-pages/examples/docs-site/website/component.yaml b/compositions/cloudflare-pages/examples/docs-site/website/component.yaml deleted file mode 100644 index 2a301a5..0000000 --- a/compositions/cloudflare-pages/examples/docs-site/website/component.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: docs-site-direct-upload - -spec: - type: cloudflare-pages - domain: platform-docs - subscribe: - environments: - - production - inputs: - siteDir: . - installCommand: npm ci - buildCommand: npm run docs:build - outputDir: docs-build - projectName: example-platform-docs-wrangler - nodeVersion: "20" - productionBranch: main - labels: - team: platform - layer: delivery - surface: docs - runtime: cloudflare diff --git a/compositions/cloudflare-pages/examples/docs-site/website/docs/deployment-paths.md b/compositions/cloudflare-pages/examples/docs-site/website/docs/deployment-paths.md deleted file mode 100644 index 98f116b..0000000 --- a/compositions/cloudflare-pages/examples/docs-site/website/docs/deployment-paths.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: Deployment Paths ---- - -## Wrangler direct upload {#wrangler-direct-upload} - -The `cloudflare-pages` composition builds the site in CI and then uses `wrangler pages deploy` to -push the generated `docs-build/` directory to a Direct Upload Pages project. - -Key inputs: - -- `siteDir` -- `installCommand` -- `buildCommand` -- `outputDir` -- `projectName` -- `productionBranch` - -That path is useful when you want deployment to follow the build artifact produced by Gluon. - -## Turbo worker deploy {#turbo-worker-deploy} - -The `cloudflare-worker-turbo` composition installs pnpm, runs workspace-level install, build, and -typecheck commands, then uses the app-local Wrangler config to publish a Worker from `apps/*`. - -Key inputs: - -- `workspaceDir` -- `appDir` -- `installCommand` -- `buildCommand` -- `typecheckCommand` -- `deployCommand` -- `pnpmVersion` - -That path is useful when each Worker app owns its own `component.yaml` and `wrangler.jsonc`, but the -real install and build still need to happen from the monorepo root. - -## Turbo Pages direct upload {#turbo-pages-direct-upload} - -The `cloudflare-pages-turbo` composition follows the same workspace-root install and build pattern, -then direct-uploads an app-specific output directory such as `apps/web-console/dist`. - -Key inputs: - -- `workspaceDir` -- `appDir` -- `installCommand` -- `buildCommand` -- `outputDir` -- `projectName` -- `pnpmVersion` - -That path is useful when the Pages app lives under `apps/`, the component manifest should stay next -to the app, and Gluon should still own the final build artifact. - -## Terraform Git source {#terraform-git-source} - -The `cloudflare-pages-terraform` composition validates the same local site build, then reconciles a -`cloudflare_pages_project` resource that points Cloudflare Pages at this GitHub repository. - -Key inputs: - -- `terraformDir` -- `rootDir` -- `cloudflareBuildCommand` -- `repoOwner` -- `repoName` -- `projectName` - -That path is useful when you want the Pages project itself versioned as infrastructure and let -Cloudflare build from Git after the project is connected. - -## Turbo Pages Terraform {#turbo-pages-terraform} - -The `cloudflare-pages-turbo-terraform` composition keeps the component manifest inside an `apps/*` -directory, performs the local pnpm and Turbo build from the workspace root, and then points Terraform -at an `infra/*` directory that owns the Cloudflare Pages project contract. - -Key inputs: - -- `workspaceDir` -- `appDir` -- `outputDir` -- `destinationDir` -- `rootDir` -- `terraformDir` -- `cloudflareBuildCommand` -- `pnpmVersion` - -That path is useful when platform teams want app-local manifests for discovery and ownership, but -still want the Cloudflare Pages project itself versioned under infrastructure code. - -## Choosing between them - -- Use Wrangler when Gluon should own the build artifact and publish it directly. -- Use Terraform when Gluon should manage the Pages project contract and let Cloudflare own the Git-triggered deploys. -- Use the Turbo variants when the reusable manifest should live inside an app or package directory while the install and build still need the monorepo root. \ No newline at end of file diff --git a/compositions/cloudflare-pages/examples/docs-site/website/docs/getting-started.md b/compositions/cloudflare-pages/examples/docs-site/website/docs/getting-started.md deleted file mode 100644 index d5bc169..0000000 --- a/compositions/cloudflare-pages/examples/docs-site/website/docs/getting-started.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: Getting Started ---- - -## Local build - -Run the docs site the same way the compositions do: - -```bash -cd website -npm ci -npm run docs:build -npm run docs:serve -``` - -The production build is written to `website/docs-build/`. - -## Turbo example builds - -The new `apps/` and `packages/` examples use pnpm and Turbo from the monorepo root: - -```bash -corepack enable -pnpm install --no-frozen-lockfile -pnpm turbo run build --filter=@example/web-console -pnpm turbo run typecheck --filter=@example/api-edge -``` - -Those commands mirror the inputs used by the `cloudflare-worker-turbo`, `cloudflare-pages-turbo`, -`cloudflare-pages-turbo-terraform`, and `turbo-package` compositions. - -## Why Docusaurus here - -Docusaurus is a good fit for this sample because it produces a plain static directory while still -exercising a realistic Node-based documentation toolchain. That makes it useful for both: - -- direct upload workflows that publish prebuilt assets -- Git-connected Pages projects that build inside Cloudflare - -## Credentials used in CI - -The repository expects these secrets in GitHub Actions: - -- `CLOUDFLARE_ACCOUNT_ID` -- `CLOUDFLARE_API_TOKEN` - -The direct-upload job only uses them when it is allowed to publish. The Terraform-backed job uses -the same variables when it needs to plan against or apply Cloudflare resources. - -Worker deploys use the same Cloudflare credentials because Wrangler creates the worker directly from -the app-local manifest under `apps/`. \ No newline at end of file diff --git a/compositions/cloudflare-pages/examples/docs-site/website/docusaurus.config.js b/compositions/cloudflare-pages/examples/docs-site/website/docusaurus.config.js deleted file mode 100644 index edbc568..0000000 --- a/compositions/cloudflare-pages/examples/docs-site/website/docusaurus.config.js +++ /dev/null @@ -1,81 +0,0 @@ -const config = { - title: 'Example Platform Docs', - tagline: 'Static docs deploy paths for Cloudflare Pages through Gluon compositions', - url: 'https://example-platform-docs.pages.dev', - baseUrl: '/', - organizationName: 'sourceplane', - projectName: 'example-platform-repo', - onBrokenLinks: 'throw', - onDuplicateRoutes: 'throw', - markdown: { - hooks: { - onBrokenMarkdownLinks: 'throw', - }, - }, - i18n: { - defaultLocale: 'en', - locales: ['en'], - }, - presets: [ - [ - 'classic', - { - docs: { - path: 'docs', - routeBasePath: '/', - sidebarPath: require.resolve('./sidebars.js'), - }, - blog: false, - theme: { - customCss: require.resolve('./src/css/custom.css'), - }, - }, - ], - ], - themeConfig: { - colorMode: { - defaultMode: 'light', - respectPrefersColorScheme: true, - }, - navbar: { - title: 'Example Platform', - items: [ - { - to: '/', - label: 'Docs', - position: 'left', - }, - { - href: 'https://github.com/sourceplane/example-platform-repo', - label: 'GitHub', - position: 'right', - }, - ], - }, - footer: { - style: 'dark', - links: [ - { - title: 'Paths', - items: [ - { label: 'Wrangler Direct Upload', to: '/deployment-paths#wrangler-direct-upload' }, - { label: 'Terraform Git Source', to: '/deployment-paths#terraform-git-source' }, - ], - }, - { - title: 'Repo', - items: [ - { label: 'Intent', href: 'https://github.com/sourceplane/example-platform-repo/blob/main/intent.yaml' }, - { label: 'Compositions', href: 'https://github.com/sourceplane/example-platform-repo/tree/main/compositions' }, - ], - }, - ], - copyright: `Copyright ${new Date().getFullYear()} sourceplane`, - }, - prism: { - additionalLanguages: ['bash', 'json', 'yaml'], - }, - }, -}; - -module.exports = config; diff --git a/compositions/cloudflare-pages/examples/docs-site/website/package.json b/compositions/cloudflare-pages/examples/docs-site/website/package.json deleted file mode 100644 index 2cf01d8..0000000 --- a/compositions/cloudflare-pages/examples/docs-site/website/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "example-platform-docs", - "version": "1.0.0", - "private": true, - "description": "Minimal Docusaurus site used to verify Cloudflare Pages compositions in example-platform-repo", - "scripts": { - "docs:start": "docusaurus start", - "docs:build": "docusaurus build --out-dir docs-build", - "docs:serve": "docusaurus serve --dir docs-build" - }, - "overrides": { - "webpack": "5.105.4", - "html-webpack-plugin": "5.6.6" - }, - "dependencies": { - "@docusaurus/core": "3.9.2", - "@docusaurus/preset-classic": "3.9.2", - "@mdx-js/react": "3.1.1", - "react": "19.2.4", - "react-dom": "19.2.4" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-pages/examples/docs-site/website/sidebars.js b/compositions/cloudflare-pages/examples/docs-site/website/sidebars.js deleted file mode 100644 index 2aea2f9..0000000 --- a/compositions/cloudflare-pages/examples/docs-site/website/sidebars.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - docsSidebar: ['intro', 'getting-started', 'deployment-paths'], -}; \ No newline at end of file diff --git a/compositions/cloudflare-pages/jobs/cloudflare-pages-verify-deploy.yaml b/compositions/cloudflare-pages/jobs/cloudflare-pages-verify-deploy.yaml new file mode 100644 index 0000000..c32a7ab --- /dev/null +++ b/compositions/cloudflare-pages/jobs/cloudflare-pages-verify-deploy.yaml @@ -0,0 +1,113 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-pages-verify-deploy +spec: + description: Capability-tagged atomic steps for a standalone Cloudflare Pages site + runsOn: ubuntu-22.04 + timeout: 25m + retries: 0 + + labels: + scope: delivery + + capabilities: + - cloudflare-pages.setup-node + - cloudflare-pages.install + - cloudflare-pages.build + - cloudflare-pages.verify-output + - cloudflare-pages.provision + - cloudflare-pages.deploy + - cloudflare-pages.smoke + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-pages.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: install-site-dependencies + name: install-site-dependencies + capability: cloudflare-pages.install + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: build-site + name: build-site + capability: cloudflare-pages.build + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.buildCommand }}" + onFailure: stop + + - id: verify-build-output + name: verify-build-output + capability: cloudflare-pages.verify-output + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: | + test -d "{{ .parameters.outputDir }}" + find "{{ .parameters.outputDir }}" -maxdepth 2 -type f | head -n 20 + onFailure: stop + + - id: ensure-pages-project + name: ensure-pages-project + capability: cloudflare-pages.provision + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + + api_root="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects" + response_file="${RUNNER_TEMP:-/tmp}/cloudflare-pages-project.json" + status="$(curl -sS -o "${response_file}" -w "%{http_code}" \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json" \ + "${api_root}/{{ .parameters.projectName }}")" + + if [ "${status}" = "200" ]; then + echo "Pages project {{ .parameters.projectName }} already exists." + elif [ "${status}" = "404" ]; then + curl -sS --fail -X POST \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json" \ + --data '{"name":"{{ .parameters.projectName }}","production_branch":"{{ .parameters.deployBranch }}"}' \ + "${api_root}" >/dev/null + echo "Created Pages project {{ .parameters.projectName }}." + else + cat "${response_file}" + exit 1 + fi + + curl -sS --fail -X PATCH \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json" \ + --data '{"production_branch":"{{ .parameters.deployBranch }}"}' \ + "${api_root}/{{ .parameters.projectName }}" >/dev/null + onFailure: stop + + - id: deploy-pages-artifact + name: deploy-pages-artifact + capability: cloudflare-pages.deploy + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + + npx wrangler pages deploy "{{ .parameters.outputDir }}" \ + --project-name "{{ .parameters.projectName }}" \ + --branch "{{ .parameters.deployBranch }}" + onFailure: stop + + - id: smoke + name: smoke + capability: cloudflare-pages.smoke + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.smokeCommand }}" + onFailure: stop diff --git a/compositions/cloudflare-pages/profiles/cloudflare-pages-deploy.yaml b/compositions/cloudflare-pages/profiles/cloudflare-pages-deploy.yaml new file mode 100644 index 0000000..aa53d2b --- /dev/null +++ b/compositions/cloudflare-pages/profiles/cloudflare-pages-deploy.yaml @@ -0,0 +1,21 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-deploy +spec: + description: Full pipeline including provisioning, deployment, and smoke test + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-pages.setup-node + - cloudflare-pages.install + - cloudflare-pages.build + - cloudflare-pages.verify-output + - cloudflare-pages.provision + - cloudflare-pages.deploy + - cloudflare-pages.smoke diff --git a/compositions/cloudflare-pages/profiles/cloudflare-pages-pull-request.yaml b/compositions/cloudflare-pages/profiles/cloudflare-pages-pull-request.yaml new file mode 100644 index 0000000..28145ae --- /dev/null +++ b/compositions/cloudflare-pages/profiles/cloudflare-pages-pull-request.yaml @@ -0,0 +1,14 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-pull-request +spec: + description: Fast PR validation with build and output verification + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-pages.setup-node + - cloudflare-pages.install + - cloudflare-pages.build + - cloudflare-pages.verify-output diff --git a/compositions/cloudflare-pages/profiles/cloudflare-pages-verify.yaml b/compositions/cloudflare-pages/profiles/cloudflare-pages-verify.yaml new file mode 100644 index 0000000..711344b --- /dev/null +++ b/compositions/cloudflare-pages/profiles/cloudflare-pages-verify.yaml @@ -0,0 +1,14 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-pages-verify +spec: + description: Full non-mutating verification of Pages site build + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-pages.setup-node + - cloudflare-pages.install + - cloudflare-pages.build + - cloudflare-pages.verify-output diff --git a/compositions/cloudflare-pages/schema.yaml b/compositions/cloudflare-pages/schema.yaml new file mode 100644 index 0000000..08f5273 --- /dev/null +++ b/compositions/cloudflare-pages/schema.yaml @@ -0,0 +1,59 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-pages-component +spec: + type: cloudflare-pages + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Pages Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-pages + parameters: + type: object + required: + - nodeVersion + - appDir + - installCommand + - buildCommand + - outputDir + - projectName + properties: + nodeVersion: + type: string + + appDir: + type: string + description: Path from the component job path to the Pages app directory + + outputDir: + type: string + description: Build output directory relative to appDir + + projectName: + type: string + description: Cloudflare Pages project name + + deployBranch: + type: string + description: Branch name passed to wrangler pages deploy + default: main + + installCommand: + type: string + buildCommand: + type: string + smokeCommand: + type: string + default: "echo 'No smoke test configured.'" + additionalProperties: false + additionalProperties: true diff --git a/compositions/cloudflare-pages/tests/smoke/component.yaml b/compositions/cloudflare-pages/tests/smoke/component.yaml index 2a301a5..1b25be3 100644 --- a/compositions/cloudflare-pages/tests/smoke/component.yaml +++ b/compositions/cloudflare-pages/tests/smoke/component.yaml @@ -6,18 +6,22 @@ metadata: spec: type: cloudflare-pages + lifecycle: production + owner: platform domain: platform-docs + path: website subscribe: environments: - - production - inputs: - siteDir: . + - name: production + profile: deploy + parameters: + nodeVersion: "20" + appDir: . installCommand: npm ci buildCommand: npm run docs:build outputDir: docs-build projectName: example-platform-docs-wrangler - nodeVersion: "20" - productionBranch: main + deployBranch: main labels: team: platform layer: delivery diff --git a/compositions/cloudflare-worker-turbo/README.md b/compositions/cloudflare-worker-turbo/README.md index b6b5e5d..03cd92d 100644 --- a/compositions/cloudflare-worker-turbo/README.md +++ b/compositions/cloudflare-worker-turbo/README.md @@ -4,24 +4,49 @@ ## Purpose -Verify a Cloudflare Worker app and deploy it from the production branch +Verify a Cloudflare Worker package inside a pnpm + Turborepo monorepo and deploy +it. On top of the plain `cloudflare-worker` lifecycle this composition adds +deploy-time wiring: a committed wrangler template can be rendered from a +Secrets Manager wiring document before deploy, and managed runtime secrets can +be hydrated from an escrow after deploy. ## Contract - **Type:** `cloudflare-worker-turbo` - **Path:** `compositions/cloudflare-worker-turbo` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/api-edge` - -## Test fixtures - -- `tests/smoke` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify-deploy` (default) — `jobs/cloudflare-worker-turbo-verify-deploy.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `pnpmVersion`, `workspaceDir`, + `appDir`, `turboFilter`, `wranglerConfig` (default `wrangler.jsonc`) +- **Optional command parameters:** `installCommand` (default + `pnpm install --frozen-lockfile`), `buildCommand`, `typecheckCommand`, + `dryRunCommand`, `preDeployCommand`, `migrationCommand`, `deployCommand`, + `smokeCommand` +- **Optional wiring parameters:** `wranglerTemplate` (empty means a legacy + committed config and the wiring steps no-op), `wiringComponents`, + `wiringEnvs` (default `stage,prod`), `wiringFixture` (default + `wiring.fixture.json`), `secretsWorker`, `awsAccountId`, `awsRegion` (default + `us-east-1`), `orgName`, `owner`, `repo` + +## Profiles + +Each file in `profiles/` selects steps from the job by capability. + +| Profile | Steps | +| ------------------ | ----- | +| `pull-request` | setup-node → setup-pnpm → install → verify-structure → build → typecheck | +| `verify` (default) | `pull-request` steps + wire-fixture (offline render) and deploy-dry-run — never needs cloud credentials | +| `deploy` | setup → install → verify-structure → wire-fixture → build → typecheck → wire-credentials → wire-live → pre-deploy → migrate → deploy → secrets-live → smoke; requires approval and a clean git tree | + +`wire-credentials` and `wire-live` are deploy-only by design so verify lanes stay +credential-free; both no-op for components without a `wranglerTemplate`, and +`secrets-live` no-ops for components without `secretsWorker`. ## Verification -`./scripts/verify-composition.sh cloudflare-worker-turbo` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `cloudflare-worker-turbo` exports from the packed artifact. diff --git a/compositions/cloudflare-worker-turbo/composition.yaml b/compositions/cloudflare-worker-turbo/composition.yaml new file mode 100644 index 0000000..2237a9f --- /dev/null +++ b/compositions/cloudflare-worker-turbo/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-worker-turbo +spec: + type: cloudflare-worker-turbo + description: Cloudflare Worker with Turborepo build, verify, and deploy pipeline + + schemaRef: + name: cloudflare-worker-turbo-component + + defaultJob: verify-deploy + defaultProfile: verify + + jobs: + - name: verify-deploy + templateRef: + name: cloudflare-worker-turbo-verify-deploy + + profiles: + - name: pull-request + profileRef: + name: cloudflare-worker-turbo-pull-request + - name: verify + profileRef: + name: cloudflare-worker-turbo-verify + - name: deploy + profileRef: + name: cloudflare-worker-turbo-deploy diff --git a/compositions/cloudflare-worker-turbo/compositions.yaml b/compositions/cloudflare-worker-turbo/compositions.yaml deleted file mode 100644 index cca06fc..0000000 --- a/compositions/cloudflare-worker-turbo/compositions.yaml +++ /dev/null @@ -1,159 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: cloudflare-worker-turbo -spec: - type: cloudflare-worker-turbo - description: Verify a Cloudflare Worker app and deploy it from the production branch - defaultJob: verify-deploy-cloudflare-worker-turbo - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Cloudflare Worker Turbo Component - description: Schema for Cloudflare Workers in a pnpm and Turbo monorepo - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: cloudflare-worker-turbo - description: Component type identifier - inputs: - type: object - required: - - nodeVersion - - pnpmVersion - - productionBranch - properties: - nodeVersion: - type: string - description: Node.js version - pnpmVersion: - type: string - description: pnpm version - productionBranch: - type: string - description: Branch that is allowed to deploy the Worker app - wranglerConfig: - type: string - description: Wrangler config filename (defaults to detecting wrangler.jsonc or wrangler.toml) - preBuildCommand: - type: string - description: Optional command to run before the build (e.g. codegen, schema generation) - buildCommand: - type: string - description: Override the default turbo build command - typecheckCommand: - type: string - description: Override the default turbo typecheck command - preDeployCommand: - type: string - description: Command to run before deploy (e.g. resource provisioning, D1 database creation) - migrationCommand: - type: string - description: Command to run D1 migrations or other pre-deploy schema changes - deployCommand: - type: string - description: Override the default deploy command - smokeCommand: - type: string - description: Post-deploy verification command (e.g. curl the live endpoint) - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-deploy-cloudflare-worker-turbo - description: Verify a Worker app and deploy it from the production branch - runsOn: ubuntu-22.04 - timeout: 30m - retries: 0 - labels: - scope: delivery - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - id: setup-pnpm - name: setup-pnpm - use: pnpm/action-setup@v4 - with: - version: "{{.pnpmVersion}}" - - name: install-workspace-dependencies - run: pnpm install --no-frozen-lockfile - onFailure: stop - - name: pre-build - shell: bash - run: | - {{if .preBuildCommand}} - {{.preBuildCommand}} - {{else}} - echo "Skipping pre-build." - {{end}} - onFailure: stop - - name: verify-worker-structure - shell: bash - run: | - test -f package.json - {{if .wranglerConfig}} - test -f "{{.wranglerConfig}}" - {{else}} - test -f wrangler.jsonc || test -f wrangler.toml - {{end}} - onFailure: stop - - name: build-worker - run: "{{if .buildCommand}}{{.buildCommand}}{{else}}pnpm exec turbo run build --filter=./{{end}}" - onFailure: stop - - name: typecheck-worker - run: "{{if .typecheckCommand}}{{.typecheckCommand}}{{else}}pnpm exec turbo run typecheck --filter=./{{end}}" - onFailure: stop - - name: deploy-worker - shell: bash - run: | - if [ "{{.Environment}}" = "dev" ]; then - echo "::notice::DRY-RUN: Running wrangler deploy --dry-run for {{.Component}} in dev environment." - pnpm exec wrangler deploy --dry-run - exit 0 - fi - - if [ "{{.Environment}}" != "production" ] || [ "${GITHUB_REF:-}" != "refs/heads/{{.productionBranch}}" ]; then - echo "::notice::SKIPPED: Cloudflare Worker deploy for {{.Component}} in {{.Environment}} on ${GITHUB_REF:-local} (not production branch)." - exit 0 - fi - - echo "::group::Validate Cloudflare credentials" - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deploy}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deploy}" - echo "CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN are set." - echo "::endgroup::" - - {{if .preDeployCommand}} - echo "::group::Pre-deploy" - {{.preDeployCommand}} - echo "::endgroup::" - {{end}} - - {{if .migrationCommand}} - echo "::group::Run migrations" - {{.migrationCommand}} - echo "::endgroup::" - {{end}} - - echo "::group::Deploy Worker" - echo "::notice::LIVE DEPLOY: Deploying {{.Component}} to Cloudflare from ${GITHUB_REF:-}." - {{if .deployCommand}}{{.deployCommand}}{{else}}pnpm run deploy{{end}} - echo "::endgroup::" - - {{if .smokeCommand}} - echo "::group::Post-deploy smoke test" - {{.smokeCommand}} - echo "::endgroup::" - {{end}} - - echo "::notice::DEPLOY SUCCESS: {{.Component}} deployed to Cloudflare." - onFailure: stop diff --git a/compositions/cloudflare-worker-turbo/examples/README.md b/compositions/cloudflare-worker-turbo/examples/README.md deleted file mode 100644 index 7cc7512..0000000 --- a/compositions/cloudflare-worker-turbo/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for cloudflare-worker-turbo - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `cloudflare-worker-turbo` looks inside a consumer repository. - -- `examples/api-edge` diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/component.yaml b/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/component.yaml deleted file mode 100644 index 63644a4..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/component.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: api-edge-worker - -spec: - type: cloudflare-worker-turbo - domain: platform-runtime - subscribe: - environments: - - dev - - staging - - production - inputs: - nodeVersion: "20" - pnpmVersion: "10.12.1" - productionBranch: main - # Optional: specify wrangler config file explicitly - # wranglerConfig: wrangler.jsonc - # Optional: run D1 migrations before deploy - # migrationCommand: "pnpm exec wrangler d1 migrations apply my-db --remote" - # Optional: provision resources before deploy - # preDeployCommand: "./scripts/bootstrap-cloudflare.sh" - # Optional: verify live endpoint after deploy - # smokeCommand: "curl -sf https://my-api.workers.dev/health" - labels: - team: platform - layer: runtime - surface: api - runtime: cloudflare diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/package.json b/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/package.json deleted file mode 100644 index 392629a..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@example/api-edge", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "build": "tsc -p tsconfig.json --noEmit", - "typecheck": "tsc -p tsconfig.json --noEmit", - "deploy": "wrangler deploy --config wrangler.jsonc" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/src/index.ts b/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/src/index.ts deleted file mode 100644 index 371079f..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -interface Env { - API_NAME?: string; -} - -export default { - async fetch(request: Request, env: Env): Promise { - const url = new URL(request.url); - - return Response.json({ - ok: true, - path: url.pathname, - service: env.API_NAME ?? "api-edge", - }); - }, -}; \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/tsconfig.json b/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/tsconfig.json deleted file mode 100644 index 32a6156..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": [ - "src/**/*.ts" - ] -} \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/wrangler.jsonc b/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/wrangler.jsonc deleted file mode 100644 index 637ddf9..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/apps/api-edge/wrangler.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "../../node_modules/wrangler/config-schema.json", - "name": "example-platform-api-edge", - "main": "src/index.ts", - "compatibility_date": "2026-04-25", - "workers_dev": true, - "observability": { - "enabled": true - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/package.json b/compositions/cloudflare-worker-turbo/examples/api-edge/package.json deleted file mode 100644 index d65acec..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "example-platform-repo", - "private": true, - "version": "1.0.0", - "description": "Turbo-style Cloudflare deployment examples for gluon component discovery", - "packageManager": "pnpm@10.12.1", - "scripts": { - "build": "turbo run build", - "typecheck": "turbo run typecheck", - "deploy": "turbo run deploy" - }, - "devDependencies": { - "turbo": "2.5.8", - "typescript": "5.9.3", - "wrangler": "4.13.2" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/pnpm-workspace.yaml b/compositions/cloudflare-worker-turbo/examples/api-edge/pnpm-workspace.yaml deleted file mode 100644 index c7eaed9..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - apps/* - - packages/* \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/tsconfig.base.json b/compositions/cloudflare-worker-turbo/examples/api-edge/tsconfig.base.json deleted file mode 100644 index e7910f3..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/tsconfig.base.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "noEmit": true, - "lib": [ - "ES2022", - "DOM" - ] - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/examples/api-edge/turbo.json b/compositions/cloudflare-worker-turbo/examples/api-edge/turbo.json deleted file mode 100644 index f24d8d7..0000000 --- a/compositions/cloudflare-worker-turbo/examples/api-edge/turbo.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://turborepo.com/schema.json", - "tasks": { - "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**", - ".wrangler/**" - ] - }, - "typecheck": { - "dependsOn": [ - "^typecheck" - ], - "outputs": [] - }, - "deploy": { - "dependsOn": [ - "build" - ], - "cache": false, - "outputs": [] - } - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml b/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml new file mode 100644 index 0000000..fac23d5 --- /dev/null +++ b/compositions/cloudflare-worker-turbo/jobs/cloudflare-worker-turbo-verify-deploy.yaml @@ -0,0 +1,219 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-worker-turbo-verify-deploy +spec: + description: Capability-tagged atomic steps for Cloudflare Worker with Turborepo + runsOn: ubuntu-22.04 + timeout: 30m + retries: 0 + + labels: + scope: delivery + + capabilities: + - cloudflare-worker-turbo.setup-node + - cloudflare-worker-turbo.setup-pnpm + - cloudflare-worker-turbo.install + - cloudflare-worker-turbo.verify-structure + - cloudflare-worker-turbo.wire-fixture + - cloudflare-worker-turbo.build + - cloudflare-worker-turbo.typecheck + - cloudflare-worker-turbo.deploy-dry-run + - cloudflare-worker-turbo.wire-credentials + - cloudflare-worker-turbo.wire-live + - cloudflare-worker-turbo.pre-deploy + - cloudflare-worker-turbo.migrate + - cloudflare-worker-turbo.deploy + - cloudflare-worker-turbo.secrets-live + - cloudflare-worker-turbo.smoke + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-worker-turbo.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: setup-pnpm + name: setup-pnpm + capability: cloudflare-worker-turbo.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{ .parameters.pnpmVersion }}" + + - id: install-workspace-dependencies + name: install-workspace-dependencies + capability: cloudflare-worker-turbo.install + shell: bash + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: verify-worker-structure + name: verify-worker-structure + capability: cloudflare-worker-turbo.verify-structure + shell: bash + run: | + test -f package.json + {{- if .parameters.wranglerTemplate }} + # BF6: templated worker — the committed artifact is the template; the + # deployable config is rendered by wire-fixture/wire-live. Guard: a + # template must never carry committed 32-hex resource IDs. + test -f "{{ .parameters.wranglerTemplate }}" + if grep -nE '"id":[[:space:]]*"[0-9a-f]{32}"' "{{ .parameters.wranglerTemplate }}"; then + echo "verify-worker-structure: committed resource IDs found in {{ .parameters.wranglerTemplate }} — use @@wiring(...)@@ tokens" >&2 + exit 1 + fi + {{- else }} + test -f "{{ .parameters.wranglerConfig }}" + {{- end }} + onFailure: stop + + - id: wire-fixture + name: wire-fixture + capability: cloudflare-worker-turbo.wire-fixture + shell: bash + run: | + {{- if .parameters.wranglerTemplate }} + node {{ .parameters.workspaceDir }}/tooling/wire/render.mjs \ + --template "{{ .parameters.wranglerTemplate }}" \ + --out "{{ .parameters.wranglerConfig }}" \ + --map "{{ .parameters.wiringFixture }}" + {{- else }} + echo "wire-fixture: component is not wiring-templated; skipping." + {{- end }} + onFailure: stop + + - id: build-worker + name: build-worker + capability: cloudflare-worker-turbo.build + shell: bash + run: "{{ .parameters.buildCommand }}" + onFailure: stop + + - id: typecheck-worker + name: typecheck-worker + capability: cloudflare-worker-turbo.typecheck + shell: bash + run: "{{ .parameters.typecheckCommand }}" + onFailure: stop + + - id: deploy-dry-run + name: deploy-dry-run + capability: cloudflare-worker-turbo.deploy-dry-run + shell: bash + run: "pnpm exec wrangler deploy --dry-run --config {{ .parameters.wranglerConfig }} --env {{ .orun.environment.name }}" + onFailure: stop + + - id: wire-credentials + name: wire-credentials + capability: cloudflare-worker-turbo.wire-credentials + use: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan" + aws-region: "{{.parameters.awsRegion}}" + audience: sts.amazonaws.com + onFailure: stop + + - id: wire-live + name: wire-live + capability: cloudflare-worker-turbo.wire-live + shell: bash + run: | + {{- if .parameters.wranglerTemplate }} + set -euo pipefail + wiring_dir=$(mktemp -d) + for comp in $(echo "{{ .parameters.wiringComponents }}" | tr ',' ' '); do + for wenv in $(echo "{{ .parameters.wiringEnvs }}" | tr ',' ' '); do + aws secretsmanager get-secret-value \ + --secret-id "{{ .parameters.orgName }}/{{ .parameters.repo }}/${comp}/${wenv}" \ + --query SecretString --output text > "${wiring_dir}/${comp}__${wenv}.json" + done + done + node {{ .parameters.workspaceDir }}/tooling/wire/render.mjs \ + --template "{{ .parameters.wranglerTemplate }}" \ + --out "{{ .parameters.wranglerConfig }}" \ + --secrets-dir "${wiring_dir}" + {{- else }} + echo "wire-live: component is not wiring-templated; skipping." + {{- end }} + onFailure: stop + + - id: pre-deploy + name: pre-deploy + capability: cloudflare-worker-turbo.pre-deploy + shell: bash + run: "{{ .parameters.preDeployCommand }}" + onFailure: stop + + - id: migrate + name: migrate + capability: cloudflare-worker-turbo.migrate + shell: bash + run: "{{ .parameters.migrationCommand }}" + onFailure: stop + + - id: deploy + name: deploy + capability: cloudflare-worker-turbo.deploy + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + pnpm exec wrangler deploy --config {{ .parameters.wranglerConfig }} --env {{ .orun.environment.name }} + onFailure: stop + + - id: secrets-live + name: secrets-live + capability: cloudflare-worker-turbo.secrets-live + shell: bash + run: | + {{- if .parameters.secretsWorker }} + # SS2: hydrate this worker's runtime secrets from the AWS Secrets + # Manager escrow document (//worker-secrets/). Runs + # after deploy so a first-boot worker exists before secrets are + # pushed; `wrangler secret bulk` rolls a new version immediately, so + # smoke still observes the synced state. No escrow document at all = + # pre-SS3 state: existing manually-put secrets are left untouched. + set -euo pipefail + env_name="{{ .orun.environment.name }}" + escrow_id="{{ .parameters.orgName }}/{{ .parameters.repo }}/worker-secrets/${env_name}" + record_id="{{ .parameters.orgName }}/{{ .parameters.repo }}/worker-secrets-fingerprints/${env_name}" + work_dir=$(mktemp -d) + if ! aws secretsmanager get-secret-value --secret-id "${escrow_id}" \ + --query SecretString --output text > "${work_dir}/escrow.json" 2>/dev/null; then + echo "secrets-live: no escrow document at ${escrow_id} (SS3 not seeded) — leaving existing worker secrets untouched." + exit 0 + fi + aws secretsmanager get-secret-value --secret-id "${record_id}" \ + --query SecretString --output text > "${work_dir}/record.json" 2>/dev/null \ + || echo '{}' > "${work_dir}/record.json" + node {{ .parameters.workspaceDir }}/tooling/secrets-sync/sync.mjs \ + --manifest {{ .parameters.workspaceDir }}/tooling/secrets-sync/secrets.manifest.json \ + --worker "{{ .parameters.secretsWorker }}" \ + --env "${env_name}" \ + --escrow "${work_dir}/escrow.json" \ + --record "${work_dir}/record.json" \ + --out-bulk "${work_dir}/bulk.json" \ + --out-record "${work_dir}/record.next.json" + if [ "$(cat "${work_dir}/bulk.json")" != "{}" ]; then + pnpm exec wrangler secret bulk "${work_dir}/bulk.json" \ + --config {{ .parameters.wranglerConfig }} --env "${env_name}" + aws secretsmanager put-secret-value --secret-id "${record_id}" \ + --secret-string "file://${work_dir}/record.next.json" >/dev/null 2>&1 \ + || aws secretsmanager create-secret --name "${record_id}" \ + --secret-string "file://${work_dir}/record.next.json" >/dev/null + fi + rm -rf "${work_dir}" + {{- else }} + echo "secrets-live: component has no managed runtime secrets; skipping." + {{- end }} + onFailure: stop + + - id: smoke + name: smoke + capability: cloudflare-worker-turbo.smoke + shell: bash + run: "{{ .parameters.smokeCommand }}" + onFailure: stop diff --git a/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-deploy.yaml b/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-deploy.yaml new file mode 100644 index 0000000..493b08a --- /dev/null +++ b/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-deploy.yaml @@ -0,0 +1,36 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-worker-turbo-deploy +spec: + description: Build, validate, migrate, deploy, and smoke test a Cloudflare Worker + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-worker-turbo.setup-node + - cloudflare-worker-turbo.setup-pnpm + - cloudflare-worker-turbo.install + - cloudflare-worker-turbo.verify-structure + # BF6: templated workers have no committed wrangler.jsonc — render from + # the fixture so build/typecheck have a config; wire-live re-renders + # with real IDs before deploy (no-op for non-templated workers). + - cloudflare-worker-turbo.wire-fixture + - cloudflare-worker-turbo.build + - cloudflare-worker-turbo.typecheck + # BF6: resolve binding IDs from the Secrets Manager wiring manifest at + # deploy time (no-op for workers without a wrangler template). + - cloudflare-worker-turbo.wire-credentials + - cloudflare-worker-turbo.wire-live + - cloudflare-worker-turbo.pre-deploy + - cloudflare-worker-turbo.migrate + - cloudflare-worker-turbo.deploy + # SS2: hydrate runtime secrets from the worker-secrets escrow after + # deploy (first boot creates the worker first); no-op for components + # without secretsWorker, clean skip until the escrow is seeded (SS3). + - cloudflare-worker-turbo.secrets-live + - cloudflare-worker-turbo.smoke diff --git a/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-pull-request.yaml b/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-pull-request.yaml new file mode 100644 index 0000000..03c82d1 --- /dev/null +++ b/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-pull-request.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-worker-turbo-pull-request +spec: + description: Fast PR validation for a Cloudflare Worker package + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-worker-turbo.setup-node + - cloudflare-worker-turbo.setup-pnpm + - cloudflare-worker-turbo.install + - cloudflare-worker-turbo.verify-structure + - cloudflare-worker-turbo.build + - cloudflare-worker-turbo.typecheck diff --git a/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-verify.yaml b/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-verify.yaml new file mode 100644 index 0000000..390f9b8 --- /dev/null +++ b/compositions/cloudflare-worker-turbo/profiles/cloudflare-worker-turbo-verify.yaml @@ -0,0 +1,20 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-worker-turbo-verify +spec: + description: Full non-mutating verification, including Wrangler dry-run + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-worker-turbo.setup-node + - cloudflare-worker-turbo.setup-pnpm + - cloudflare-worker-turbo.install + - cloudflare-worker-turbo.verify-structure + # Offline fixture render only — verify lanes must never need cloud + # credentials (BF6 D5 guard); wire-credentials/wire-live are deploy-only. + - cloudflare-worker-turbo.wire-fixture + - cloudflare-worker-turbo.build + - cloudflare-worker-turbo.typecheck + - cloudflare-worker-turbo.deploy-dry-run diff --git a/compositions/cloudflare-worker-turbo/schema.yaml b/compositions/cloudflare-worker-turbo/schema.yaml new file mode 100644 index 0000000..d1892bc --- /dev/null +++ b/compositions/cloudflare-worker-turbo/schema.yaml @@ -0,0 +1,108 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-worker-turbo-component +spec: + type: cloudflare-worker-turbo + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Worker Turbo Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-worker-turbo + parameters: + type: object + required: + - nodeVersion + - pnpmVersion + - workspaceDir + - appDir + - turboFilter + - wranglerConfig + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + + workspaceDir: + type: string + description: Path from the component job path to the monorepo root + + appDir: + type: string + description: Path from the component job path to the Worker app directory + + turboFilter: + type: string + description: Turborepo filter for this Worker package + + wranglerConfig: + type: string + default: wrangler.jsonc + + # --- BF6 deploy-time wiring (all optional; empty wranglerTemplate = legacy committed config) --- + wranglerTemplate: + type: string + default: "" + description: Committed wrangler template with @@wiring(...)@@ tokens; when set, wranglerConfig is rendered, never committed + wiringComponents: + type: string + default: "" + description: Comma-separated infra components whose Secrets Manager wiring documents resolve the template tokens + wiringEnvs: + type: string + default: "stage,prod" + description: Comma-separated environments fetched by wire-live (template may reference several env sections) + wiringFixture: + type: string + default: wiring.fixture.json + description: Committed placeholder wiring map used for offline verify/dry-run rendering + secretsWorker: + type: string + default: "" + description: Manifest key in tooling/secrets-sync/secrets.manifest.json naming this worker's managed runtime secrets; empty = the secrets-live step skips (SS2) + awsAccountId: + type: string + description: AWS account ID hosting the GitHub-OIDC role wire-live assumes to read wiring secrets + awsRegion: + type: string + default: us-east-1 + orgName: + type: string + owner: + type: string + repo: + type: string + + installCommand: + type: string + default: pnpm install --frozen-lockfile + + buildCommand: + type: string + typecheckCommand: + type: string + dryRunCommand: + type: string + preDeployCommand: + type: string + default: "echo 'No pre-deploy step configured.'" + migrationCommand: + type: string + default: "echo 'No migrations configured.'" + deployCommand: + type: string + smokeCommand: + type: string + default: "echo 'No smoke test configured.'" + additionalProperties: false + additionalProperties: true diff --git a/compositions/cloudflare-worker-turbo/tests/README.md b/compositions/cloudflare-worker-turbo/tests/README.md deleted file mode 100644 index 5322964..0000000 --- a/compositions/cloudflare-worker-turbo/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for cloudflare-worker-turbo - -These files provide contract or smoke fixtures that CI can inspect for `cloudflare-worker-turbo` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/cloudflare-worker-turbo/tests/smoke/component.yaml b/compositions/cloudflare-worker-turbo/tests/smoke/component.yaml deleted file mode 100644 index f14d397..0000000 --- a/compositions/cloudflare-worker-turbo/tests/smoke/component.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: api-edge-worker - -spec: - type: cloudflare-worker-turbo - domain: platform-runtime - subscribe: - environments: - - dev - - staging - - production - inputs: - nodeVersion: "20" - pnpmVersion: "10.12.1" - productionBranch: main - labels: - team: platform - layer: runtime - surface: api - runtime: cloudflare diff --git a/compositions/cloudflare-worker/README.md b/compositions/cloudflare-worker/README.md index 8408509..369d571 100644 --- a/compositions/cloudflare-worker/README.md +++ b/compositions/cloudflare-worker/README.md @@ -4,24 +4,40 @@ ## Purpose -Verify a Cloudflare Worker app and deploy it from the production branch +Verify a standalone Cloudflare Worker package — install, structure check +(`package.json` plus `wranglerConfig`), build, typecheck — and deploy it with +the component's own `deployCommand`, which runs with `CLOUDFLARE_ACCOUNT_ID` and +`CLOUDFLARE_API_TOKEN` asserted present. + +For a Worker inside a pnpm + Turborepo monorepo use `cloudflare-worker-turbo`. ## Contract - **Type:** `cloudflare-worker` - **Path:** `compositions/cloudflare-worker` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/identity-worker` - -## Test fixtures - -- `tests/smoke` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify-deploy` (default) — `jobs/cloudflare-worker-verify-deploy.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `installCommand`, `buildCommand`, + `deployCommand`, `wranglerConfig` (default `wrangler.jsonc`) +- **Optional parameters:** `pnpmVersion`, `appDir` (default `.`), + `typecheckCommand`, `dryRunCommand`, `preDeployCommand`, `migrationCommand`, + `smokeCommand` + +## Profiles + +Each file in `profiles/` selects steps from the job by capability. + +| Profile | Steps | +| ------------------ | ----- | +| `pull-request` | setup-node → install → verify-structure → build → typecheck | +| `verify` (default) | `pull-request` steps + deploy-dry-run | +| `deploy` | `pull-request` steps + pre-deploy → migrate → deploy → smoke; requires approval and a clean git tree | ## Verification -`./scripts/verify-composition.sh cloudflare-worker` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `cloudflare-worker` exports from the packed artifact. diff --git a/compositions/cloudflare-worker/composition.yaml b/compositions/cloudflare-worker/composition.yaml new file mode 100644 index 0000000..440fa6d --- /dev/null +++ b/compositions/cloudflare-worker/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-worker +spec: + type: cloudflare-worker + description: Cloudflare Worker build, verify, and deploy pipeline + + schemaRef: + name: cloudflare-worker-component + + defaultJob: verify-deploy + defaultProfile: verify + + jobs: + - name: verify-deploy + templateRef: + name: cloudflare-worker-verify-deploy + + profiles: + - name: pull-request + profileRef: + name: cloudflare-worker-pull-request + - name: verify + profileRef: + name: cloudflare-worker-verify + - name: deploy + profileRef: + name: cloudflare-worker-deploy diff --git a/compositions/cloudflare-worker/compositions.yaml b/compositions/cloudflare-worker/compositions.yaml deleted file mode 100644 index d6278e4..0000000 --- a/compositions/cloudflare-worker/compositions.yaml +++ /dev/null @@ -1,158 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: cloudflare-worker -spec: - type: cloudflare-worker - description: Verify a Cloudflare Worker app and deploy it from the production branch - defaultJob: verify-deploy-cloudflare-worker - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Cloudflare Worker Component - description: Schema for Cloudflare Workers with explicit build commands - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: cloudflare-worker - description: Component type identifier - inputs: - type: object - required: - - installCommand - - buildCommand - - deployCommand - - nodeVersion - - productionBranch - properties: - installCommand: - type: string - description: Command used to install dependencies - buildCommand: - type: string - description: Command used to build the Worker - typecheckCommand: - type: string - description: Command used to typecheck the Worker (optional) - deployCommand: - type: string - description: Command used to deploy the Worker to Cloudflare - nodeVersion: - type: string - description: Node.js version - pnpmVersion: - type: string - description: pnpm version (optional, installed via npm if provided) - productionBranch: - type: string - description: Branch that is allowed to deploy the Worker app - wranglerConfig: - type: string - description: Wrangler config filename (defaults to detecting wrangler.jsonc or wrangler.toml) - preDeployCommand: - type: string - description: Command to run before deploy (e.g. resource provisioning, D1 database creation) - migrationCommand: - type: string - description: Command to run D1 migrations or other pre-deploy schema changes - smokeCommand: - type: string - description: Post-deploy verification command (e.g. curl the live endpoint) - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-deploy-cloudflare-worker - description: Verify a Worker app and deploy it from the production branch - runsOn: ubuntu-22.04 - timeout: 30m - retries: 0 - labels: - scope: delivery - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - name: install-dependencies - shell: bash - run: | - {{if .pnpmVersion}} - npm install -g pnpm@{{.pnpmVersion}} - {{end}} - {{.installCommand}} - onFailure: stop - - name: verify-worker-structure - shell: bash - run: | - test -f package.json - {{if .wranglerConfig}} - test -f "{{.wranglerConfig}}" - {{else}} - test -f wrangler.jsonc || test -f wrangler.toml - {{end}} - onFailure: stop - - name: build-worker - run: "{{.buildCommand}}" - onFailure: stop - - name: typecheck-worker - shell: bash - run: | - {{if .typecheckCommand}} - {{.typecheckCommand}} - {{else}} - echo "Skipping typecheck (not configured)." - {{end}} - onFailure: stop - - name: deploy-worker - shell: bash - run: | - if [ "{{.Environment}}" = "dev" ]; then - echo "::notice::DRY-RUN: Running wrangler deploy --dry-run for {{.Component}} in dev environment." - pnpm exec wrangler deploy --dry-run - exit 0 - fi - - if [ "{{.Environment}}" != "production" ] || [ "${GITHUB_REF:-}" != "refs/heads/{{.productionBranch}}" ]; then - echo "::notice::SKIPPED: Cloudflare Worker deploy for {{.Component}} in {{.Environment}} on ${GITHUB_REF:-local} (not production branch)." - exit 0 - fi - - echo "::group::Validate Cloudflare credentials" - : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required for deploy}" - : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required for deploy}" - echo "CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN are set." - echo "::endgroup::" - - {{if .preDeployCommand}} - echo "::group::Pre-deploy" - {{.preDeployCommand}} - echo "::endgroup::" - {{end}} - - {{if .migrationCommand}} - echo "::group::Run migrations" - {{.migrationCommand}} - echo "::endgroup::" - {{end}} - - echo "::group::Deploy Worker" - echo "::notice::LIVE DEPLOY: Deploying {{.Component}} to Cloudflare from ${GITHUB_REF:-}." - {{.deployCommand}} - echo "::endgroup::" - - {{if .smokeCommand}} - echo "::group::Post-deploy smoke test" - {{.smokeCommand}} - echo "::endgroup::" - {{end}} - - echo "::notice::DEPLOY SUCCESS: {{.Component}} deployed to Cloudflare." - onFailure: stop diff --git a/compositions/cloudflare-worker/examples/README.md b/compositions/cloudflare-worker/examples/README.md deleted file mode 100644 index 6ce50ab..0000000 --- a/compositions/cloudflare-worker/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for cloudflare-worker - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `cloudflare-worker` looks inside a consumer repository. - -- `examples/identity-worker` diff --git a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/component.yaml b/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/component.yaml deleted file mode 100644 index 01b1240..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/component.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: identity-worker - -spec: - type: cloudflare-worker - domain: platform-identity - subscribe: - environments: - - dev - - staging - - production - inputs: - installCommand: pnpm install --no-frozen-lockfile - buildCommand: pnpm exec turbo run build --filter=./ - typecheckCommand: pnpm exec turbo run typecheck --filter=./ - deployCommand: pnpm run deploy - nodeVersion: "20" - pnpmVersion: "10.12.1" - productionBranch: main - labels: - team: platform - layer: runtime - surface: identity - runtime: cloudflare \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/package.json b/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/package.json deleted file mode 100644 index 9e50779..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@example/identity-worker", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "build": "tsc -p tsconfig.json --noEmit", - "typecheck": "tsc -p tsconfig.json --noEmit", - "deploy": "wrangler deploy --config wrangler.jsonc" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/src/index.ts b/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/src/index.ts deleted file mode 100644 index 4476079..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/src/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -interface Env { - TENANT_HEADER?: string; -} - -export default { - async fetch(request: Request, env: Env): Promise { - const tenantHeader = env.TENANT_HEADER ?? "x-tenant-id"; - const tenantId = request.headers.get(tenantHeader) ?? "anonymous"; - - return Response.json({ - ok: true, - service: "identity-worker", - tenantId, - }); - }, -}; \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/tsconfig.json b/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/tsconfig.json deleted file mode 100644 index 32a6156..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": [ - "src/**/*.ts" - ] -} \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/wrangler.jsonc b/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/wrangler.jsonc deleted file mode 100644 index b6085e7..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/apps/identity-worker/wrangler.jsonc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$schema": "../../node_modules/wrangler/config-schema.json", - "name": "example-platform-identity-worker", - "main": "src/index.ts", - "compatibility_date": "2026-04-25", - "workers_dev": true, - "observability": { - "enabled": true - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/package.json b/compositions/cloudflare-worker/examples/identity-worker/package.json deleted file mode 100644 index d65acec..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "example-platform-repo", - "private": true, - "version": "1.0.0", - "description": "Turbo-style Cloudflare deployment examples for gluon component discovery", - "packageManager": "pnpm@10.12.1", - "scripts": { - "build": "turbo run build", - "typecheck": "turbo run typecheck", - "deploy": "turbo run deploy" - }, - "devDependencies": { - "turbo": "2.5.8", - "typescript": "5.9.3", - "wrangler": "4.13.2" - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/pnpm-workspace.yaml b/compositions/cloudflare-worker/examples/identity-worker/pnpm-workspace.yaml deleted file mode 100644 index c7eaed9..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - apps/* - - packages/* \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/tsconfig.base.json b/compositions/cloudflare-worker/examples/identity-worker/tsconfig.base.json deleted file mode 100644 index e7910f3..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/tsconfig.base.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "noEmit": true, - "lib": [ - "ES2022", - "DOM" - ] - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker/examples/identity-worker/turbo.json b/compositions/cloudflare-worker/examples/identity-worker/turbo.json deleted file mode 100644 index f24d8d7..0000000 --- a/compositions/cloudflare-worker/examples/identity-worker/turbo.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://turborepo.com/schema.json", - "tasks": { - "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**", - ".wrangler/**" - ] - }, - "typecheck": { - "dependsOn": [ - "^typecheck" - ], - "outputs": [] - }, - "deploy": { - "dependsOn": [ - "build" - ], - "cache": false, - "outputs": [] - } - } -} \ No newline at end of file diff --git a/compositions/cloudflare-worker/jobs/cloudflare-worker-verify-deploy.yaml b/compositions/cloudflare-worker/jobs/cloudflare-worker-verify-deploy.yaml new file mode 100644 index 0000000..a765a6b --- /dev/null +++ b/compositions/cloudflare-worker/jobs/cloudflare-worker-verify-deploy.yaml @@ -0,0 +1,109 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-worker-verify-deploy +spec: + description: Capability-tagged atomic steps for a standalone Cloudflare Worker + runsOn: ubuntu-22.04 + timeout: 30m + retries: 0 + + labels: + scope: delivery + + capabilities: + - cloudflare-worker.setup-node + - cloudflare-worker.install + - cloudflare-worker.verify-structure + - cloudflare-worker.build + - cloudflare-worker.typecheck + - cloudflare-worker.deploy-dry-run + - cloudflare-worker.pre-deploy + - cloudflare-worker.migrate + - cloudflare-worker.deploy + - cloudflare-worker.smoke + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-worker.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: install-dependencies + name: install-dependencies + capability: cloudflare-worker.install + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: verify-worker-structure + name: verify-worker-structure + capability: cloudflare-worker.verify-structure + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: | + test -f package.json + test -f "{{ .parameters.wranglerConfig }}" + onFailure: stop + + - id: build-worker + name: build-worker + capability: cloudflare-worker.build + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.buildCommand }}" + onFailure: stop + + - id: typecheck-worker + name: typecheck-worker + capability: cloudflare-worker.typecheck + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.typecheckCommand }}" + onFailure: stop + + - id: deploy-dry-run + name: deploy-dry-run + capability: cloudflare-worker.deploy-dry-run + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.dryRunCommand }}" + onFailure: stop + + - id: pre-deploy + name: pre-deploy + capability: cloudflare-worker.pre-deploy + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.preDeployCommand }}" + onFailure: stop + + - id: migrate + name: migrate + capability: cloudflare-worker.migrate + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.migrationCommand }}" + onFailure: stop + + - id: deploy + name: deploy + capability: cloudflare-worker.deploy + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + {{ .parameters.deployCommand }} + onFailure: stop + + - id: smoke + name: smoke + capability: cloudflare-worker.smoke + shell: bash + working-directory: "{{ .parameters.appDir }}" + run: "{{ .parameters.smokeCommand }}" + onFailure: stop diff --git a/compositions/cloudflare-worker/profiles/cloudflare-worker-deploy.yaml b/compositions/cloudflare-worker/profiles/cloudflare-worker-deploy.yaml new file mode 100644 index 0000000..f31cfb6 --- /dev/null +++ b/compositions/cloudflare-worker/profiles/cloudflare-worker-deploy.yaml @@ -0,0 +1,23 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-worker-deploy +spec: + description: Build, validate, migrate, deploy, and smoke test a Cloudflare Worker + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-worker.setup-node + - cloudflare-worker.install + - cloudflare-worker.verify-structure + - cloudflare-worker.build + - cloudflare-worker.typecheck + - cloudflare-worker.pre-deploy + - cloudflare-worker.migrate + - cloudflare-worker.deploy + - cloudflare-worker.smoke diff --git a/compositions/cloudflare-worker/profiles/cloudflare-worker-pull-request.yaml b/compositions/cloudflare-worker/profiles/cloudflare-worker-pull-request.yaml new file mode 100644 index 0000000..3b5ee48 --- /dev/null +++ b/compositions/cloudflare-worker/profiles/cloudflare-worker-pull-request.yaml @@ -0,0 +1,15 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-worker-pull-request +spec: + description: Fast PR validation for a standalone Cloudflare Worker + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-worker.setup-node + - cloudflare-worker.install + - cloudflare-worker.verify-structure + - cloudflare-worker.build + - cloudflare-worker.typecheck diff --git a/compositions/cloudflare-worker/profiles/cloudflare-worker-verify.yaml b/compositions/cloudflare-worker/profiles/cloudflare-worker-verify.yaml new file mode 100644 index 0000000..d24f641 --- /dev/null +++ b/compositions/cloudflare-worker/profiles/cloudflare-worker-verify.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-worker-verify +spec: + description: Full non-mutating verification, including Wrangler dry-run + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-worker.setup-node + - cloudflare-worker.install + - cloudflare-worker.verify-structure + - cloudflare-worker.build + - cloudflare-worker.typecheck + - cloudflare-worker.deploy-dry-run diff --git a/compositions/cloudflare-worker/schema.yaml b/compositions/cloudflare-worker/schema.yaml new file mode 100644 index 0000000..d70513a --- /dev/null +++ b/compositions/cloudflare-worker/schema.yaml @@ -0,0 +1,65 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-worker-component +spec: + type: cloudflare-worker + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Worker Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-worker + parameters: + type: object + required: + - nodeVersion + - installCommand + - buildCommand + - deployCommand + - wranglerConfig + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + + appDir: + type: string + description: Path from the component job path to the Worker app directory + default: "." + + wranglerConfig: + type: string + default: wrangler.jsonc + + installCommand: + type: string + buildCommand: + type: string + typecheckCommand: + type: string + default: "echo 'No typecheck configured.'" + dryRunCommand: + type: string + preDeployCommand: + type: string + default: "echo 'No pre-deploy step configured.'" + migrationCommand: + type: string + default: "echo 'No migrations configured.'" + deployCommand: + type: string + smokeCommand: + type: string + default: "echo 'No smoke test configured.'" + additionalProperties: false + additionalProperties: true diff --git a/compositions/cloudflare-worker/tests/README.md b/compositions/cloudflare-worker/tests/README.md deleted file mode 100644 index 30b3661..0000000 --- a/compositions/cloudflare-worker/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for cloudflare-worker - -These files provide contract or smoke fixtures that CI can inspect for `cloudflare-worker` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/cloudflare-worker/tests/smoke/component.yaml b/compositions/cloudflare-worker/tests/smoke/component.yaml deleted file mode 100644 index 01b1240..0000000 --- a/compositions/cloudflare-worker/tests/smoke/component.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: identity-worker - -spec: - type: cloudflare-worker - domain: platform-identity - subscribe: - environments: - - dev - - staging - - production - inputs: - installCommand: pnpm install --no-frozen-lockfile - buildCommand: pnpm exec turbo run build --filter=./ - typecheckCommand: pnpm exec turbo run typecheck --filter=./ - deployCommand: pnpm run deploy - nodeVersion: "20" - pnpmVersion: "10.12.1" - productionBranch: main - labels: - team: platform - layer: runtime - surface: identity - runtime: cloudflare \ No newline at end of file diff --git a/compositions/cloudflare-workers-assets-turbo/README.md b/compositions/cloudflare-workers-assets-turbo/README.md new file mode 100644 index 0000000..7bef90d --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/README.md @@ -0,0 +1,47 @@ +# cloudflare-workers-assets-turbo + +`cloudflare-workers-assets-turbo` is an Orun composition in the Stack Tectonic catalog. + +## Purpose + +Build a Worker-entrypoint app with Turbo and deploy it to Cloudflare's +**Workers + Static Assets** runtime (a single `wrangler deploy` that uploads +both the worker bundle and the `ASSETS`-bound directory). + +This is the right composition for apps whose framework emits a Worker bundle +plus a static-assets directory, e.g. Next.js apps adapted with +`@opennextjs/cloudflare`. For pure-static SPAs (Vite, plain React) use +`cloudflare-pages-turbo` instead. + +## Contract + +- **Type:** `cloudflare-workers-assets-turbo` +- **Path:** `compositions/cloudflare-workers-assets-turbo` +- **Required parameters:** `nodeVersion`, `pnpmVersion`, `workspaceDir`, + `appDir`, `turboFilter`, `wranglerConfig`, `workerName`, + `workerEntrypoint`, `assetsDir`. +- **Per-env naming:** set `environmentAwareWorkerName: true` to append the + Orun environment name as a suffix to `workerName` (mirrors + `cloudflare-pages-turbo`'s `environmentAwareProjectName`). +- **Smoke helper env:** the deploy step exports `EFFECTIVE_WORKER_NAME` (and + `DEPLOYED_URL` when `workersDevSubdomain` is set) so the smoke command in + `component.yaml` can curl the deployed hostname without hard-coding it. + +## Profiles + +| Profile | Steps | +| -------------- | ----- | +| `pull-request` | setup → install → verify-structure → build → verify-output | +| `verify` | pull-request + `deploy-dry-run` | +| `deploy` | full pipeline through `deploy` + `smoke` | + +## Why not `cloudflare-worker-turbo`? + +`cloudflare-worker-turbo` is tuned for pure Worker packages (Hono APIs, +service workers): its profiles include `typecheck`, `pre-deploy`, and +`migrate` steps tailored to that lifecycle, and it deploys with +`--env ` against a single Worker definition. It does **not** verify +that an assets directory exists, and it does not support per-environment +worker-name suffixing the way `cloudflare-pages-turbo` does for Pages +projects. This composition adds those concerns without polluting the +Worker-API path. diff --git a/compositions/cloudflare-workers-assets-turbo/composition.yaml b/compositions/cloudflare-workers-assets-turbo/composition.yaml new file mode 100644 index 0000000..2a543df --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/composition.yaml @@ -0,0 +1,35 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: cloudflare-workers-assets-turbo +spec: + type: cloudflare-workers-assets-turbo + description: >- + Cloudflare Worker + Static Assets (single-bundle) build, verify, and deploy + pipeline. Targets apps that emit a Worker entrypoint plus an assets + directory consumed via the `ASSETS` binding — e.g. Next.js apps built with + `@opennextjs/cloudflare`. Per-environment isolation is done via worker + naming (mirrors `cloudflare-pages-turbo`'s `environmentAwareProjectName`), + not wrangler envs. + + schemaRef: + name: cloudflare-workers-assets-turbo-component + + defaultJob: verify-deploy + defaultProfile: verify + + jobs: + - name: verify-deploy + templateRef: + name: cloudflare-workers-assets-turbo-verify-deploy + + profiles: + - name: pull-request + profileRef: + name: cloudflare-workers-assets-turbo-pull-request + - name: verify + profileRef: + name: cloudflare-workers-assets-turbo-verify + - name: deploy + profileRef: + name: cloudflare-workers-assets-turbo-deploy diff --git a/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml b/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml new file mode 100644 index 0000000..bc55ae0 --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/jobs/cloudflare-workers-assets-turbo-verify-deploy.yaml @@ -0,0 +1,128 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: cloudflare-workers-assets-turbo-verify-deploy +spec: + description: Capability-tagged atomic steps for Cloudflare Workers + Static Assets with Turborepo + runsOn: ubuntu-22.04 + timeout: 30m + retries: 0 + + labels: + scope: delivery + + capabilities: + - cloudflare-workers-assets-turbo.setup-node + - cloudflare-workers-assets-turbo.setup-pnpm + - cloudflare-workers-assets-turbo.install + - cloudflare-workers-assets-turbo.verify-structure + - cloudflare-workers-assets-turbo.build + - cloudflare-workers-assets-turbo.verify-output + - cloudflare-workers-assets-turbo.deploy-dry-run + - cloudflare-workers-assets-turbo.deploy + - cloudflare-workers-assets-turbo.smoke + + steps: + - id: setup-node + name: setup-node + capability: cloudflare-workers-assets-turbo.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{ .parameters.nodeVersion }}" + + - id: setup-pnpm + name: setup-pnpm + capability: cloudflare-workers-assets-turbo.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{ .parameters.pnpmVersion }}" + + - id: install-workspace-dependencies + name: install-workspace-dependencies + capability: cloudflare-workers-assets-turbo.install + shell: bash + run: "{{ .parameters.installCommand }}" + onFailure: stop + + - id: verify-app-structure + name: verify-app-structure + capability: cloudflare-workers-assets-turbo.verify-structure + shell: bash + run: | + test -f package.json + test -f "{{ .parameters.wranglerConfig }}" + onFailure: stop + + - id: build-app + name: build-app + capability: cloudflare-workers-assets-turbo.build + shell: bash + run: | + {{- if .parameters.environmentBuildVar }} + export {{ .parameters.environmentBuildVar }}="{{ .orun.environment.name }}" + {{- end }} + {{ .parameters.buildCommand }} + onFailure: stop + + - id: verify-build-output + name: verify-build-output + capability: cloudflare-workers-assets-turbo.verify-output + shell: bash + run: | + test -f "{{ .parameters.workerEntrypoint }}" + test -d "{{ .parameters.assetsDir }}" + # Size sanity: Cloudflare Workers compressed size limit is 10 MB. + ls -lh "{{ .parameters.workerEntrypoint }}" + onFailure: stop + + - id: deploy-dry-run + name: deploy-dry-run + capability: cloudflare-workers-assets-turbo.deploy-dry-run + shell: bash + run: | + {{- if .parameters.environmentAwareWorkerName }} + EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}-{{ .orun.environment.name }}" + {{- else }} + EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}" + {{- end }} + pnpm exec wrangler deploy --dry-run \ + --config "{{ .parameters.wranglerConfig }}" \ + --name "${EFFECTIVE_WORKER_NAME}" + onFailure: stop + + - id: deploy + name: deploy + capability: cloudflare-workers-assets-turbo.deploy + shell: bash + run: | + : "${CLOUDFLARE_ACCOUNT_ID:?CLOUDFLARE_ACCOUNT_ID is required}" + : "${CLOUDFLARE_API_TOKEN:?CLOUDFLARE_API_TOKEN is required}" + + {{- if .parameters.environmentAwareWorkerName }} + EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}-{{ .orun.environment.name }}" + {{- else }} + EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}" + {{- end }} + + pnpm exec wrangler deploy \ + --config "{{ .parameters.wranglerConfig }}" \ + --name "${EFFECTIVE_WORKER_NAME}" + onFailure: stop + + - id: smoke + name: smoke + capability: cloudflare-workers-assets-turbo.smoke + shell: bash + run: | + export ORUN_ENVIRONMENT="{{ .orun.environment.name }}" + {{- if .parameters.environmentAwareWorkerName }} + export EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}-{{ .orun.environment.name }}" + {{- else }} + export EFFECTIVE_WORKER_NAME="{{ .parameters.workerName }}" + {{- end }} + {{- if .parameters.workersDevSubdomain }} + export WORKERS_DEV_SUBDOMAIN="{{ .parameters.workersDevSubdomain }}" + export DEPLOYED_URL="https://${EFFECTIVE_WORKER_NAME}.${WORKERS_DEV_SUBDOMAIN}.workers.dev" + {{- end }} + {{ .parameters.smokeCommand }} + onFailure: stop diff --git a/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-deploy.yaml b/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-deploy.yaml new file mode 100644 index 0000000..4c51a1c --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-deploy.yaml @@ -0,0 +1,22 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-workers-assets-turbo-deploy +spec: + description: Full pipeline including build, deploy, and smoke test + + policies: + requireApproval: true + requireCleanGitTree: true + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-workers-assets-turbo.setup-node + - cloudflare-workers-assets-turbo.setup-pnpm + - cloudflare-workers-assets-turbo.install + - cloudflare-workers-assets-turbo.verify-structure + - cloudflare-workers-assets-turbo.build + - cloudflare-workers-assets-turbo.verify-output + - cloudflare-workers-assets-turbo.deploy + - cloudflare-workers-assets-turbo.smoke diff --git a/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-pull-request.yaml b/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-pull-request.yaml new file mode 100644 index 0000000..25effe1 --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-pull-request.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-workers-assets-turbo-pull-request +spec: + description: Fast PR validation for a Cloudflare Workers + Static Assets package + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-workers-assets-turbo.setup-node + - cloudflare-workers-assets-turbo.setup-pnpm + - cloudflare-workers-assets-turbo.install + - cloudflare-workers-assets-turbo.verify-structure + - cloudflare-workers-assets-turbo.build + - cloudflare-workers-assets-turbo.verify-output diff --git a/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-verify.yaml b/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-verify.yaml new file mode 100644 index 0000000..c802f9f --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/profiles/cloudflare-workers-assets-turbo-verify.yaml @@ -0,0 +1,17 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: cloudflare-workers-assets-turbo-verify +spec: + description: Full non-mutating verification including wrangler deploy --dry-run + + jobs: + verify-deploy: + includeCapabilities: + - cloudflare-workers-assets-turbo.setup-node + - cloudflare-workers-assets-turbo.setup-pnpm + - cloudflare-workers-assets-turbo.install + - cloudflare-workers-assets-turbo.verify-structure + - cloudflare-workers-assets-turbo.build + - cloudflare-workers-assets-turbo.verify-output + - cloudflare-workers-assets-turbo.deploy-dry-run diff --git a/compositions/cloudflare-workers-assets-turbo/schema.yaml b/compositions/cloudflare-workers-assets-turbo/schema.yaml new file mode 100644 index 0000000..382e4b9 --- /dev/null +++ b/compositions/cloudflare-workers-assets-turbo/schema.yaml @@ -0,0 +1,102 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: cloudflare-workers-assets-turbo-component +spec: + type: cloudflare-workers-assets-turbo + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Cloudflare Workers + Static Assets Turbo Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: cloudflare-workers-assets-turbo + parameters: + type: object + required: + - nodeVersion + - pnpmVersion + - workspaceDir + - appDir + - turboFilter + - wranglerConfig + - workerName + - workerEntrypoint + - assetsDir + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + + workspaceDir: + type: string + description: Path from the component job path to the monorepo root + + appDir: + type: string + description: Path from the component job path to the app directory + + turboFilter: + type: string + description: Turborepo filter for this package + + wranglerConfig: + type: string + default: wrangler.jsonc + + workerName: + type: string + description: Base Cloudflare Worker name (per-env suffix applied when environmentAwareWorkerName is true) + + workerEntrypoint: + type: string + description: Path to the built Worker entrypoint, relative to appDir (e.g. .open-next/worker.js) + + assetsDir: + type: string + description: Path to the built static-assets directory, relative to appDir (e.g. .open-next/assets) + + environmentAwareWorkerName: + type: boolean + description: >- + When true, appends the Orun environment name as a suffix to the + workerName (e.g. "my-worker" becomes "my-worker-stage" in the + stage environment). Mirrors cloudflare-pages-turbo's + environmentAwareProjectName for parity. + default: false + + environmentBuildVar: + type: string + description: >- + Optional environment variable name (e.g. NEXT_PUBLIC_DEPLOY_ENV) + exported with the Orun environment name during the build step, + allowing the app to lock its configuration to the target + environment at build time. + + workersDevSubdomain: + type: string + description: >- + The account's workers.dev subdomain (e.g. "your-workers-subdomain"). + Used to derive the deployed hostname for the smoke step: + `${EFFECTIVE_WORKER_NAME}.${workersDevSubdomain}.workers.dev`. + + installCommand: + type: string + default: pnpm install --frozen-lockfile + + buildCommand: + type: string + + smokeCommand: + type: string + default: "echo 'No smoke test configured.'" + additionalProperties: false + additionalProperties: true diff --git a/compositions/db-migrate/README.md b/compositions/db-migrate/README.md new file mode 100644 index 0000000..ccca76b --- /dev/null +++ b/compositions/db-migrate/README.md @@ -0,0 +1,47 @@ +# db-migrate + +`db-migrate` is an exported Orun composition in the Stack Tectonic catalog. + +## Purpose + +Run database migrations from a pnpm + Turborepo monorepo: install the +workspace, build the `@saas/db` package, assume the environment's GitHub-OIDC +plan role, then invoke the migration runner (`dist/runner/cli.js`) in either +`plan` or `apply` mode. The Orun environment name is passed through as +`MIGRATION_ENV` and as `--env`, so plan and apply always target the environment +the run belongs to. + +## Contract + +- **Type:** `db-migrate` +- **Path:** `compositions/db-migrate` +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `migrate` (default) — `jobs/db-migrate-run.yaml` +- **Default profile:** `apply` +- **Required parameters:** `nodeVersion`, `pnpmVersion`, `secretName` +- **Optional parameters:** `awsAccountId` (AWS account ID hosting the + GitHub-OIDC role this component assumes), `awsRegion`, `owner`, `repo` + +`awsAccountId`, `awsRegion`, `owner`, and `repo` are optional in the schema but +are all interpolated into the `aws-credentials` step, so a component that runs +either profile in CI needs them set. + +## Profiles + +Each file in `profiles/` selects steps from the job by capability. + +| Profile | Steps | +| ----------------- | ----- | +| `plan` | setup-node → setup-pnpm → install → build → aws-credentials → plan. Reports pending migrations without mutating the database; used on pull requests. | +| `apply` (default) | the same setup steps followed by `apply` instead of `plan`. Applies pending migrations to the live database post-merge. | + +`setup-pnpm` is declared before `setup-node` in the job so `setup-node` can warm +and persist the pnpm store cache, keyed on the workspace lockfile. + +## Verification + +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `db-migrate` exports from the packed artifact. diff --git a/compositions/db-migrate/composition.yaml b/compositions/db-migrate/composition.yaml new file mode 100644 index 0000000..92594fa --- /dev/null +++ b/compositions/db-migrate/composition.yaml @@ -0,0 +1,26 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: db-migrate +spec: + type: db-migrate + description: Database migration runner — plan on PRs, apply on merge + + schemaRef: + name: db-migrate-component + + defaultJob: migrate + defaultProfile: apply + + jobs: + - name: migrate + templateRef: + name: db-migrate-run + + profiles: + - name: plan + profileRef: + name: db-migrate-plan + - name: apply + profileRef: + name: db-migrate-apply diff --git a/compositions/db-migrate/jobs/db-migrate-run.yaml b/compositions/db-migrate/jobs/db-migrate-run.yaml new file mode 100644 index 0000000..cb86341 --- /dev/null +++ b/compositions/db-migrate/jobs/db-migrate-run.yaml @@ -0,0 +1,80 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: db-migrate-run +spec: + description: Run database migrations in plan or apply mode + runsOn: ubuntu-22.04 + timeout: 10m + retries: 0 + + labels: + scope: database + + capabilities: + - db-migrate.setup-node + - db-migrate.setup-pnpm + - db-migrate.install + - db-migrate.build + - db-migrate.aws-credentials + - db-migrate.plan + - db-migrate.apply + + steps: + # setup-pnpm runs before setup-node so setup-node can warm and persist the + # pnpm store cache (keyed on the workspace lockfile). + - id: setup-pnpm + name: setup-pnpm + capability: db-migrate.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{.parameters.pnpmVersion}}" + + - id: setup-node + name: setup-node + capability: db-migrate.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{.parameters.nodeVersion}}" + cache: pnpm + cache-dependency-path: "**/pnpm-lock.yaml" + + - id: install-dependencies + name: install-dependencies + capability: db-migrate.install + run: pnpm install --frozen-lockfile + onFailure: stop + + - id: build-db-package + name: build-db-package + capability: db-migrate.build + run: pnpm exec turbo run build --filter=@saas/db + onFailure: stop + + - id: aws-credentials + name: Configure AWS Credentials + capability: db-migrate.aws-credentials + use: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan" + aws-region: "{{.parameters.awsRegion}}" + audience: sts.amazonaws.com + onFailure: stop + + - id: migrate-plan + name: Migration Plan + capability: db-migrate.plan + shell: bash + run: | + set -euo pipefail + MIGRATION_ENV="{{ .orun.environment.name }}" node ../../dist/runner/cli.js plan --env "{{ .orun.environment.name }}" + onFailure: stop + + - id: migrate-apply + name: Migration Apply + capability: db-migrate.apply + shell: bash + run: | + set -euo pipefail + MIGRATION_ENV="{{ .orun.environment.name }}" node ../../dist/runner/cli.js apply --env "{{ .orun.environment.name }}" + onFailure: stop diff --git a/compositions/db-migrate/profiles/db-migrate-apply.yaml b/compositions/db-migrate/profiles/db-migrate-apply.yaml new file mode 100644 index 0000000..1ef23ac --- /dev/null +++ b/compositions/db-migrate/profiles/db-migrate-apply.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: db-migrate-apply +spec: + description: Post-merge migration apply — applies pending migrations to the live database + + jobs: + migrate: + includeCapabilities: + - db-migrate.setup-node + - db-migrate.setup-pnpm + - db-migrate.install + - db-migrate.build + - db-migrate.aws-credentials + - db-migrate.apply diff --git a/compositions/db-migrate/profiles/db-migrate-plan.yaml b/compositions/db-migrate/profiles/db-migrate-plan.yaml new file mode 100644 index 0000000..dfe83a4 --- /dev/null +++ b/compositions/db-migrate/profiles/db-migrate-plan.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: db-migrate-plan +spec: + description: PR migration plan — authenticates and reports pending migrations without mutating the database + + jobs: + migrate: + includeCapabilities: + - db-migrate.setup-node + - db-migrate.setup-pnpm + - db-migrate.install + - db-migrate.build + - db-migrate.aws-credentials + - db-migrate.plan diff --git a/compositions/db-migrate/schema.yaml b/compositions/db-migrate/schema.yaml new file mode 100644 index 0000000..96c4e6c --- /dev/null +++ b/compositions/db-migrate/schema.yaml @@ -0,0 +1,44 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: db-migrate-component +spec: + type: db-migrate + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Database Migration Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: db-migrate + parameters: + type: object + required: + - nodeVersion + - pnpmVersion + - secretName + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + awsAccountId: + type: string + description: AWS account ID hosting the GitHub-OIDC role this component assumes + awsRegion: + type: string + secretName: + type: string + owner: + type: string + repo: + type: string + additionalProperties: false + additionalProperties: true diff --git a/compositions/helm-chart/README.md b/compositions/helm-chart/README.md deleted file mode 100644 index 1f06a60..0000000 --- a/compositions/helm-chart/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# helm-chart - -`helm-chart` is an exported Orun composition in the Stack Tectonic catalog. - -## Purpose - -Helm chart validation jobs for chart components - -## Contract - -- **Type:** `helm-chart` -- **Path:** `compositions/helm-chart` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/identity-portal-chart` - -## Test fixtures - -- `tests/smoke` - -## Verification - -`./scripts/verify-composition.sh helm-chart` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. diff --git a/compositions/helm-chart/compositions.yaml b/compositions/helm-chart/compositions.yaml deleted file mode 100644 index 754bd90..0000000 --- a/compositions/helm-chart/compositions.yaml +++ /dev/null @@ -1,72 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: helm-chart -spec: - type: helm-chart - description: Helm chart validation jobs for chart components - defaultJob: render-helm-chart - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Helm Chart Component - description: Schema for helm-chart components in the multi-type sample - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: helm-chart - description: Component type identifier - inputs: - type: object - required: - - chartPath - - valuesFile - - releaseName - properties: - chartPath: - type: string - description: Helm chart directory used by the job - valuesFile: - type: string - description: Values file used to render the chart - releaseName: - type: string - description: Helm release name used during template rendering - helmVersion: - type: string - description: Optional Helm version installed by the job registry - additionalProperties: false - additionalProperties: true - jobs: - - name: render-helm-chart - description: Lint and template Helm charts against their paired values files - runsOn: ubuntu-22.04 - timeout: 20m - retries: 0 - labels: - scope: delivery - steps: - - id: setup-helm - name: setup-helm - use: azure/setup-helm@v4.3.0 - with: - version: "{{.helmVersion}}" - - name: helm-chart-context - shell: bash - run: | - helm version --short - echo "Rendering {{.releaseName}} from {{.chartPath}} with {{.valuesFile}}" - onFailure: stop - - name: helm-chart-lint - run: helm lint {{.chartPath}} --values {{.valuesFile}} - onFailure: stop - - name: helm-chart-template - run: helm template {{.releaseName}} {{.chartPath}} --values {{.valuesFile}} - onFailure: stop \ No newline at end of file diff --git a/compositions/helm-chart/examples/README.md b/compositions/helm-chart/examples/README.md deleted file mode 100644 index e8fa4fd..0000000 --- a/compositions/helm-chart/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for helm-chart - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `helm-chart` looks inside a consumer repository. - -- `examples/identity-portal-chart` diff --git a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/Chart.yaml b/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/Chart.yaml deleted file mode 100644 index 8da9933..0000000 --- a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: identity-portal -description: Helm chart for the customer identity portal -type: application -version: 0.1.0 -appVersion: "1.0.0" \ No newline at end of file diff --git a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/component.yaml b/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/component.yaml deleted file mode 100644 index b7574e4..0000000 --- a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/component.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: identity-portal-chart - -spec: - type: helm-chart - domain: customer-identity - subscribe: - environments: - - development - - staging - inputs: - chartPath: . - valuesFile: ../../../deploy/hello-deploy/values.yaml - releaseName: identity-portal - helmVersion: v3.15.4 - labels: - team: platform - layer: delivery - domain: identity - release: identity-portal - dependsOn: - - component: identity-portal-values \ No newline at end of file diff --git a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/templates/configmap.yaml b/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/templates/configmap.yaml deleted file mode 100644 index 80fd892..0000000 --- a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/templates/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ default .Chart.Name .Values.nameOverride }} - labels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} -data: - message: {{ .Values.config.message | quote }} - environment: {{ .Values.config.environment | quote }} - color: {{ .Values.config.color | quote }} \ No newline at end of file diff --git a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/values.yaml b/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/values.yaml deleted file mode 100644 index d3272b6..0000000 --- a/compositions/helm-chart/examples/identity-portal-chart/charts/hello-chart/chart/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -nameOverride: identity-portal -config: - message: identity portal application configuration - environment: shared - color: blue \ No newline at end of file diff --git a/compositions/helm-chart/examples/identity-portal-chart/deploy/hello-deploy/values.yaml b/compositions/helm-chart/examples/identity-portal-chart/deploy/hello-deploy/values.yaml deleted file mode 100644 index e71ead5..0000000 --- a/compositions/helm-chart/examples/identity-portal-chart/deploy/hello-deploy/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -nameOverride: identity-portal -config: - message: identity portal delivery values - environment: development - color: amber \ No newline at end of file diff --git a/compositions/helm-chart/tests/README.md b/compositions/helm-chart/tests/README.md deleted file mode 100644 index b9d1f75..0000000 --- a/compositions/helm-chart/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for helm-chart - -These files provide contract or smoke fixtures that CI can inspect for `helm-chart` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/helm-chart/tests/smoke/component.yaml b/compositions/helm-chart/tests/smoke/component.yaml deleted file mode 100644 index b7574e4..0000000 --- a/compositions/helm-chart/tests/smoke/component.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: identity-portal-chart - -spec: - type: helm-chart - domain: customer-identity - subscribe: - environments: - - development - - staging - inputs: - chartPath: . - valuesFile: ../../../deploy/hello-deploy/values.yaml - releaseName: identity-portal - helmVersion: v3.15.4 - labels: - team: platform - layer: delivery - domain: identity - release: identity-portal - dependsOn: - - component: identity-portal-values \ No newline at end of file diff --git a/compositions/helm-values/README.md b/compositions/helm-values/README.md deleted file mode 100644 index 3ac29fa..0000000 --- a/compositions/helm-values/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# helm-values - -`helm-values` is an exported Orun composition in the Stack Tectonic catalog. - -## Purpose - -Helm values validation jobs for deployment files - -## Contract - -- **Type:** `helm-values` -- **Path:** `compositions/helm-values` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/identity-portal-values` - -## Test fixtures - -- `tests/smoke` - -## Verification - -`./scripts/verify-composition.sh helm-values` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. diff --git a/compositions/helm-values/compositions.yaml b/compositions/helm-values/compositions.yaml deleted file mode 100644 index 17f15b6..0000000 --- a/compositions/helm-values/compositions.yaml +++ /dev/null @@ -1,72 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: helm-values -spec: - type: helm-values - description: Helm values validation jobs for deployment files - defaultJob: render-helm-values - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Helm Values Component - description: Schema for helm-values components in the multi-type sample - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: helm-values - description: Component type identifier - inputs: - type: object - required: - - chartPath - - valuesFile - - releaseName - properties: - chartPath: - type: string - description: Chart directory paired with this values file - valuesFile: - type: string - description: Helm values file used by the job - releaseName: - type: string - description: Helm release name used during template rendering - helmVersion: - type: string - description: Optional Helm version installed by the job registry - additionalProperties: false - additionalProperties: true - jobs: - - name: render-helm-values - description: Validate values files against their paired chart directories - runsOn: ubuntu-22.04 - timeout: 20m - retries: 0 - labels: - scope: delivery - steps: - - id: setup-helm - name: setup-helm - use: azure/setup-helm@v4.3.0 - with: - version: "{{.helmVersion}}" - - name: helm-values-context - shell: bash - run: | - helm version --short - echo "Validating {{.valuesFile}} against {{.chartPath}}" - onFailure: stop - - name: helm-values-lint - run: helm lint {{.chartPath}} --values {{.valuesFile}} - onFailure: stop - - name: helm-values-template - run: helm template {{.releaseName}} {{.chartPath}} --values {{.valuesFile}} - onFailure: stop \ No newline at end of file diff --git a/compositions/helm-values/examples/README.md b/compositions/helm-values/examples/README.md deleted file mode 100644 index 7788840..0000000 --- a/compositions/helm-values/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for helm-values - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `helm-values` looks inside a consumer repository. - -- `examples/identity-portal-values` diff --git a/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/Chart.yaml b/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/Chart.yaml deleted file mode 100644 index 8da9933..0000000 --- a/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: identity-portal -description: Helm chart for the customer identity portal -type: application -version: 0.1.0 -appVersion: "1.0.0" \ No newline at end of file diff --git a/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/templates/configmap.yaml b/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/templates/configmap.yaml deleted file mode 100644 index 80fd892..0000000 --- a/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/templates/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ default .Chart.Name .Values.nameOverride }} - labels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} -data: - message: {{ .Values.config.message | quote }} - environment: {{ .Values.config.environment | quote }} - color: {{ .Values.config.color | quote }} \ No newline at end of file diff --git a/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/values.yaml b/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/values.yaml deleted file mode 100644 index d3272b6..0000000 --- a/compositions/helm-values/examples/identity-portal-values/charts/hello-chart/chart/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -nameOverride: identity-portal -config: - message: identity portal application configuration - environment: shared - color: blue \ No newline at end of file diff --git a/compositions/helm-values/examples/identity-portal-values/deploy/hello-deploy/component.yaml b/compositions/helm-values/examples/identity-portal-values/deploy/hello-deploy/component.yaml deleted file mode 100644 index cddc642..0000000 --- a/compositions/helm-values/examples/identity-portal-values/deploy/hello-deploy/component.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: identity-portal-values - -spec: - type: helm-values - domain: customer-identity - subscribe: - environments: - - development - - staging - inputs: - chartPath: ../../charts/hello-chart/chart - valuesFile: values.yaml - releaseName: identity-portal - helmVersion: v3.15.4 - labels: - team: platform - layer: delivery - domain: identity - release: identity-portal - dependsOn: - - component: network-foundation \ No newline at end of file diff --git a/compositions/helm-values/examples/identity-portal-values/deploy/hello-deploy/values.yaml b/compositions/helm-values/examples/identity-portal-values/deploy/hello-deploy/values.yaml deleted file mode 100644 index e71ead5..0000000 --- a/compositions/helm-values/examples/identity-portal-values/deploy/hello-deploy/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -nameOverride: identity-portal -config: - message: identity portal delivery values - environment: development - color: amber \ No newline at end of file diff --git a/compositions/helm-values/tests/README.md b/compositions/helm-values/tests/README.md deleted file mode 100644 index ce3056b..0000000 --- a/compositions/helm-values/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for helm-values - -These files provide contract or smoke fixtures that CI can inspect for `helm-values` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/helm-values/tests/smoke/component.yaml b/compositions/helm-values/tests/smoke/component.yaml deleted file mode 100644 index cddc642..0000000 --- a/compositions/helm-values/tests/smoke/component.yaml +++ /dev/null @@ -1,25 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: identity-portal-values - -spec: - type: helm-values - domain: customer-identity - subscribe: - environments: - - development - - staging - inputs: - chartPath: ../../charts/hello-chart/chart - valuesFile: values.yaml - releaseName: identity-portal - helmVersion: v3.15.4 - labels: - team: platform - layer: delivery - domain: identity - release: identity-portal - dependsOn: - - component: network-foundation \ No newline at end of file diff --git a/compositions/publish-stack/README.md b/compositions/publish-stack/README.md new file mode 100644 index 0000000..3a730f6 --- /dev/null +++ b/compositions/publish-stack/README.md @@ -0,0 +1,33 @@ +# publish-stack + +`publish-stack` is an exported Orun composition in the Stack Tectonic catalog. + +## Purpose + +Publish an Orun stack to an OCI registry. Runs `orun publish --dry-run` on every pull request and performs the real publish on release. + +## Contract + +- **Type:** `publish-stack` +- **Path:** `compositions/publish-stack` +- **Definition:** `composition.yaml` + +## Profiles + +| Profile | Description | +|-----------|--------------------------------------------------| +| `dry-run` | PR validation — runs `orun publish --dry-run` | +| `verify` | Staging validation — dry-run without publishing | +| `release` | Production — dry-run + real publish to registry | + +## Inputs + +| Input | Required | Description | +|------------|----------|-----------------------------------------------------------| +| `registry` | yes | OCI registry base URL, e.g. `ghcr.io/org/stack-name` | +| `version` | yes | Stack version to publish; passed to `orun publish --version` | +| `root` | no | Root directory of the stack (default `.`) | + +## Example fixtures + +- `examples/` diff --git a/compositions/publish-stack/composition.yaml b/compositions/publish-stack/composition.yaml new file mode 100644 index 0000000..e9615d7 --- /dev/null +++ b/compositions/publish-stack/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: publish-stack +spec: + type: publish-stack + description: Publish an Orun stack to an OCI registry with dry-run validation + + schemaRef: + name: publish-stack-component + + defaultJob: publish + defaultProfile: dry-run + + jobs: + - name: publish + templateRef: + name: publish-stack-publish + + profiles: + - name: dry-run + profileRef: + name: publish-stack-dry-run + - name: verify + profileRef: + name: publish-stack-verify + - name: release + profileRef: + name: publish-stack-release diff --git a/compositions/publish-stack/examples/README.md b/compositions/publish-stack/examples/README.md new file mode 100644 index 0000000..6084b05 --- /dev/null +++ b/compositions/publish-stack/examples/README.md @@ -0,0 +1,5 @@ +# Examples for publish-stack + +These fixtures show how `publish-stack` looks inside a consumer repository. + +- `examples/stack-tectonic` — the Stack Tectonic stack itself, published to `ghcr.io/sourceplane/stack-tectonic` diff --git a/compositions/publish-stack/jobs/publish-stack-publish.yaml b/compositions/publish-stack/jobs/publish-stack-publish.yaml new file mode 100644 index 0000000..b6de9b5 --- /dev/null +++ b/compositions/publish-stack/jobs/publish-stack-publish.yaml @@ -0,0 +1,48 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: publish-stack-publish +spec: + description: Publish an Orun stack to an OCI registry, with an always-on dry-run validation step + runsOn: ubuntu-22.04 + timeout: 20m + retries: 0 + + labels: + scope: delivery + + capabilities: + - publish-stack.setup + - publish-stack.dry-run + - publish-stack.publish + + steps: + - id: setup-orun + name: setup-orun + capability: publish-stack.setup + use: sourceplane/orun-action@v1.1.0 + + # The declared parameters are passed explicitly. Without them `orun publish` + # infers the target from the git remote (ghcr.io///) + # and the version from the git tag or stack.yaml — which silently ignores + # `registry`/`version` and publishes to the wrong repository path. + - id: publish-dry-run + name: publish-dry-run + capability: publish-stack.dry-run + shell: bash + run: | + orun publish "{{ .parameters.registry }}" \ + --root "{{ if .parameters.root }}{{ .parameters.root }}{{ else }}.{{ end }}" \ + --version "{{ .parameters.version }}" \ + --dry-run + onFailure: stop + + - id: publish + name: publish + capability: publish-stack.publish + shell: bash + run: | + orun publish "{{ .parameters.registry }}" \ + --root "{{ if .parameters.root }}{{ .parameters.root }}{{ else }}.{{ end }}" \ + --version "{{ .parameters.version }}" + onFailure: stop diff --git a/compositions/publish-stack/profiles/publish-stack-dry-run.yaml b/compositions/publish-stack/profiles/publish-stack-dry-run.yaml new file mode 100644 index 0000000..910a516 --- /dev/null +++ b/compositions/publish-stack/profiles/publish-stack-dry-run.yaml @@ -0,0 +1,12 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: publish-stack-dry-run +spec: + description: PR validation — runs orun publish with --dry-run only + + jobs: + publish: + includeCapabilities: + - publish-stack.setup + - publish-stack.dry-run diff --git a/compositions/publish-stack/profiles/publish-stack-release.yaml b/compositions/publish-stack/profiles/publish-stack-release.yaml new file mode 100644 index 0000000..96c5716 --- /dev/null +++ b/compositions/publish-stack/profiles/publish-stack-release.yaml @@ -0,0 +1,16 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: publish-stack-release +spec: + description: Production release — validates with dry-run then publishes to OCI registry + + policies: + requireCleanGitTree: true + + jobs: + publish: + includeCapabilities: + - publish-stack.setup + - publish-stack.dry-run + - publish-stack.publish diff --git a/compositions/publish-stack/profiles/publish-stack-verify.yaml b/compositions/publish-stack/profiles/publish-stack-verify.yaml new file mode 100644 index 0000000..883114a --- /dev/null +++ b/compositions/publish-stack/profiles/publish-stack-verify.yaml @@ -0,0 +1,12 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: publish-stack-verify +spec: + description: Staging verification — validates publish without pushing to registry + + jobs: + publish: + includeCapabilities: + - publish-stack.setup + - publish-stack.dry-run diff --git a/compositions/publish-stack/schema.yaml b/compositions/publish-stack/schema.yaml new file mode 100644 index 0000000..76a7334 --- /dev/null +++ b/compositions/publish-stack/schema.yaml @@ -0,0 +1,37 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: publish-stack-component +spec: + type: publish-stack + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Publish Stack Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: publish-stack + parameters: + type: object + required: + - registry + - version + properties: + registry: + type: string + description: OCI registry base URL without tag (e.g. ghcr.io/sourceplane/stack-tectonic) + version: + type: string + description: Stack version to publish; passed through to `orun publish --version` + root: + type: string + description: Root directory of the stack (default ".") + additionalProperties: false + additionalProperties: true diff --git a/compositions/terraform/README.md b/compositions/terraform/README.md index 4a77832..76c39a3 100644 --- a/compositions/terraform/README.md +++ b/compositions/terraform/README.md @@ -1,27 +1,86 @@ -# terraform +# Terraform Composition -`terraform` is an exported Orun composition in the Stack Tectonic catalog. +Repo-local Orun composition for Terraform infrastructure components. -## Purpose +## Contract -Terraform validation jobs for infra components +| Field | Value | +| --- | --- | +| Type | `terraform` | +| Composition | `composition.yaml` | +| Schema | `schema.yaml` | +| Job | `terraform` (default) — `jobs/terraform-validate.yaml` | +| Default Profile | `apply` | +| Profiles | `plan-only`, `apply`, `local` | -## Contract +## Parameters (from schema) + +`schema.yaml` is the authoritative contract for this table. + +| Parameter | Required | Description | +| --- | --- | --- | +| `stackName` | yes | Logical name of the Terraform stack | +| `terraformDir` | yes | Relative path to the Terraform root module | +| `terraformVersion` | yes | Pinned Terraform CLI version | +| `awsAccountId` | no | AWS account ID hosting the GitHub-OIDC role this component assumes | +| `orgName` | no | Organization name (used for S3 bucket naming) | +| `awsRegion` | no | AWS region override | +| `owner` | no | GitHub org owner | +| `repo` | no | GitHub repo name | +| `namespace` | no | Logical namespace | +| `namespacePrefix` | no | Environment-scoped prefix | +| `lane` | no | Deployment lane | + +## Profiles + +Each file in `profiles/` selects steps from the `terraform` job by capability. + +### `plan-only` + +Non-mutating validation: setup, AWS credentials, env export, context, fmt, init, +workspace, validate, plan. Used on pull requests to preview changes. + +### `apply` (default) + +Full lifecycle: the `plan-only` steps plus `terraform apply`. Used on +main-branch pushes when profile rules select it. + +### `local` + +The `plan-only` steps without the `terraform.aws-credentials` step, so a +developer can run the plan lane on a workstation using ambient AWS credentials +instead of assuming the GitHub-OIDC role. Stops at `plan` — it never applies. -- **Type:** `terraform` -- **Path:** `compositions/terraform` -- **Definition:** `compositions.yaml` +## Job Steps -## Example fixtures +1. **setup-terraform** — Install pinned Terraform version +2. **aws-credentials** — Assume the environment's GitHub-OIDC plan role (skipped by `local`) +3. **terraform-env** — Export `TF_VAR_*` from component parameters and environment +4. **terraform-context** — Print version and component metadata +5. **terraform-fmt-check** — Enforce canonical formatting +6. **terraform-init** — Initialize with S3 backend config +7. **terraform-workspace** — Select or create environment workspace +8. **terraform-validate** — Validate configuration +9. **terraform-plan** — Generate execution plan +10. **terraform-apply** — Apply changes (only in the `apply` profile) -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. +## S3 Backend Convention -- `examples/network-foundation` +``` +bucket: {orgName}-{environment} +key: {repo}/{componentName}/terraform.tfstate +region: {awsRegion} +``` -## Test fixtures +Note: S3 backend consumption requires IAM roles from `aws-admin` (Task 0004/0005). +Until then, `terraform init` will fail on live runs but `orun validate` and +`orun plan` will succeed. -- `tests/smoke` +## Local Verification -## Verification +```bash +orun compositions --intent intent.yaml --long +orun validate --intent intent.yaml +``` -`./scripts/verify-composition.sh terraform` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +The catalog gate itself is `./scripts/verify.sh`, run from the repository root. diff --git a/compositions/terraform/composition.yaml b/compositions/terraform/composition.yaml new file mode 100644 index 0000000..41fc3cb --- /dev/null +++ b/compositions/terraform/composition.yaml @@ -0,0 +1,29 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: terraform +spec: + type: terraform + description: Terraform validation and planning for multi-tenant SaaS infrastructure components + + schemaRef: + name: terraform-component + + defaultJob: terraform + defaultProfile: apply + + jobs: + - name: terraform + templateRef: + name: terraform-validate + + profiles: + - name: plan-only + profileRef: + name: terraform-plan-only + - name: apply + profileRef: + name: terraform-apply + - name: local + profileRef: + name: terraform-local \ No newline at end of file diff --git a/compositions/terraform/compositions.yaml b/compositions/terraform/compositions.yaml deleted file mode 100644 index 0c8574a..0000000 --- a/compositions/terraform/compositions.yaml +++ /dev/null @@ -1,78 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: terraform -spec: - type: terraform - description: Terraform validation jobs for infra components - defaultJob: validate-terraform - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Terraform Stack Component - description: Schema for terraform components in the multi-type sample - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: terraform - description: Component type identifier - inputs: - type: object - required: - - stackName - - terraformDir - properties: - stackName: - type: string - description: Logical stack name used in job logs - terraformDir: - type: string - description: Terraform root directory used by the job - terraformVersion: - type: string - description: Optional Terraform version installed by the job registry - varFile: - type: string - description: Optional tfvars file for future expansion - backendKey: - type: string - description: Optional backend key for future expansion - additionalProperties: false - additionalProperties: true - jobs: - - name: validate-terraform - description: Validate Terraform stacks with fmt, init, and validate - runsOn: ubuntu-22.04 - timeout: 20m - retries: 0 - labels: - scope: infra - steps: - - id: setup-terraform - name: setup-terraform - use: hashicorp/setup-terraform@v4 - with: - terraform_version: "{{.terraformVersion}}" - terraform_wrapper: "false" - - name: terraform-context - shell: bash - run: | - terraform version - echo "Validating {{.stackName}} at {{.terraformDir}}" - onFailure: stop - - name: terraform-fmt-check - run: terraform fmt -check {{.terraformDir}} - onFailure: stop - - name: terraform-init - run: terraform -chdir={{.terraformDir}} init -backend=false -input=false - onFailure: stop - - name: terraform-validate - run: terraform -chdir={{.terraformDir}} validate -no-color - onFailure: stop \ No newline at end of file diff --git a/compositions/terraform/examples/README.md b/compositions/terraform/examples/README.md deleted file mode 100644 index 8950b7e..0000000 --- a/compositions/terraform/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for terraform - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `terraform` looks inside a consumer repository. - -- `examples/network-foundation` diff --git a/compositions/terraform/examples/network-foundation/infra/infra-1/component.yaml b/compositions/terraform/examples/network-foundation/infra/infra-1/component.yaml deleted file mode 100644 index d63d128..0000000 --- a/compositions/terraform/examples/network-foundation/infra/infra-1/component.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: network-foundation - -spec: - type: terraform - domain: platform-foundation - subscribe: - environments: - - development - - staging - - production - inputs: - stackName: network-foundation - terraformDir: . - terraformVersion: 1.9.8 - labels: - team: platform - layer: foundation - stack: network \ No newline at end of file diff --git a/compositions/terraform/examples/network-foundation/infra/infra-1/main.tf b/compositions/terraform/examples/network-foundation/infra/infra-1/main.tf deleted file mode 100644 index dcc30c2..0000000 --- a/compositions/terraform/examples/network-foundation/infra/infra-1/main.tf +++ /dev/null @@ -1,21 +0,0 @@ -terraform { - required_version = ">= 1.6.0" -} - -locals { - stack_name = "network-foundation" - owner = "platform" - environment = "shared" -} - -output "stack_name" { - value = local.stack_name -} - -output "owner" { - value = local.owner -} - -output "environment" { - value = local.environment -} \ No newline at end of file diff --git a/compositions/terraform/jobs/terraform-validate.yaml b/compositions/terraform/jobs/terraform-validate.yaml new file mode 100644 index 0000000..eea197b --- /dev/null +++ b/compositions/terraform/jobs/terraform-validate.yaml @@ -0,0 +1,123 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: terraform-validate +spec: + description: Run Terraform fmt, init, validate, and plan for component roots + runsOn: ubuntu-22.04 + timeout: 20m + retries: 0 + + labels: + scope: infra + + capabilities: + - terraform.setup + - terraform.aws-credentials + - terraform.env + - terraform.context + - terraform.fmt + - terraform.init + - terraform.workspace + - terraform.validate + - terraform.plan + - terraform.apply + + steps: + - id: setup-terraform + name: setup-terraform + capability: terraform.setup + use: hashicorp/setup-terraform@v4 + with: + terraform_version: "{{.parameters.terraformVersion}}" + terraform_wrapper: "false" + + - id: aws-credentials + name: Configure AWS Credentials + capability: terraform.aws-credentials + use: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: "arn:aws:iam::{{.parameters.awsAccountId}}:role/{{.orun.environment.name}}-github-{{.parameters.owner}}-{{.parameters.repo}}-plan" + aws-region: "{{.parameters.awsRegion}}" + audience: sts.amazonaws.com + onFailure: stop + + - id: terraform-env + name: Export Terraform Env + capability: terraform.env + shell: bash + run: | + { + {{- range $key, $value := .env }} + printf '%s=%s\n' '{{ $key }}' '{{ $value }}' + {{- end }} + + {{- range $key, $value := .parameters }} + printf 'TF_VAR_{{ $key }}=%s\n' '{{ $value }}' + {{- end }} + + printf 'TF_VAR_environment=%s\n' "{{ .orun.environment.name }}" + printf 'TF_VAR_component=%s\n' "{{ .orun.component.name }}" + } >> "$ORUN_ENV" + onFailure: stop + + - id: terraform-context + name: Terraform Context + capability: terraform.context + shell: bash + run: | + terraform version + echo "Component: {{ .orun.component.name }}" + echo "Environment: {{ .orun.environment.name }}" + echo "Terraform directory: {{ .parameters.terraformDir }}" + onFailure: stop + + - id: terraform-fmt-check + name: fmt Check + capability: terraform.fmt + run: "terraform -chdir={{ .parameters.terraformDir }} fmt -check" + onFailure: stop + + - id: terraform-init + name: Init + capability: terraform.init + shell: bash + run: | + set -euo pipefail + + terraform -chdir={{ .parameters.terraformDir }} init \ + -input=false \ + -reconfigure \ + -backend-config="bucket={{.parameters.orgName}}-{{.orun.environment.name}}" \ + -backend-config="key={{.parameters.repo}}/{{.orun.component.name}}/terraform.tfstate" \ + -backend-config="region=${AWS_REGION:-{{.parameters.awsRegion}}}" + onFailure: stop + + - id: terraform-workspace + name: Workspace + capability: terraform.workspace + shell: bash + run: | + set -euo pipefail + + terraform -chdir={{ .parameters.terraformDir }} workspace select -or-create {{ .orun.environment.name }} + echo "TF_WORKSPACE={{ .orun.environment.name }}" >> "$ORUN_ENV" + onFailure: stop + + - id: terraform-validate + name: Validate + capability: terraform.validate + run: "terraform -chdir={{ .parameters.terraformDir }} validate -no-color" + onFailure: stop + + - id: terraform-plan + name: Plan + capability: terraform.plan + run: "terraform -chdir={{ .parameters.terraformDir }} plan -no-color" + onFailure: stop + + - id: terraform-apply + name: Apply + capability: terraform.apply + run: "terraform -chdir={{ .parameters.terraformDir }} apply -no-color -auto-approve" + onFailure: stop diff --git a/compositions/terraform/profiles/terraform-apply.yaml b/compositions/terraform/profiles/terraform-apply.yaml new file mode 100644 index 0000000..c31b874 --- /dev/null +++ b/compositions/terraform/profiles/terraform-apply.yaml @@ -0,0 +1,20 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: terraform-apply +spec: + description: Full Terraform plan and apply for live environments + + jobs: + terraform: + includeCapabilities: + - terraform.setup + - terraform.aws-credentials + - terraform.env + - terraform.context + - terraform.fmt + - terraform.init + - terraform.workspace + - terraform.validate + - terraform.plan + - terraform.apply diff --git a/compositions/terraform/profiles/terraform-local.yaml b/compositions/terraform/profiles/terraform-local.yaml new file mode 100644 index 0000000..074e4c8 --- /dev/null +++ b/compositions/terraform/profiles/terraform-local.yaml @@ -0,0 +1,22 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: terraform-local +spec: + # Credential-free local lane: omits terraform.aws-credentials and + # terraform.apply, so it plans without assuming a role and never mutates + # infrastructure. The description previously read "Full Terraform plan and + # apply for live environments", copy-pasted from the apply profile. + description: Local Terraform plan only — no AWS credentials, no apply + + jobs: + terraform: + includeCapabilities: + - terraform.setup + - terraform.env + - terraform.context + - terraform.fmt + - terraform.init + - terraform.workspace + - terraform.validate + - terraform.plan diff --git a/compositions/terraform/profiles/terraform-plan-only.yaml b/compositions/terraform/profiles/terraform-plan-only.yaml new file mode 100644 index 0000000..87b6492 --- /dev/null +++ b/compositions/terraform/profiles/terraform-plan-only.yaml @@ -0,0 +1,19 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: terraform-plan-only +spec: + description: PR Terraform plan with no-lock flag for non-mutating preview + + jobs: + terraform: + includeCapabilities: + - terraform.setup + - terraform.aws-credentials + - terraform.env + - terraform.context + - terraform.fmt + - terraform.init + - terraform.workspace + - terraform.validate + - terraform.plan diff --git a/compositions/terraform/schema.yaml b/compositions/terraform/schema.yaml new file mode 100644 index 0000000..c8125cb --- /dev/null +++ b/compositions/terraform/schema.yaml @@ -0,0 +1,52 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: terraform-component +spec: + type: terraform + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Terraform Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: terraform + parameters: + type: object + required: + - stackName + - terraformDir + - terraformVersion + properties: + awsAccountId: + type: string + description: AWS account ID hosting the GitHub-OIDC role this component assumes + awsRegion: + type: string + lane: + type: string + namespace: + type: string + namespacePrefix: + type: string + orgName: + type: string + owner: + type: string + repo: + type: string + stackName: + type: string + terraformDir: + type: string + terraformVersion: + type: string + additionalProperties: true + additionalProperties: true diff --git a/compositions/terraform/tests/README.md b/compositions/terraform/tests/README.md deleted file mode 100644 index 89a8abe..0000000 --- a/compositions/terraform/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for terraform - -These files provide contract or smoke fixtures that CI can inspect for `terraform` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/terraform/tests/smoke/component.yaml b/compositions/terraform/tests/smoke/component.yaml deleted file mode 100644 index d63d128..0000000 --- a/compositions/terraform/tests/smoke/component.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: network-foundation - -spec: - type: terraform - domain: platform-foundation - subscribe: - environments: - - development - - staging - - production - inputs: - stackName: network-foundation - terraformDir: . - terraformVersion: 1.9.8 - labels: - team: platform - layer: foundation - stack: network \ No newline at end of file diff --git a/compositions/turbo-package/README.md b/compositions/turbo-package/README.md index 9f7a252..e12cf0d 100644 --- a/compositions/turbo-package/README.md +++ b/compositions/turbo-package/README.md @@ -4,24 +4,36 @@ ## Purpose -Verify a shared package in a pnpm and Turbo monorepo +Verify a shared package in a pnpm + Turborepo monorepo: install the workspace +with a frozen lockfile, run an optional pre-build, check the package has a +`package.json`, then build and typecheck it. Build and typecheck default to +`pnpm exec turbo run --filter=./` when no command is given. + +This composition only verifies — it publishes and deploys nothing. ## Contract - **Type:** `turbo-package` - **Path:** `compositions/turbo-package` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. +- **Composition:** `composition.yaml` +- **Schema:** `schema.yaml` — the authoritative parameter contract +- **Job:** `verify` (default) — `jobs/turbo-package-verify.yaml` +- **Default profile:** `verify` +- **Required parameters:** `nodeVersion`, `pnpmVersion` +- **Optional parameters:** `preBuildCommand`, `buildCommand`, `typecheckCommand` -- `examples/platform-sdk` +## Profiles -## Test fixtures +Each file in `profiles/` selects steps from the job by capability. -- `tests/smoke` +| Profile | Steps | +| ------------------ | ----- | +| `quick-check` | setup-node → setup-pnpm → install → verify-structure | +| `verify` (default) | setup-node → setup-pnpm → install → pre-build → verify-structure → build → typecheck | ## Verification -`./scripts/verify-composition.sh turbo-package` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. +`./scripts/verify.sh` is the catalog's only gate. It asserts that this +directory's `composition.yaml` has a `metadata.name` and `spec.type` matching +the directory, that `schema.yaml` and `jobs/` exist beside it, then packs the +catalog and confirms `turbo-package` exports from the packed artifact. diff --git a/compositions/turbo-package/composition.yaml b/compositions/turbo-package/composition.yaml new file mode 100644 index 0000000..62a24ab --- /dev/null +++ b/compositions/turbo-package/composition.yaml @@ -0,0 +1,26 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: turbo-package +spec: + type: turbo-package + description: Turborepo package verification jobs + + schemaRef: + name: turbo-package-component + + defaultJob: verify + defaultProfile: verify + + jobs: + - name: verify + templateRef: + name: turbo-package-verify + + profiles: + - name: quick-check + profileRef: + name: turbo-package-quick-check + - name: verify + profileRef: + name: turbo-package-verify diff --git a/compositions/turbo-package/compositions.yaml b/compositions/turbo-package/compositions.yaml deleted file mode 100644 index 348c62e..0000000 --- a/compositions/turbo-package/compositions.yaml +++ /dev/null @@ -1,88 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: turbo-package -spec: - type: turbo-package - description: Verify a shared package in a pnpm and Turbo monorepo - defaultJob: verify-turbo-package - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Turbo Package Component - description: Schema for shared package components validated through pnpm and Turbo - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: turbo-package - description: Component type identifier - inputs: - type: object - required: - - nodeVersion - - pnpmVersion - properties: - nodeVersion: - type: string - description: Node.js version - pnpmVersion: - type: string - description: pnpm version - preBuildCommand: - type: string - description: Optional command to run before the build (e.g. codegen, schema generation) - buildCommand: - type: string - description: Override the default turbo build command - typecheckCommand: - type: string - description: Override the default turbo typecheck command - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-turbo-package - description: Install the workspace and validate a shared package - runsOn: ubuntu-22.04 - timeout: 25m - retries: 0 - labels: - scope: verify - steps: - - id: setup-node - name: setup-node - use: actions/setup-node@v4 - with: - node-version: "{{.nodeVersion}}" - - id: setup-pnpm - name: setup-pnpm - use: pnpm/action-setup@v4 - with: - version: "{{.pnpmVersion}}" - - name: install-workspace-dependencies - run: pnpm install --no-frozen-lockfile - onFailure: stop - - name: pre-build - shell: bash - run: | - {{if .preBuildCommand}} - {{.preBuildCommand}} - {{else}} - echo "Skipping pre-build." - {{end}} - onFailure: stop - - name: verify-package-structure - run: test -f package.json - onFailure: stop - - name: build-package - run: "{{if .buildCommand}}{{.buildCommand}}{{else}}pnpm exec turbo run build --filter=./{{end}}" - onFailure: stop - - name: typecheck-package - run: "{{if .typecheckCommand}}{{.typecheckCommand}}{{else}}pnpm exec turbo run typecheck --filter=./{{end}}" - onFailure: stop diff --git a/compositions/turbo-package/examples/README.md b/compositions/turbo-package/examples/README.md deleted file mode 100644 index cdd50f1..0000000 --- a/compositions/turbo-package/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for turbo-package - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `turbo-package` looks inside a consumer repository. - -- `examples/platform-sdk` diff --git a/compositions/turbo-package/examples/platform-sdk/package.json b/compositions/turbo-package/examples/platform-sdk/package.json deleted file mode 100644 index d65acec..0000000 --- a/compositions/turbo-package/examples/platform-sdk/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "example-platform-repo", - "private": true, - "version": "1.0.0", - "description": "Turbo-style Cloudflare deployment examples for gluon component discovery", - "packageManager": "pnpm@10.12.1", - "scripts": { - "build": "turbo run build", - "typecheck": "turbo run typecheck", - "deploy": "turbo run deploy" - }, - "devDependencies": { - "turbo": "2.5.8", - "typescript": "5.9.3", - "wrangler": "4.13.2" - } -} \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/packages/sdk/component.yaml b/compositions/turbo-package/examples/platform-sdk/packages/sdk/component.yaml deleted file mode 100644 index a2bcd94..0000000 --- a/compositions/turbo-package/examples/platform-sdk/packages/sdk/component.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: platform-sdk - -spec: - type: turbo-package - domain: platform-packages - subscribe: - environments: - - dev - - development - - staging - - production - inputs: - nodeVersion: "20" - pnpmVersion: "10.12.1" - labels: - team: platform - layer: shared - surface: sdk - runtime: node \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/packages/sdk/package.json b/compositions/turbo-package/examples/platform-sdk/packages/sdk/package.json deleted file mode 100644 index 3951719..0000000 --- a/compositions/turbo-package/examples/platform-sdk/packages/sdk/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@example/sdk", - "private": true, - "version": "0.1.0", - "type": "module", - "scripts": { - "build": "tsc -p tsconfig.json --noEmit", - "typecheck": "tsc -p tsconfig.json --noEmit" - } -} \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/packages/sdk/src/index.ts b/compositions/turbo-package/examples/platform-sdk/packages/sdk/src/index.ts deleted file mode 100644 index e3959e4..0000000 --- a/compositions/turbo-package/examples/platform-sdk/packages/sdk/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function createPlatformClient(baseUrl: string): string { - return new URL("/v1", baseUrl).toString(); -} \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/packages/sdk/tsconfig.json b/compositions/turbo-package/examples/platform-sdk/packages/sdk/tsconfig.json deleted file mode 100644 index 32a6156..0000000 --- a/compositions/turbo-package/examples/platform-sdk/packages/sdk/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "include": [ - "src/**/*.ts" - ] -} \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/pnpm-workspace.yaml b/compositions/turbo-package/examples/platform-sdk/pnpm-workspace.yaml deleted file mode 100644 index c7eaed9..0000000 --- a/compositions/turbo-package/examples/platform-sdk/pnpm-workspace.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - - apps/* - - packages/* \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/tsconfig.base.json b/compositions/turbo-package/examples/platform-sdk/tsconfig.base.json deleted file mode 100644 index e7910f3..0000000 --- a/compositions/turbo-package/examples/platform-sdk/tsconfig.base.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "noEmit": true, - "lib": [ - "ES2022", - "DOM" - ] - } -} \ No newline at end of file diff --git a/compositions/turbo-package/examples/platform-sdk/turbo.json b/compositions/turbo-package/examples/platform-sdk/turbo.json deleted file mode 100644 index f24d8d7..0000000 --- a/compositions/turbo-package/examples/platform-sdk/turbo.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "$schema": "https://turborepo.com/schema.json", - "tasks": { - "build": { - "dependsOn": [ - "^build" - ], - "outputs": [ - "dist/**", - ".wrangler/**" - ] - }, - "typecheck": { - "dependsOn": [ - "^typecheck" - ], - "outputs": [] - }, - "deploy": { - "dependsOn": [ - "build" - ], - "cache": false, - "outputs": [] - } - } -} \ No newline at end of file diff --git a/compositions/turbo-package/jobs/turbo-package-verify.yaml b/compositions/turbo-package/jobs/turbo-package-verify.yaml new file mode 100644 index 0000000..ae19da9 --- /dev/null +++ b/compositions/turbo-package/jobs/turbo-package-verify.yaml @@ -0,0 +1,76 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: turbo-package-verify +spec: + description: Install the workspace and validate a shared package + runsOn: ubuntu-22.04 + timeout: 25m + retries: 0 + + labels: + scope: verify + + capabilities: + - turbo-package.setup-node + - turbo-package.setup-pnpm + - turbo-package.install + - turbo-package.pre-build + - turbo-package.verify-structure + - turbo-package.build + - turbo-package.typecheck + + steps: + # setup-pnpm runs before setup-node so setup-node can warm and persist the + # pnpm store cache (keyed on the workspace lockfile). + - id: setup-pnpm + name: setup-pnpm + capability: turbo-package.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{.parameters.pnpmVersion}}" + + - id: setup-node + name: setup-node + capability: turbo-package.setup-node + use: actions/setup-node@v6 + with: + node-version: "{{.parameters.nodeVersion}}" + cache: pnpm + cache-dependency-path: "**/pnpm-lock.yaml" + + - id: install-workspace-dependencies + name: install-workspace-dependencies + capability: turbo-package.install + run: pnpm install --frozen-lockfile + onFailure: stop + + - id: pre-build + name: pre-build + capability: turbo-package.pre-build + shell: bash + run: | + {{if .preBuildCommand}} + {{.parameters.preBuildCommand}} + {{else}} + echo "Skipping pre-build." + {{end}} + onFailure: stop + + - id: verify-package-structure + name: verify-package-structure + capability: turbo-package.verify-structure + run: test -f package.json + onFailure: stop + + - id: build-package + name: build-package + capability: turbo-package.build + run: "{{if .buildCommand}}{{.parameters.buildCommand}}{{else}}pnpm exec turbo run build --filter=./{{end}}" + onFailure: stop + + - id: typecheck-package + name: typecheck-package + capability: turbo-package.typecheck + run: "{{if .typecheckCommand}}{{.parameters.typecheckCommand}}{{else}}pnpm exec turbo run typecheck --filter=./{{end}}" + onFailure: stop diff --git a/compositions/turbo-package/profiles/turbo-package-quick-check.yaml b/compositions/turbo-package/profiles/turbo-package-quick-check.yaml new file mode 100644 index 0000000..8ec1d31 --- /dev/null +++ b/compositions/turbo-package/profiles/turbo-package-quick-check.yaml @@ -0,0 +1,14 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: turbo-package-quick-check +spec: + description: Quick check with setup and structure verification only + + jobs: + verify: + includeCapabilities: + - turbo-package.setup-node + - turbo-package.setup-pnpm + - turbo-package.install + - turbo-package.verify-structure diff --git a/compositions/turbo-package/profiles/turbo-package-verify.yaml b/compositions/turbo-package/profiles/turbo-package-verify.yaml new file mode 100644 index 0000000..8297fb6 --- /dev/null +++ b/compositions/turbo-package/profiles/turbo-package-verify.yaml @@ -0,0 +1,17 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: turbo-package-verify +spec: + description: Full verification with build and typecheck + + jobs: + verify: + includeCapabilities: + - turbo-package.setup-node + - turbo-package.setup-pnpm + - turbo-package.install + - turbo-package.pre-build + - turbo-package.verify-structure + - turbo-package.build + - turbo-package.typecheck diff --git a/compositions/turbo-package/schema.yaml b/compositions/turbo-package/schema.yaml new file mode 100644 index 0000000..c2e7d74 --- /dev/null +++ b/compositions/turbo-package/schema.yaml @@ -0,0 +1,38 @@ +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: turbo-package-component +spec: + type: turbo-package + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Turbo Package Component + type: object + required: + - name + - type + - parameters + properties: + name: + type: string + type: + type: string + const: turbo-package + parameters: + type: object + required: + - nodeVersion + - pnpmVersion + properties: + nodeVersion: + type: string + pnpmVersion: + type: string + preBuildCommand: + type: string + buildCommand: + type: string + typecheckCommand: + type: string + additionalProperties: false + additionalProperties: true diff --git a/compositions/turbo-package/tests/README.md b/compositions/turbo-package/tests/README.md deleted file mode 100644 index 7d0c3db..0000000 --- a/compositions/turbo-package/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for turbo-package - -These files provide contract or smoke fixtures that CI can inspect for `turbo-package` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/turbo-package/tests/smoke/component.yaml b/compositions/turbo-package/tests/smoke/component.yaml deleted file mode 100644 index a2bcd94..0000000 --- a/compositions/turbo-package/tests/smoke/component.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: platform-sdk - -spec: - type: turbo-package - domain: platform-packages - subscribe: - environments: - - dev - - development - - staging - - production - inputs: - nodeVersion: "20" - pnpmVersion: "10.12.1" - labels: - team: platform - layer: shared - surface: sdk - runtime: node \ No newline at end of file diff --git a/compositions/workspace/README.md b/compositions/workspace/README.md deleted file mode 100644 index 56f9732..0000000 --- a/compositions/workspace/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# workspace - -`workspace` is an exported Orun composition in the Stack Tectonic catalog. - -## Purpose - -Workspace-backed provider smoke jobs - -## Contract - -- **Type:** `workspace` -- **Path:** `compositions/workspace` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -- `examples/provider-smoke` - -## Test fixtures - -- `tests/smoke` - -## Verification - -`./scripts/verify-composition.sh workspace` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. diff --git a/compositions/workspace/compositions.yaml b/compositions/workspace/compositions.yaml deleted file mode 100644 index 036827c..0000000 --- a/compositions/workspace/compositions.yaml +++ /dev/null @@ -1,84 +0,0 @@ -apiVersion: sourceplane.io/v1alpha1 -kind: Composition -metadata: - name: workspace -spec: - type: workspace - description: Workspace-backed provider smoke jobs - defaultJob: verify-workspace - inputSchema: - $schema: http://json-schema.org/draft-07/schema# - title: Workspace Provider Smoke Component - description: Schema for a workspace-backed provider smoke test component - type: object - required: - - name - - type - - inputs - properties: - name: - type: string - description: Component name - type: - type: string - const: workspace - description: Component type identifier - inputs: - type: object - required: - - chartPath - - valuesFile - - kustomizeDir - - terraformDir - - workflowFile - properties: - AZURE_CLI_VERSION: - type: string - description: Exact Azure CLI version pinned for deterministic provider setup - chartPath: - type: string - description: Local Helm chart path - valuesFile: - type: string - description: Values file passed to helm template - kustomizeDir: - type: string - description: Kustomize root used for render-only builds - terraformDir: - type: string - description: Terraform directory checked with terraform fmt - workflowFile: - type: string - description: Workflow file rendered by torkflow view - additionalProperties: false - additionalProperties: true - jobs: - - name: verify-workspace - description: Verify workspace-installed provider tools with dry-run-safe commands - runsOn: ubuntu-22.04 - timeout: 15m - retries: 0 - labels: - scope: smoke - steps: - - name: kubectl-dry-run - run: kubectl version --client --output=yaml - onFailure: stop - - name: helm-template - run: helm template {{.Component}} {{.chartPath}} --values {{.valuesFile}} - onFailure: stop - - name: terraform-fmt-check - run: terraform fmt -check {{.terraformDir}} - onFailure: stop - - name: kustomize-build - run: kustomize build {{.kustomizeDir}} - onFailure: stop - - name: torkflow-view - run: torkflow view --workflow {{.workflowFile}} - onFailure: stop - inputs: - chartPath: charts/hello-chart/chart - valuesFile: deploy/hello-deploy/values.yaml - kustomizeDir: smoke/kustomize - terraformDir: smoke/terraform - workflowFile: smoke/provider-smoke.yaml diff --git a/compositions/workspace/examples/README.md b/compositions/workspace/examples/README.md deleted file mode 100644 index ad03279..0000000 --- a/compositions/workspace/examples/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Examples for workspace - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `workspace` looks inside a consumer repository. - -- `examples/provider-smoke` diff --git a/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/Chart.yaml b/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/Chart.yaml deleted file mode 100644 index 8da9933..0000000 --- a/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/Chart.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v2 -name: identity-portal -description: Helm chart for the customer identity portal -type: application -version: 0.1.0 -appVersion: "1.0.0" \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/templates/configmap.yaml b/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/templates/configmap.yaml deleted file mode 100644 index 80fd892..0000000 --- a/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/templates/configmap.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ default .Chart.Name .Values.nameOverride }} - labels: - app.kubernetes.io/name: {{ .Chart.Name }} - app.kubernetes.io/instance: {{ .Release.Name }} -data: - message: {{ .Values.config.message | quote }} - environment: {{ .Values.config.environment | quote }} - color: {{ .Values.config.color | quote }} \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/values.yaml b/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/values.yaml deleted file mode 100644 index d3272b6..0000000 --- a/compositions/workspace/examples/provider-smoke/charts/hello-chart/chart/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -nameOverride: identity-portal -config: - message: identity portal application configuration - environment: shared - color: blue \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/component.yaml b/compositions/workspace/examples/provider-smoke/component.yaml deleted file mode 100644 index 453169f..0000000 --- a/compositions/workspace/examples/provider-smoke/component.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: provider-smoke - -spec: - type: workspace - domain: platform-foundation - subscribe: - environments: - - development - - staging - inputs: - chartPath: charts/hello-chart/chart - valuesFile: deploy/hello-deploy/values.yaml - kustomizeDir: smoke/kustomize - terraformDir: smoke/terraform - workflowFile: smoke/provider-smoke.yaml - labels: - team: platform - layer: foundation - surface: provider-smoke diff --git a/compositions/workspace/examples/provider-smoke/deploy/hello-deploy/values.yaml b/compositions/workspace/examples/provider-smoke/deploy/hello-deploy/values.yaml deleted file mode 100644 index e71ead5..0000000 --- a/compositions/workspace/examples/provider-smoke/deploy/hello-deploy/values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -nameOverride: identity-portal -config: - message: identity portal delivery values - environment: development - color: amber \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/smoke/kustomize/configmap.yaml b/compositions/workspace/examples/provider-smoke/smoke/kustomize/configmap.yaml deleted file mode 100644 index e7328d3..0000000 --- a/compositions/workspace/examples/provider-smoke/smoke/kustomize/configmap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: workspace-provider-smoke -data: - source: kustomize \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/smoke/kustomize/kustomization.yaml b/compositions/workspace/examples/provider-smoke/smoke/kustomize/kustomization.yaml deleted file mode 100644 index 490c6c9..0000000 --- a/compositions/workspace/examples/provider-smoke/smoke/kustomize/kustomization.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - configmap.yaml \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/smoke/provider-smoke.yaml b/compositions/workspace/examples/provider-smoke/smoke/provider-smoke.yaml deleted file mode 100644 index b52ad9b..0000000 --- a/compositions/workspace/examples/provider-smoke/smoke/provider-smoke.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: torkflow/v1 -kind: Workflow -metadata: - name: provider-smoke - id: provider-smoke -spec: - maxParallelSteps: 1 - steps: - - name: Summarize_Intent - actionRef: core.js - parameters: - script: "({ message: 'provider-native dry-run flow' })" - outboundEdges: - - nextStepName: Print_Result - - - name: Print_Result - actionRef: core.stdout - parameters: - title: Provider Smoke - format: text - payload: - message: "{{ Steps.Summarize_Intent.message }}" \ No newline at end of file diff --git a/compositions/workspace/examples/provider-smoke/smoke/terraform/main.tf b/compositions/workspace/examples/provider-smoke/smoke/terraform/main.tf deleted file mode 100644 index cee63b0..0000000 --- a/compositions/workspace/examples/provider-smoke/smoke/terraform/main.tf +++ /dev/null @@ -1,7 +0,0 @@ -terraform { - required_version = ">= 1.6.0" -} - -locals { - smoke_message = "workspace-provider-smoke" -} \ No newline at end of file diff --git a/compositions/workspace/tests/README.md b/compositions/workspace/tests/README.md deleted file mode 100644 index eade93c..0000000 --- a/compositions/workspace/tests/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Tests for workspace - -These files provide contract or smoke fixtures that CI can inspect for `workspace` without requiring a full consumer repository checkout. - -- `tests/smoke` diff --git a/compositions/workspace/tests/smoke/component.yaml b/compositions/workspace/tests/smoke/component.yaml deleted file mode 100644 index dd2e53f..0000000 --- a/compositions/workspace/tests/smoke/component.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: sourceplane.io/v1 -kind: Component - -metadata: - name: provider-smoke - -spec: - type: workspace - domain: platform-foundation - subscribe: - environments: - - development - inputs: - chartPath: charts/hello-chart/chart - valuesFile: deploy/hello-deploy/values.yaml - kustomizeDir: smoke/kustomize - terraformDir: smoke/terraform - workflowFile: smoke/provider-smoke.yaml diff --git a/docs/authoring.md b/docs/authoring.md index 306f553..be0ae29 100644 --- a/docs/authoring.md +++ b/docs/authoring.md @@ -1,22 +1,219 @@ # Authoring guide -## Add a composition +A composition is not one file. It is a directory of four kinds of document, each with its own +`kind:` and its own `metadata.name`, wired together by reference: + +```text +compositions// +├── composition.yaml # kind: Composition +├── schema.yaml # kind: ComponentSchema +├── jobs/.yaml # kind: JobTemplate +├── profiles/

.yaml # kind: ExecutionProfile +└── README.md +``` + +The worked example below is `compositions/turbo-package`, the smallest composition in the catalog. + +## 1. `composition.yaml` + +The entry point. It names the type, points at the schema, lists the job templates and execution +profiles, and picks the defaults. + +```yaml +apiVersion: sourceplane.io/v1alpha1 +kind: Composition +metadata: + name: turbo-package +spec: + type: turbo-package + description: Turborepo package verification jobs + + schemaRef: + name: turbo-package-component + + defaultJob: verify + defaultProfile: verify + + jobs: + - name: verify + templateRef: + name: turbo-package-verify + + profiles: + - name: quick-check + profileRef: + name: turbo-package-quick-check + - name: verify + profileRef: + name: turbo-package-verify +``` + +`metadata.name` and `spec.type` must both equal the directory name — `scripts/verify.sh` fails the +build otherwise. + +Note the two namespaces. `jobs[].name` and `profiles[].name` are the short names a component uses +(`profile: quick-check`). `templateRef.name` and `profileRef.name` are the `metadata.name` of the +documents under `jobs/` and `profiles/`, which are prefixed with the composition name to stay unique +across the catalog. + +## 2. `schema.yaml` + +A `ComponentSchema` holding a JSON Schema (draft-07) for the component document. Constrain `type` +with a `const` so a mistyped component fails validation, and set +`parameters.additionalProperties: false` so unknown parameters are caught rather than silently +ignored. + +```yaml +apiVersion: sourceplane.io/v1alpha1 +kind: ComponentSchema +metadata: + name: turbo-package-component +spec: + type: turbo-package + schema: + $schema: http://json-schema.org/draft-07/schema# + title: Turbo Package Component + type: object + required: [name, type, parameters] + properties: + name: + type: string + type: + type: string + const: turbo-package + parameters: + type: object + required: [nodeVersion, pnpmVersion] + properties: + nodeVersion: { type: string } + pnpmVersion: { type: string } + preBuildCommand: { type: string } + buildCommand: { type: string } + typecheckCommand: { type: string } + additionalProperties: false + additionalProperties: true +``` + +`metadata.name` here is what `composition.yaml`'s `schemaRef.name` points at. + +## 3. `jobs/.yaml` + +A `JobTemplate` declares the full set of `capabilities` the job can perform, then defines the +`steps` that implement them. Every step carries a `capability` tag. Steps either `run` a shell +command or `use` a GitHub Action with `with:` inputs, and component parameters are interpolated as +`{{ .parameters. }}`. -1. Create `compositions//compositions.yaml`. -2. Describe the contract in `spec.description`, `spec.inputSchema`, and `spec.jobs`. -3. Add at least one realistic fixture under `examples/` and one smoke or contract fixture under `tests/`, preferably excerpted or adapted from a consumer-style repo. -4. Run `./scripts/generate-readme.sh` to refresh the generated composition README summaries. -5. Run `./scripts/score.sh` and `./scripts/verify.sh`. +```yaml +apiVersion: sourceplane.io/v1alpha1 +kind: JobTemplate +metadata: + name: turbo-package-verify +spec: + description: Install the workspace and validate a shared package + runsOn: ubuntu-22.04 + timeout: 25m + retries: 0 -## Add a blueprint + labels: + scope: verify + + capabilities: + - turbo-package.setup-node + - turbo-package.setup-pnpm + - turbo-package.install + - turbo-package.pre-build + - turbo-package.verify-structure + - turbo-package.build + - turbo-package.typecheck + + steps: + - id: setup-pnpm + name: setup-pnpm + capability: turbo-package.setup-pnpm + use: pnpm/action-setup@v4 + with: + version: "{{.parameters.pnpmVersion}}" + + # ... install, pre-build, verify-structure ... + + - id: build-package + name: build-package + capability: turbo-package.build + run: "{{if .buildCommand}}{{.parameters.buildCommand}}{{else}}pnpm exec turbo run build --filter=./{{end}}" + onFailure: stop +``` + +Conventions worth keeping: + +- Namespace capabilities as `.` so they stay unique across the catalog. +- One capability per step, and keep steps atomic — a capability that bundles "build and deploy" + cannot be split across profiles later. +- Set `onFailure: stop` on steps that must not be skipped past. +- Order matters: steps run in file order, and profiles filter that order rather than reordering it. + +## 4. `profiles/.yaml` + +An `ExecutionProfile` selects which capabilities of which job actually run. This is how one job +template serves several lanes. + +```yaml +apiVersion: sourceplane.io/v1alpha1 +kind: ExecutionProfile +metadata: + name: turbo-package-quick-check +spec: + description: Quick check with setup and structure verification only + + jobs: + verify: + includeCapabilities: + - turbo-package.setup-node + - turbo-package.setup-pnpm + - turbo-package.install + - turbo-package.verify-structure +``` + +The key under `jobs:` is the short job name from `composition.yaml` (`verify`), not the template +name. The sibling `turbo-package-verify` profile includes the same list plus `pre-build`, `build`, +and `typecheck` — that difference is the entire distinction between the two lanes. + +Profiles may also carry `policies`. `compositions/cloudflare-pages/profiles/cloudflare-pages-deploy.yaml` +sets `requireApproval: true` and `requireCleanGitTree: true`; `publish-stack`'s `release` profile +sets `requireCleanGitTree: true`. Attach those to the mutating profiles, not the verification ones. + +### Choosing a profile from a component + +Consumers bind a profile per environment, which is why the same composition can be non-mutating on a +pull request and mutating on production: + +```yaml +spec: + type: cloudflare-pages + subscribe: + environments: + - name: staging + profile: verify + - name: production + profile: deploy +``` + +If a component names no profile, `spec.defaultProfile` from `composition.yaml` applies. + +## Add a composition -1. Create `blueprints//blueprint.yaml`. -2. Document the composition set in `blueprints//README.md`. -3. Add example references or starter intent snippets if the blueprint introduces a new adoption path. +1. Create `compositions//` and write the four documents above. Keep `metadata.name` and + `spec.type` in `composition.yaml` equal to the directory name. +2. Give the composition at least one non-mutating profile and, if it mutates anything, one mutating + profile guarded by policies. +3. Add a realistic fixture under `compositions//tests/smoke/component.yaml`, preferably + excerpted or adapted from a consumer-style repo. +4. Write `compositions//README.md` documenting the parameters and the profiles. +5. Run `./scripts/verify.sh`. ## Keep the catalog clean -- Prefer atomic compositions over variant explosions. -- Use blueprints for recommended assemblies. -- Keep example and test fixtures close enough to real repositories that they can guide consumers and feed CI trust signals. +- Prefer atomic compositions over variant explosions; prefer a new profile over a new composition + when the only difference is which steps run. +- Keep capabilities fine-grained enough that a future profile can pick a subset of them. +- Keep fixtures close enough to real repositories that they can guide consumers and feed CI. - Keep the OCI consumption story pinned to released versions, not floating refs. diff --git a/docs/concepts.md b/docs/concepts.md index 9de366b..7b6445e 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -6,27 +6,26 @@ This repository is a catalog, not an application repo. It publishes versioned ex ## Compositions -`compositions/` contains atomic Orun `Composition` contracts. These are the stable type-level building blocks exported by the stack package. +`compositions/` contains atomic Orun `Composition` contracts. These are the stable type-level building blocks exported by the stack package, one directory per exported type. -## Blueprints +## Component schemas -`blueprints/` groups recommended multi-composition patterns for common adoption paths. Blueprints are human-facing catalog assets that explain how multiple compositions fit together. +Each composition ships a `ComponentSchema` in `schema.yaml`: a JSON Schema (draft-07) that constrains the `parameters` block of a consumer's `component.yaml`. It is what makes a typo in a parameter name a validation failure rather than a silently ignored key. -## Examples +## Job templates -`examples/` contains starter intents that show how a consumer repo can reference the OCI package and structure discovery roots. +`jobs/.yaml` holds a `JobTemplate`: the runner, timeout, the full list of `capabilities` the job can perform, and the ordered `steps` that implement them. Every step is tagged with exactly one capability. -## Registry index +## Execution profiles -`registry/index.json` is generated catalog metadata for future search, score, and registry sync workflows. +`profiles/.yaml` holds an `ExecutionProfile`, which lists the capabilities to include for each job. A profile is a subset of a job template, so a plan-only lane and a release lane share one set of steps instead of duplicating them. Profiles may also carry `policies` such as `requireApproval` or `requireCleanGitTree`, which is where mutating lanes get their guardrails. -## Trust model +Consumers select a profile per environment under `subscribe.environments`; `spec.defaultProfile` in `composition.yaml` applies when none is named. -The stack separates verification into: +## Examples -- contract validation -- docs hygiene -- score generation -- tagged release publication +`examples/` contains starter intents that show how a consumer repo can reference the OCI package and structure discovery roots. + +## Trust model -That split keeps discovery and trust signals visible without coupling them to a single flat workflow. +There is one gate, `scripts/verify.sh`, run by two workflows. It validates every composition contract structurally, resolves the publish target with a dry run, then packs the layers that actually ship and resolves the packed artifact back through a throwaway consumer intent. Release automation runs the identical gate before it publishes a tag. See [verification.md](verification.md). diff --git a/docs/getting-started.md b/docs/getting-started.md index f34c938..c4aefb0 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -15,14 +15,31 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.11.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 ``` ## 3. Discover local components Point `discovery.roots` at the application, infra, and deploy directories that own `component.yaml` files. -## 4. Plan and apply +## 4. Pick a profile per environment + +Each component subscribes to environments and names the execution profile that runs there: + +```yaml +spec: + type: cloudflare-pages + subscribe: + environments: + - name: development + profile: pull-request + - name: production + profile: deploy +``` + +A profile selects a subset of the composition's job steps, so the non-mutating and mutating lanes come from the same contract. Omit `profile` and the composition's default applies. + +## 5. Plan and apply Run `orun validate`, `orun plan`, or `orun run` against that intent. The stack stays versioned independently from the consuming repository. diff --git a/docs/production-deploys.md b/docs/production-deploys.md index 8cb458f..6b2cade 100644 --- a/docs/production-deploys.md +++ b/docs/production-deploys.md @@ -65,24 +65,69 @@ jobs: ## Composition behavior -Stack-tectonic Cloudflare compositions (`cloudflare-worker-turbo`, `cloudflare-worker`, `cloudflare-pages-turbo`, `cloudflare-pages`) all follow the same deploy semantics: +Deployment is not gated inside the job steps. It is decided entirely by which **execution profile** +an environment subscribes to: a deploy only happens when the selected profile includes the +composition's `deploy` capability. -| Condition | Behavior | CI annotation | +For `cloudflare-pages`, `cloudflare-pages-turbo`, `cloudflare-worker`, `cloudflare-worker-turbo`, +and `cloudflare-workers-assets-turbo`: + +| Profile | What runs | Mutating? | | --- | --- | --- | -| Environment = `dev` | Dry-run only | `DRY-RUN` | -| Environment != `production` or branch != `productionBranch` | Skip deploy | `SKIPPED` | -| Environment = `production` AND branch = `productionBranch` AND credentials present | Live deploy | `LIVE DEPLOY` → `DEPLOY SUCCESS` | -| Credentials missing on production deploy | Hard failure | Step fails with clear error | +| `pull-request` | setup, install, structure/build verification | no | +| `verify` | `pull-request` plus `deploy-dry-run` where the composition has one | no | +| `deploy` | the full pipeline through `provision`/`deploy` and `smoke` | yes | -## Verifying a deploy actually happened +`cloudflare-pages` and `cloudflare-pages-turbo` have no `deploy-dry-run` capability, so their +`verify` lane stops at build-output verification. The `cloudflare-worker*` compositions do have one. + +The Terraform-reconciled variants (`cloudflare-pages-terraform`, `cloudflare-pages-turbo-terraform`) +use the same shape with `terraform-plan` in `verify` and `terraform-apply` in `release`. + +Guardrails come from profile policies rather than in-step branch checks. Every mutating profile in +the catalog sets: + +```yaml +policies: + requireApproval: true + requireCleanGitTree: true +``` + +Credentials are still enforced at the step: `deploy` steps assert `CLOUDFLARE_ACCOUNT_ID` and +`CLOUDFLARE_API_TOKEN` are set and hard-fail when they are missing, rather than silently skipping. -After a production push, check CI logs for: -- `::notice::LIVE DEPLOY: Deploying to Cloudflare` -- `::notice::DEPLOY SUCCESS: deployed to Cloudflare` +The `deployBranch` parameter is not a gate — it is the branch name passed to +`wrangler pages deploy --branch` and to the Pages project's `production_branch` setting. + +## Wiring a component + +Bind the mutating profile only to the environment that should actually deploy: + +```yaml +spec: + type: cloudflare-pages-turbo + subscribe: + environments: + - name: preview + profile: pull-request + - name: staging + profile: verify + - name: production + profile: deploy +``` + +If an environment names no profile, the composition's `spec.defaultProfile` applies — which is +`verify` for every Cloudflare composition in this catalog, i.e. non-mutating. An environment that +should deploy must say so explicitly. + +## Verifying a deploy actually happened -If you see only `SKIPPED` or `DRY-RUN` annotations, the deploy did not run. +Check the executed step list for the run, not just its colour. If the run for the production +environment shows only the setup, install, build, and verification steps, the environment resolved a +non-mutating profile and nothing was deployed. -A green run with `0 components x 3 envs -> 0 jobs` means **no deployment occurred**. This is never evidence of a successful deploy. +A green run reporting `0 components x 3 envs -> 0 jobs` means **no deployment occurred**. This is +never evidence of a successful deploy. ## Consumer repo checklist @@ -90,7 +135,8 @@ Before relying on production deploys: 1. Set `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` as GitHub repository secrets 2. Ensure your workflow passes these as environment variables to the `orun run` step -3. Choose one of the patterns above for your production branch push behavior -4. Replace `PLACEHOLDER` database IDs in `wrangler.jsonc` with real resource IDs -5. If using D1, configure `migrationCommand` in your `component.yaml` inputs -6. Optionally add `smokeCommand` to verify the live endpoint after deploy +3. Subscribe the production environment to the composition's `deploy` (or `release`) profile +4. Choose one of the patterns above for your production branch push behavior +5. Replace `PLACEHOLDER` database IDs in `wrangler.jsonc` with real resource IDs +6. If using D1, configure `migrationCommand` in your `component.yaml` parameters +7. Optionally add `smokeCommand` to verify the live endpoint after deploy diff --git a/docs/remote-state-matrix-ci.md b/docs/remote-state-matrix-ci.md index 2bc90d7..a8b9ed8 100644 --- a/docs/remote-state-matrix-ci.md +++ b/docs/remote-state-matrix-ci.md @@ -23,7 +23,7 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.12.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 ``` ## Default workflow template @@ -103,4 +103,4 @@ jobs: - plan artifact reuse across matrix runners - changed-only pull request and main-branch planning - remote-state coordination across parallel GitHub Actions runners -- a pinned Orun GitHub Action version instead of a separate `kiox` workspace +- a pinned Orun GitHub Action version, pinned independently from the catalog release in `intent.yaml` diff --git a/docs/roadmap.md b/docs/roadmap.md index 712f81d..19052a3 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,8 +1,11 @@ # Roadmap -- Add runnable composition-level examples beyond starter placeholders. -- Add stronger smoke tests for every exported composition. -- Publish richer registry metadata for search and registry sync. +- Add a smoke fixture under `tests/smoke/` for the seven compositions that still lack one: + `cloudflare-worker`, `cloudflare-worker-turbo`, `cloudflare-workers-assets-turbo`, `db-migrate`, + `publish-stack`, `terraform`, and `turbo-package`. +- Extend `scripts/verify.sh` to validate smoke fixtures against each composition's `schema.yaml`, + not just the structural presence of the contract files. +- Give every composition a README documenting its parameters and profiles; `db-migrate` has none yet. +- Add runnable composition-level examples beyond starter intents. +- Add scheduled verification so packaging regressions surface without waiting for a pull request. - Add download and adoption metrics once the consumer footprint grows. -- Introduce more opinionated blueprints for full SaaS and internal platform topologies. -- Add scheduled verification so scores can track freshness over time. diff --git a/docs/using-this-stack-from-oci.md b/docs/using-this-stack-from-oci.md index b6dbd3c..a19c888 100644 --- a/docs/using-this-stack-from-oci.md +++ b/docs/using-this-stack-from-oci.md @@ -8,21 +8,26 @@ This repository is meant to be consumed from other repositories as a versioned O ## What this stack publishes -The published OCI artifact contains the composition contracts under `compositions/` plus the surrounding catalog metadata that explains how to use them. +The published OCI artifact ships three layers: `stack.yaml`, the composition contracts under +`compositions/`, and the starter intents under `examples/`. -Today the exported composition types are: +The exported composition types are: +- `cloudflare-domain` - `cloudflare-pages` - `cloudflare-pages-turbo` - `cloudflare-pages-terraform` - `cloudflare-pages-turbo-terraform` - `cloudflare-worker` - `cloudflare-worker-turbo` +- `cloudflare-workers-assets-turbo` +- `db-migrate` +- `publish-stack` - `terraform` -- `helm-chart` -- `helm-values` - `turbo-package` -- `workspace` + +Each type is a directory under `compositions//` holding `composition.yaml`, `schema.yaml`, +`jobs/`, and `profiles/`. See [authoring.md](authoring.md) for what each document does. ## The split to keep in mind @@ -47,7 +52,7 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.12.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 discovery: roots: @@ -63,7 +68,7 @@ environments: The important line is the OCI source: ```yaml -ref: oci://ghcr.io/sourceplane/stack-tectonic:0.12.0 +ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 ``` Pin a released version instead of `latest` so plans stay reproducible. @@ -76,36 +81,60 @@ Use the copyable workflow in [remote-state-matrix-ci.md](remote-state-matrix-ci. The consuming repository should keep `component.yaml` files next to the code or infrastructure they own. -Example: +Example, adapted from `compositions/cloudflare-pages/tests/smoke/component.yaml`: ```yaml apiVersion: sourceplane.io/v1 kind: Component + metadata: name: marketing-site spec: type: cloudflare-pages - domain: edge + lifecycle: production + owner: platform + domain: platform-docs + path: website + subscribe: - environments: [development, production] - inputs: - siteDir: . + environments: + - name: development + profile: pull-request + - name: production + profile: deploy + + parameters: + nodeVersion: "20" + appDir: . installCommand: pnpm install --frozen-lockfile buildCommand: pnpm run build outputDir: dist projectName: marketing-site - nodeVersion: "20" - productionBranch: main + deployBranch: main ``` The component stays repo-local. Only the execution contract for `cloudflare-pages` comes from the OCI package. +## Choosing a profile per environment + +Each entry under `subscribe.environments` names the execution profile that environment runs. A +profile includes a subset of the job's capabilities, so the same component can build and verify on a +pull request and additionally provision, deploy, and smoke-test on production. Omit `profile` and +the composition's `spec.defaultProfile` applies. + +Consult the composition's README for its profile list, or run `orun compositions list --long` +against your intent. + ## Recommended adoption path -1. Start with atomic compositions like `terraform`, `cloudflare-pages`, or `workspace`. -2. Adopt monorepo-aware types like `turbo-package` or `cloudflare-pages-turbo` when the repo needs them. -3. Use the blueprints in this repo as guidance for multi-composition rollouts. +1. Start with atomic compositions like `terraform`, `cloudflare-pages`, or `turbo-package`. +2. Adopt monorepo-aware types like `cloudflare-pages-turbo`, `cloudflare-worker-turbo`, or + `cloudflare-workers-assets-turbo` when the repo needs them. +3. Layer in the Terraform-reconciled variants (`cloudflare-pages-terraform`, + `cloudflare-pages-turbo-terraform`, `cloudflare-domain`) once projects and DNS need to be managed + as infrastructure rather than created by hand. +4. Use the starter intents under `examples/` as a shape reference for multi-composition repos. ## Upgrade flow @@ -118,14 +147,13 @@ The component stays repo-local. Only the execution contract for `cloudflare-page For the default consumer workflow that compiles a single plan and runs it through a remote-state matrix in GitHub Actions, see [remote-state-matrix-ci.md](remote-state-matrix-ci.md). -## Why this repo now uses a catalog structure +## Why this repo uses a catalog structure -The old flat layout worked for a small prototype, but it would become noisy as the stack grows. The current layout separates: +The layout separates: -- `compositions/` for atomic contracts -- `blueprints/` for recommended assemblies +- `compositions/` for atomic contracts, each decomposed into schema, job templates, and profiles - `examples/` for starter consumer intents -- `registry/` for generated catalog metadata - `docs/` for consumer and contributor guidance +- `scripts/` and `.github/workflows/` for the release gate -That makes the stack easier to search, test, score, version, and eventually sync into a broader registry experience. +That makes the stack easier to search, test, version, and consume one type at a time. diff --git a/docs/verification.md b/docs/verification.md index ab54ecc..bf57e8a 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -1,51 +1,79 @@ # Verification model -The repository uses a split verification model so the stack can scale as a catalog. +The catalog has one gate, `scripts/verify.sh`, and two workflows that run it. -## Verify workflow +## `scripts/verify.sh` -`verify.yml` splits verification into two lanes: +The script runs from the repository root and executes four stages in order. Any failure stops the run. -- a composition matrix that runs `./scripts/verify-composition.sh ` for every exported type -- a full catalog lane that runs `./scripts/verify.sh` +### 1. Structural validation of every composition contract -The full catalog lane: +For each `compositions/*/composition.yaml`: -- checks generated composition docs are up to date -- checks the generated registry index is current -- checks every composition has example and test fixtures beyond placeholder READMEs -- runs the same OCI dry-run publish path used by release automation +- `metadata.name` must equal the directory name +- `spec.type` must equal the directory name +- `schema.yaml` must exist beside it +- `jobs/` must exist beside it -## Docs workflow +The run also fails if no composition directories are found at all, so an empty or mis-staged tree +cannot pass silently. -`docs.yml` enforces catalog scaffolding generated by `./scripts/generate-readme.sh`. +### 2. Publish target resolution -## Scorecard workflow +```bash +orun publish "ghcr.io/sourceplane/stack-tectonic:${stack_version}" \ + --dry-run --root . --version "${stack_version}" +``` -`scorecard.yml` rebuilds `registry/index.json` and fails if the checked-in catalog scorecard is stale. +`stack_version` is read from `metadata.version` in `stack.yaml`. This resolves the manifest and the +registry target without uploading anything. -## Release workflow +### 3. Pack the shipped layers + +`orun pack` archives whatever root it is given, but `orun publish` ships only `stack.yaml`, +`compositions/`, and `examples/`. The script stages exactly that subset into a temporary directory +and packs it, so the artifact under test is the artifact consumers actually resolve. + +### 4. Resolve the packed artifact back through a consumer intent + +The script writes a throwaway `intent.yaml` pointing at the packed tarball with an `archive` +composition source: -`release.yml` validates the tag against `stack.yaml`, reruns the full catalog verification, publishes the OCI package, and attaches the registry index to the GitHub release. +```yaml +compositions: + sources: + - name: stack-tectonic + kind: archive + path: /stack.tgz +``` -## Score model +It then runs `orun compositions list --intent intent.yaml` and asserts that every composition +directory in the repo appears in the output. -The generated scorecard currently evaluates: +This last stage is the point of the script. A dry-run publish only proves the manifest and target +resolve; it is no evidence the package is loadable. Packing and re-resolving exercises the same code +path a consumer repository runs, so a composition Orun cannot load or export fails here instead of +in a downstream repo after release. + +## Verify workflow + +`.github/workflows/verify.yml` runs on every pull request and every push to `main`. It is a single +`verify-stack` job: check out, log in to GHCR, set up Orun via `sourceplane/orun-action`, and run +`./scripts/verify.sh`. + +## Release workflow -| Signal | Points | -| --- | ---: | -| Has composition README | 10 | -| Has example assets | 15 | -| Has test assets | 25 | -| Verified by repo automation | 20 | -| Semantic versioned stack | 10 | -| Has usable docs | 10 | -| Has scorecard/security workflow | 10 | +`.github/workflows/release.yml` runs on tag pushes matching `v*`: -Grades: +1. Derive the version from `metadata.version` in `stack.yaml` and assert it equals the tag without + its leading `v`. A mismatched tag fails the release before anything is published. +2. Run `./scripts/verify.sh` — the same gate the pull request ran. +3. Create the GitHub release with `gh release create --generate-notes`, skipping if it already exists. +4. Publish the OCI package with an explicit target. The target is passed explicitly because with no + ref `orun` infers `ghcr.io///` from the git remote, which is the wrong + repository path. +5. Confirm the package is pullable: `orun fetch` into a temp directory, assert `stack.yaml` is + present, and report the exported composition count. -- `A+` trusted -- `A` strong -- `B` stable -- `C` experimental -- `D` legacy +The package push deliberately runs *after* the release is created, so the tag and release notes are +the record of record before the immutable artifact exists. diff --git a/examples/full-enterprise/intent.yaml b/examples/full-enterprise/intent.yaml index e58cdeb..129dc8a 100644 --- a/examples/full-enterprise/intent.yaml +++ b/examples/full-enterprise/intent.yaml @@ -7,14 +7,13 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.11.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 discovery: roots: - apps - packages - infra - - charts - deploy - website diff --git a/examples/monorepo-platform/intent.yaml b/examples/monorepo-platform/intent.yaml index 559a047..da40f03 100644 --- a/examples/monorepo-platform/intent.yaml +++ b/examples/monorepo-platform/intent.yaml @@ -7,7 +7,7 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.11.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 discovery: roots: diff --git a/examples/simple-nextjs/intent.yaml b/examples/simple-nextjs/intent.yaml index 90328a7..012c98a 100644 --- a/examples/simple-nextjs/intent.yaml +++ b/examples/simple-nextjs/intent.yaml @@ -7,7 +7,7 @@ compositions: sources: - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.11.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.13.0 discovery: roots: diff --git a/registry/index.json b/registry/index.json deleted file mode 100644 index 35d5348..0000000 --- a/registry/index.json +++ /dev/null @@ -1,329 +0,0 @@ -{ - "stack": { - "name": "stack-tectonic", - "title": "Stack Tectonic", - "version": "0.12.0", - "oci": "oci://ghcr.io/sourceplane/stack-tectonic:0.12.0" - }, - "catalog": { - "compositions": [ - { - "name": "cloudflare-pages", - "kind": "composition", - "path": "compositions/cloudflare-pages", - "description": "Build static site assets and direct-upload them to Cloudflare Pages with Wrangler", - "category": "hosting", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "cloudflare", - "hosting", - "pages" - ], - "signals": { - "readme": true, - "exampleAssets": 6, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "cloudflare-pages-terraform", - "kind": "composition", - "path": "compositions/cloudflare-pages-terraform", - "description": "Verify static site builds locally and reconcile a Git-backed Cloudflare Pages project with Terraform", - "category": "platform", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "cloudflare", - "pages", - "platform", - "terraform" - ], - "signals": { - "readme": true, - "exampleAssets": 7, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "cloudflare-pages-turbo", - "kind": "composition", - "path": "compositions/cloudflare-pages-turbo", - "description": "Build a static app with Turbo and direct-upload it to Cloudflare Pages", - "category": "hosting", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "cloudflare", - "hosting", - "pages", - "turbo" - ], - "signals": { - "readme": true, - "exampleAssets": 8, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "cloudflare-pages-turbo-terraform", - "kind": "composition", - "path": "compositions/cloudflare-pages-turbo-terraform", - "description": "Verify a static app with Turbo locally and reconcile a Git-backed Cloudflare Pages project with Terraform", - "category": "platform", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "cloudflare", - "pages", - "platform", - "terraform", - "turbo" - ], - "signals": { - "readme": true, - "exampleAssets": 9, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "cloudflare-worker", - "kind": "composition", - "path": "compositions/cloudflare-worker", - "description": "Verify a Cloudflare Worker app and deploy it from the production branch", - "category": "edge", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "cloudflare", - "edge", - "worker" - ], - "signals": { - "readme": true, - "exampleAssets": 9, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "cloudflare-worker-turbo", - "kind": "composition", - "path": "compositions/cloudflare-worker-turbo", - "description": "Verify a Cloudflare Worker app and deploy it from the production branch", - "category": "edge", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "cloudflare", - "edge", - "turbo", - "worker" - ], - "signals": { - "readme": true, - "exampleAssets": 9, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "helm-chart", - "kind": "composition", - "path": "compositions/helm-chart", - "description": "Helm chart validation jobs for chart components", - "category": "kubernetes", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "chart", - "helm", - "kubernetes" - ], - "signals": { - "readme": true, - "exampleAssets": 5, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "helm-values", - "kind": "composition", - "path": "compositions/helm-values", - "description": "Helm values validation jobs for deployment files", - "category": "kubernetes", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "helm", - "kubernetes", - "values" - ], - "signals": { - "readme": true, - "exampleAssets": 5, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "terraform", - "kind": "composition", - "path": "compositions/terraform", - "description": "Terraform validation jobs for infra components", - "category": "infrastructure", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "infrastructure", - "terraform" - ], - "signals": { - "readme": true, - "exampleAssets": 2, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "turbo-package", - "kind": "composition", - "path": "compositions/turbo-package", - "description": "Verify a shared package in a pnpm and Turbo monorepo", - "category": "developer-experience", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "developer-experience", - "package", - "turbo" - ], - "signals": { - "readme": true, - "exampleAssets": 8, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - }, - { - "name": "workspace", - "kind": "composition", - "path": "compositions/workspace", - "description": "Workspace-backed provider smoke jobs", - "category": "developer-experience", - "verified": true, - "score": 100, - "grade": "A+", - "tags": [ - "developer-experience", - "workspace" - ], - "signals": { - "readme": true, - "exampleAssets": 9, - "testAssets": 1, - "verifyWorkflow": true, - "releaseWorkflow": true, - "scorecardWorkflow": true, - "semver": true, - "docsGood": true - } - } - ], - "blueprints": [ - { - "name": "edge-worker-platform", - "kind": "blueprint", - "path": "blueprints/edge-worker-platform", - "description": "Edge-worker delivery with workspace verification, Terraform foundations, and deploy overlays.", - "uses": [ - "workspace", - "terraform", - "cloudflare-worker", - "helm-values", - "Worker validation and deployment", - "Infra validation", - "Environment configuration overlays" - ], - "verified": true, - "score": 80, - "grade": "A" - }, - { - "name": "nextjs-cloudflare", - "kind": "blueprint", - "path": "blueprints/nextjs-cloudflare", - "description": "Next.js monorepo delivery on Cloudflare with Terraform-managed Pages resources.", - "uses": [ - "workspace", - "turbo-package", - "cloudflare-pages-turbo", - "cloudflare-pages-terraform", - "Shared workspace validation", - "Monorepo package verification", - "Git-backed Pages provisioning", - "Edge-hosted frontend delivery" - ], - "verified": true, - "score": 80, - "grade": "A" - } - ] - } -} diff --git a/scripts/generate-readme.sh b/scripts/generate-readme.sh deleted file mode 100755 index aa4d9cd..0000000 --- a/scripts/generate-readme.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -check_mode="${1:-}" - -python3 - "$repo_root" "$check_mode" <<'PY' -from pathlib import Path -import re -import sys - -root = Path(sys.argv[1]) -check_mode = sys.argv[2] == "--check" -dirty: list[str] = [] - - -def extract(pattern: str, text: str) -> str: - match = re.search(pattern, text, re.MULTILINE) - if not match: - raise SystemExit(f"missing pattern: {pattern!r}") - return match.group(1).strip() - - -def write_or_check(path: Path, content: str) -> None: - normalized = content.rstrip() + "\n" - current = path.read_text() if path.exists() else None - if current == normalized: - return - dirty.append(str(path.relative_to(root))) - if not check_mode: - path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(normalized) - - -def top_level_assets(directory: Path) -> list[str]: - if not directory.exists(): - return [] - items: set[str] = set() - for path in directory.rglob("*"): - if not path.is_file() or path.name.lower() == "readme.md": - continue - rel = path.relative_to(directory) - items.add(rel.parts[0]) - return sorted(items) - - -def render_asset_list(directory_name: str, items: list[str], empty_message: str) -> str: - if not items: - return f"- {empty_message}" - return "\n".join(f"- `{directory_name}/{item}`" for item in items) - - -for contract in sorted((root / "compositions").glob("*/compositions.yaml")): - text = contract.read_text() - name = extract(r"^ name:\s*(.+)$", text) - description = extract(r"^ description:\s*(.+)$", text) - comp_dir = contract.parent - example_items = top_level_assets(comp_dir / "examples") - test_items = top_level_assets(comp_dir / "tests") - example_list = render_asset_list("examples", example_items, "Add a sample fixture under examples/.") - test_list = render_asset_list("tests", test_items, "Add a smoke or contract fixture under tests/.") - - readme = f"""# {name} - -`{name}` is an exported Orun composition in the Stack Tectonic catalog. - -## Purpose - -{description} - -## Contract - -- **Type:** `{name}` -- **Path:** `{comp_dir.relative_to(root)}` -- **Definition:** `compositions.yaml` - -## Example fixtures - -These sample assets are excerpted or adapted from `example-platform-repo` so the contract is documented with realistic consumer-repo shapes. - -{example_list} - -## Test fixtures - -{test_list} - -## Verification - -`./scripts/verify-composition.sh {name}` checks that this composition keeps its contract, fixture, and generated-doc scaffolding intact. -""" - - examples_readme = f"""# Examples for {name} - -These fixtures are excerpted or adapted from `example-platform-repo` to show how `{name}` looks inside a consumer repository. - -{example_list} -""" - - tests_readme = f"""# Tests for {name} - -These files provide contract or smoke fixtures that CI can inspect for `{name}` without requiring a full consumer repository checkout. - -{test_list} -""" - - write_or_check(comp_dir / "README.md", readme) - write_or_check(comp_dir / "examples" / "README.md", examples_readme) - write_or_check(comp_dir / "tests" / "README.md", tests_readme) - -if check_mode and dirty: - print("Generated composition docs are stale:") - for item in dirty: - print(f" - {item}") - raise SystemExit(1) -PY diff --git a/scripts/score.sh b/scripts/score.sh deleted file mode 100755 index 3a7185a..0000000 --- a/scripts/score.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -check_mode="${1:-}" - -python3 - "$repo_root" "$check_mode" <<'PY' -from pathlib import Path -import json -import re -import sys - -root = Path(sys.argv[1]) -check_mode = sys.argv[2] == "--check" - -stack_text = (root / "stack.yaml").read_text() -stack_name = re.search(r"(?m)^ name:\s*(.+)$", stack_text).group(1).strip() -stack_title = re.search(r"(?m)^ title:\s*(.+)$", stack_text).group(1).strip() -stack_version = re.search(r"(?m)^ version:\s*(.+)$", stack_text).group(1).strip() -semver = bool(re.fullmatch(r"\d+\.\d+\.\d+", stack_version)) - -verify_exists = (root / ".github/workflows/verify.yml").exists() -release_exists = (root / ".github/workflows/release.yml").exists() -scorecard_exists = (root / ".github/workflows/scorecard.yml").exists() - - -def extract(pattern: str, text: str) -> str: - match = re.search(pattern, text, re.MULTILINE) - if not match: - raise SystemExit(f"missing pattern: {pattern!r}") - return match.group(1).strip() - - -def category_for(name: str) -> str: - if "terraform" in name and "cloudflare-pages" in name: - return "platform" - if "cloudflare-pages" in name: - return "hosting" - if "cloudflare-worker" in name: - return "edge" - if name.startswith("terraform"): - return "infrastructure" - if name.startswith("helm"): - return "kubernetes" - return "developer-experience" - - -def tags_for(name: str) -> list[str]: - tags = set(name.split("-")) - tags.add(category_for(name)) - if "cloudflare" in name: - tags.add("cloudflare") - if "turbo" in name: - tags.add("turbo") - return sorted(tags) - - -def grade_for(score: int) -> str: - if score >= 90: - return "A+" - if score >= 80: - return "A" - if score >= 65: - return "B" - if score >= 50: - return "C" - return "D" - - -def docs_good(readme: Path) -> bool: - return readme.exists() and len(readme.read_text().strip()) >= 240 - - -def count_assets(directory: Path) -> int: - if not directory.exists(): - return 0 - return sum(1 for path in directory.rglob("*") if path.is_file() and path.name.lower() != "readme.md") - - -compositions = [] -for contract in sorted((root / "compositions").glob("*/compositions.yaml")): - text = contract.read_text() - name = extract(r"^ name:\s*(.+)$", text) - description = extract(r"^ description:\s*(.+)$", text) - comp_dir = contract.parent - readme = comp_dir / "README.md" - example_assets = count_assets(comp_dir / "examples") - test_assets = count_assets(comp_dir / "tests") - - score = 0 - if readme.exists(): - score += 10 - if example_assets: - score += 15 - if test_assets: - score += 25 - if verify_exists and release_exists: - score += 20 - if semver: - score += 10 - if docs_good(readme): - score += 10 - if scorecard_exists: - score += 10 - - grade = grade_for(score) - compositions.append( - { - "name": name, - "kind": "composition", - "path": str(comp_dir.relative_to(root)), - "description": description, - "category": category_for(name), - "verified": score >= 80, - "score": score, - "grade": grade, - "tags": tags_for(name), - "signals": { - "readme": readme.exists(), - "exampleAssets": example_assets, - "testAssets": test_assets, - "verifyWorkflow": verify_exists, - "releaseWorkflow": release_exists, - "scorecardWorkflow": scorecard_exists, - "semver": semver, - "docsGood": docs_good(readme), - }, - } - ) - - -blueprints = [] -for blueprint in sorted((root / "blueprints").glob("*/blueprint.yaml")): - text = blueprint.read_text() - name = extract(r"^ name:\s*(.+)$", text) - summary = extract(r"^ summary:\s*(.+)$", text) - uses = re.findall(r"(?m)^ -\s*(.+)$", text) - bp_dir = blueprint.parent - readme = bp_dir / "README.md" - example_assets = count_assets(bp_dir / "examples") - - score = 0 - if readme.exists(): - score += 10 - if len(uses) >= 2: - score += 20 - if example_assets: - score += 15 - if verify_exists and release_exists: - score += 20 - if semver: - score += 10 - if docs_good(readme): - score += 10 - if scorecard_exists: - score += 10 - - blueprints.append( - { - "name": name, - "kind": "blueprint", - "path": str(bp_dir.relative_to(root)), - "description": summary, - "uses": uses, - "verified": score >= 80, - "score": score, - "grade": grade_for(score), - } - ) - - -index = { - "stack": { - "name": stack_name, - "title": stack_title, - "version": stack_version, - "oci": f"oci://ghcr.io/sourceplane/{stack_name}:{stack_version}", - }, - "catalog": { - "compositions": compositions, - "blueprints": blueprints, - }, -} - -rendered = json.dumps(index, indent=2, sort_keys=False) + "\n" -index_path = root / "registry/index.json" -current = index_path.read_text() if index_path.exists() else None - -if check_mode: - if current != rendered: - print("registry/index.json is stale") - raise SystemExit(1) -else: - index_path.parent.mkdir(parents=True, exist_ok=True) - index_path.write_text(rendered) -PY diff --git a/scripts/verify-composition.sh b/scripts/verify-composition.sh deleted file mode 100755 index 567d5e7..0000000 --- a/scripts/verify-composition.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -composition_name="${1:?usage: verify-composition.sh }" -composition_dir="$repo_root/compositions/$composition_name" - -python3 - "$composition_dir" "$composition_name" <<'PY' -from pathlib import Path -import re -import sys - -comp_dir = Path(sys.argv[1]) -name = sys.argv[2] - -if not comp_dir.exists(): - raise SystemExit(f"missing composition directory: {comp_dir}") - -contract_path = comp_dir / "compositions.yaml" -if not contract_path.exists(): - raise SystemExit(f"missing contract: {contract_path}") - -contract_text = contract_path.read_text() - -def require(condition: bool, message: str) -> None: - if not condition: - raise SystemExit(message) - -require( - re.search(rf"(?m)^ name:\s*{re.escape(name)}\s*$", contract_text) is not None, - f"contract metadata.name does not match directory for {name}", -) -require( - re.search(rf"(?m)^ type:\s*{re.escape(name)}\s*$", contract_text) is not None, - f"contract spec.type does not match directory for {name}", -) - -for relative_path in ("README.md", "examples/README.md", "tests/README.md"): - require((comp_dir / relative_path).exists(), f"missing required file: {comp_dir / relative_path}") - -def non_readme_files(directory: Path) -> list[Path]: - return sorted( - path - for path in directory.rglob("*") - if path.is_file() and path.name.lower() != "readme.md" - ) - -example_assets = non_readme_files(comp_dir / "examples") -test_assets = non_readme_files(comp_dir / "tests") - -require(example_assets, f"{name} is missing example assets beyond README.md") -require(test_assets, f"{name} is missing test assets beyond README.md") - -def has_matching_component(directory: Path) -> bool: - for path in directory.rglob("component.yaml"): - text = path.read_text() - if re.search(rf"(?m)^ type:\s*{re.escape(name)}\s*$", text): - return True - return False - -require(has_matching_component(comp_dir / "examples"), f"{name} examples do not include a matching component.yaml") -require(has_matching_component(comp_dir / "tests"), f"{name} tests do not include a matching component.yaml") - -print( - f"{name}: {len(example_assets)} example assets, {len(test_assets)} test assets, " - f"fixtures verified" -) -PY diff --git a/scripts/verify.sh b/scripts/verify.sh index 9f2558f..716c6d2 100755 --- a/scripts/verify.sh +++ b/scripts/verify.sh @@ -1,21 +1,85 @@ #!/usr/bin/env bash +# Catalog gate. Proves the tree in compositions/ is publishable *and* consumable: +# `orun publish --dry-run` only resolves the manifest and target, so on its own it +# is no evidence the package is valid. Packing the archive and resolving it back +# through a throwaway intent exercises the same code path a consumer repo runs. set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$repo_root" -./scripts/generate-readme.sh --check -./scripts/score.sh --check - -for contract in "$repo_root"/compositions/*/compositions.yaml; do - composition_name="$(basename "$(dirname "$contract")")" - ./scripts/verify-composition.sh "$composition_name" -done - stack_version="$(awk '/^ version: /{print $2}' stack.yaml)" test -n "$stack_version" +# Every composition directory must carry the decomposed contract: a +# composition.yaml whose metadata.name and spec.type both match the directory. +expected=0 +for contract in "$repo_root"/compositions/*/composition.yaml; do + name="$(basename "$(dirname "$contract")")" + meta_name="$(awk '/^metadata:/{f=1;next} f&&/^ name:/{print $2;exit}' "$contract")" + spec_type="$(awk '/^spec:/{f=1;next} f&&/^ type:/{print $2;exit}' "$contract")" + if [ "$meta_name" != "$name" ]; then + echo "verify: $name: metadata.name is '$meta_name', expected '$name'" >&2 + exit 1 + fi + if [ "$spec_type" != "$name" ]; then + echo "verify: $name: spec.type is '$spec_type', expected '$name'" >&2 + exit 1 + fi + test -f "$(dirname "$contract")/schema.yaml" \ + || { echo "verify: $name: missing schema.yaml" >&2; exit 1; } + test -d "$(dirname "$contract")/jobs" \ + || { echo "verify: $name: missing jobs/" >&2; exit 1; } + expected=$((expected + 1)) +done +test "$expected" -gt 0 || { echo "verify: no compositions found" >&2; exit 1; } +echo "verify: $expected composition contract(s) structurally valid" + +# Resolve the publish target and version without uploading. orun publish "ghcr.io/sourceplane/stack-tectonic:${stack_version}" \ --dry-run \ --root . \ --version "$stack_version" + +# Pack, then resolve the packed artifact back through a consumer intent. This is +# the step that would catch a composition orun cannot load or export. +work_dir="$(mktemp -d)" +trap 'rm -rf "$work_dir"' EXIT + +# `orun pack` archives the whole root, but `orun publish` ships only the +# stack.yaml + compositions/ and examples/ layers. Stage that subset so the +# artifact we verify is the artifact consumers actually resolve. +stage_dir="$work_dir/stage" +mkdir -p "$stage_dir" +cp stack.yaml "$stage_dir/" +cp -R compositions "$stage_dir/" +[ -d examples ] && cp -R examples "$stage_dir/" + +orun pack --root "$stage_dir" --output "$work_dir/stack.tgz" >/dev/null + +cat > "$work_dir/intent.yaml" <&2; exit 1; } +done + +echo "verify: all $expected composition(s) export from the packed artifact" diff --git a/stack.yaml b/stack.yaml index c4d5159..5be06cc 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,16 +3,16 @@ kind: Stack metadata: name: stack-tectonic title: Stack Tectonic - version: 0.12.0 - description: Versioned OCI-hosted catalog of platform compositions and blueprints for Sourceplane repositories. + version: 0.13.0 + description: Versioned OCI-hosted catalog of Cloudflare, Terraform and monorepo compositions for Sourceplane repositories. owner: sourceplane tags: - terraform - - helm + - aws - cloudflare + - supabase - platform - catalog - - blueprints registry: host: ghcr.io namespace: sourceplane