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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 60 additions & 7 deletions .github/workflows/app-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,37 @@ on:
required: false
type: number
default: 40
pr-gate:
description: >-
The PR gate (pr-gate/, PR-GATE.md): a draft runs nothing, only the top PR of a
stack runs (its tree holds the PRs below), and only when the stack impacts
`project` (Rush's --impacted-by, from where the stack left its root branch) or
changes one of `gate-paths`. A skipped `checks` job reports "skipped". Off:
every run runs, as before. Turn it on together with, in the caller:
`types: [opened, synchronize, reopened, ready_for_review]`, no `paths:` filter
(pass them as `gate-paths`), and `pull-requests: read`.
required: false
type: boolean
default: false
gate-paths:
description: >-
With `pr-gate`: globs, one per line (`*` crosses `/`), that run the checks
INSTEAD of the project's Rush impact — for a check that reads a few files
only (an i18n coverage check). Empty: `project`'s impact decides.
required: false
type: string
default: ""
secrets:
BE_NPM_TOKEN:
description: >-
npm.beplus.cloud token for the @beplus scope. `secrets: inherit` (or, for
an environment secret, `github-environment`) is all a caller passes.
required: false

permissions:
contents: read

# No workflow-wide `permissions`: `plan` takes the caller's token as it is, so the PR gate
# reads the repository's pull requests where the caller grants `pull-requests: read` (and
# fails open, with a warning, where it does not). A called workflow cannot ask for more than
# its caller grants — asking would fail every caller that does not — so it never names it.
jobs:
# What a caller would otherwise write out, read from the files that already
# hold it. Every value comes from the pull request's own tree, so each is
Expand All @@ -146,6 +167,7 @@ jobs:
outputs:
directory: ${{ steps.project.outputs.directory }}
database: ${{ steps.project.outputs.database }}
run: ${{ steps.gate.outputs.run || 'true' }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -231,10 +253,26 @@ jobs:
echo "database=$database"
} >> "$GITHUB_OUTPUT"

# Last in `plan`: with a project to weigh it checks out the PR's head with its whole
# history (blobless), which the steps above must not read.
- name: PR gate
id: gate
if: inputs.pr-gate
uses: beplus/setup-beplus/pr-gate@v2
with:
stack: top-only
projects: ${{ inputs.gate-paths == '' && inputs.project || '' }}
paths: ${{ inputs.gate-paths }}
node-version: ${{ inputs.node-version }}

checks:
name: checks
needs: plan
# The PR gate's answer; without it, always. Skipped reports "skipped", never pending.
if: needs.plan.outputs.run == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
# Where BE_NPM_TOKEN is an environment secret the job has to claim the
# environment to see it, and the environment's branch policy must then admit
# every branch the caller runs on. Empty: no environment.
Expand Down Expand Up @@ -268,8 +306,14 @@ jobs:

# Keyed by the project too: `install --to` installs a subset, and
# db-migrations-pr.yml saves its own, smaller one under the plain key.
- name: Cache Rush and pnpm
uses: actions/cache@v4
#
# RESTORED here, SAVED only off a pull request. A cache a PR saves is scoped to that
# PR's ref: no other PR can read it, so saving it (~40 s) bought nothing but the next
# push of the same PR. rush-cache.yml saves the one every PR reads, from the default
# branch (its key is this one).
- name: Restore the Rush and pnpm cache
id: cache
uses: actions/cache/restore@v4
with:
path: |
common/temp
Expand All @@ -293,15 +337,24 @@ jobs:
# ⚠️ AND PROVE IT WORKED. npm.beplus.cloud answers a read it cannot
# authenticate with HTTP 200 and a stub body, never 401, so a token
# that did not reach this job fails nothing until pnpm, minutes later.
# This asks the registry for every @beplus package the project depends
# on, and fails here, naming the cause.
# This asks the registry for ONE @beplus package the project depends on
# (one request, about a second) and fails here, naming the cause. A
# package that is not published is the install's to report.
BE_NPM_CHECK: ${{ needs.plan.outputs.directory }}

- name: Rush install
env:
PROJECT: ${{ inputs.project }}
run: node common/scripts/install-run-rush.js install --to "$PROJECT"

- name: Save the Rush and pnpm cache
if: github.event_name != 'pull_request' && steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
common/temp
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Rush build
if: inputs.build != 'none'
env:
Expand Down
64 changes: 57 additions & 7 deletions .github/workflows/db-migrations-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,38 @@ on:
required: false
type: string
default: ""
pr-gate:
description: >-
The PR gate (pr-gate/, PR-GATE.md): a draft checks nothing, and only the top PR
of a stack checks (its tree holds every PR below it), and only when the stack
impacts the database project (Rush's --impacted-by, from where the stack left its
root branch) or changes one of `gate-paths`. Off: every run the caller's
triggers start runs, as before. Turn it on together with, in the caller:
`types: [opened, synchronize, reopened, ready_for_review]` on `pull_request`,
NO `paths:` filter there (it sees only the top PR's own commits; a `push`
filter may stay), and `pull-requests: read`.
required: false
type: boolean
default: false
gate-paths:
description: >-
With `pr-gate`: globs, one per line (`*` crosses `/`), that run the checks
INSTEAD of the database project's Rush impact — the paths a caller's
`paths:` filter named (beplus.estate.json and the workflows always run them).
Empty: the database project's impact decides.
required: false
type: string
default: ""
secrets:
BE_NPM_TOKEN:
description: >-
npm.beplus.cloud token for the @beplus scope. `secrets: inherit` (or, for
an environment secret, `github-environment`) is all a caller passes.
required: false

permissions:
contents: read

# No workflow-wide `permissions`: `plan` takes the caller's token as it is, so the PR gate
# reads pull requests where the caller grants `pull-requests: read` (a called workflow
# asking for more than its caller grants would fail every caller that does not).
jobs:
# What the copies wrote out by hand, read from the manifest that already
# holds it. Both values come from the pull request's own tree, so both are
Expand All @@ -104,6 +126,7 @@ jobs:
package: ${{ steps.database.outputs.package }}
project: ${{ steps.database.outputs.project }}
database: ${{ steps.database.outputs.database }}
run: ${{ steps.gate.outputs.run || 'true' }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -155,10 +178,25 @@ jobs:
echo "database=$database"
} >> "$GITHUB_OUTPUT"

# Last in `plan`: it checks out the PR's head with its history.
- name: PR gate
id: gate
if: inputs.pr-gate
uses: beplus/setup-beplus/pr-gate@v2
with:
stack: top-only
projects: ${{ inputs.gate-paths == '' && steps.database.outputs.project || '' }}
paths: |
beplus.estate.json
${{ inputs.gate-paths }}

checks:
name: migration integrity + rebuild
needs: plan
if: needs.plan.outputs.run == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
# Where BE_NPM_TOKEN is an environment secret (MRKIT: `dev`) the job has to
# claim the environment to see it, and the environment's branch policy must
# then admit every branch this gate runs on — it has no `branches` filter
Expand Down Expand Up @@ -200,8 +238,12 @@ jobs:
with:
node-version: 22.14

- name: Cache Rush and pnpm
uses: actions/cache@v4
# Restored on every run, saved only off a pull request (the push to dev this
# workflow also runs on): a PR's cache is scoped to its own ref, and no other PR
# can read it.
- name: Restore the Rush and pnpm cache
id: cache
uses: actions/cache/restore@v4
with:
path: |
common/temp
Expand All @@ -225,13 +267,21 @@ jobs:
# authenticate with HTTP 200 and a stub body, never 401, so a token
# that did not reach this job fails nothing until pnpm, minutes later,
# reports ERR_PNPM_TARBALL_INTEGRITY, then ERR_PNPM_NO_VERSIONS. This
# asks the registry for every @beplus package the database package
# depends on, and fails here, naming the cause.
# asks the registry for ONE @beplus package the database package
# depends on (one request), and fails here, naming the cause.
BE_NPM_CHECK: ${{ needs.plan.outputs.package }}

- name: Rush install
run: node common/scripts/install-run-rush.js install --to ${{ needs.plan.outputs.project }}

- name: Save the Rush and pnpm cache
if: github.event_name != 'pull_request' && steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
common/temp
key: ${{ steps.cache.outputs.cache-primary-key }}

# ⚠️ INSTALL IS NOT ENOUGH. drizzle-kit reads dist/, including workspace
# dependencies' — Mountaineer's @beplus/postmark contributes tables.
# Without a build its dist/db is absent, drizzle-kit prints
Expand Down
47 changes: 43 additions & 4 deletions .github/workflows/docs-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,28 @@ on:
required: false
type: string
default: ""
pr-gate:
description: >-
The PR gate (pr-gate/, PR-GATE.md) for a pull request's build: a draft builds
nothing, and only the top PR of a stack builds (its tree holds every PR below it).
A push builds and publishes as before. Off: every pull request builds. Turn it on
together with, in the caller: `types: [opened, synchronize, reopened,
ready_for_review]`, no `branches:`/`paths:` filter on `pull_request` (pass the
paths as `gate-paths`), and `pull-requests: read`.
required: false
type: boolean
default: false
gate-paths:
description: >-
With `pr-gate`: globs, one per line (`*` crosses `/`): a pull request builds only
when its stack changes one (the workflows, rush.json and the like always count).
Empty: every ready top PR builds.
required: false
type: string
default: ""

permissions:
contents: read
# No workflow-wide `permissions`: every job names its own, and `gate` takes the caller's
# token as it is (a called workflow asking for more than its caller grants fails them all).

# One deployment at a time, and never cancel one half-done: a partly uploaded site is a broken one.
# A pull request's build deploys nothing, so a newer push to it replaces the one in flight.
Expand All @@ -131,8 +150,24 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
gate:
name: PR gate
if: inputs.pr-gate && github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
run: ${{ steps.gate.outputs.run }}
steps:
- id: gate
uses: beplus/setup-beplus/pr-gate@v2
with:
stack: top-only
paths: ${{ inputs.gate-paths }}

build:
name: Build the docs site
needs: gate
# Without the gate (off, or not a pull request), always; with it, its answer.
if: ${{ !cancelled() && (needs.gate.result == 'skipped' || needs.gate.outputs.run == 'true') }}
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
# `pages: read` is for asking Pages where the site will be served, below.
Expand Down Expand Up @@ -349,7 +384,10 @@ jobs:
deploy:
name: Publish to GitHub Pages
needs: build
if: needs.build.outputs.publish == 'true'
# ⚠️ Status spelled out: `gate`, above `build`, is skipped on every push, and an implicit
# success() counts a skipped job anywhere up the chain as not succeeded — so without
# `!cancelled()` here nothing would ever publish.
if: ${{ !cancelled() && needs.build.result == 'success' && needs.build.outputs.publish == 'true' }}
runs-on: ubuntu-latest
# Pages needs to write the deployment and to mint the token that proves it came from this run.
permissions:
Expand All @@ -366,7 +404,8 @@ jobs:
package:
name: Publish the docs package
needs: build
if: needs.build.outputs.publish == 'true' && inputs.package
# Status spelled out, as for `deploy`.
if: ${{ !cancelled() && needs.build.result == 'success' && needs.build.outputs.publish == 'true' && inputs.package }}
runs-on: ubuntu-latest
environment: ${{ inputs.package-environment }}
# The site is already up: a package that cannot be published fails here, never the deploy.
Expand Down
33 changes: 32 additions & 1 deletion .github/workflows/infra-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ name: infra diff

on:
workflow_call:
inputs:
pr-gate:
description: >-
The PR gate (pr-gate/, PR-GATE.md): a draft diffs nothing, and only the top PR of
a stack diffs (cdk diff compares its tree, which holds every PR below it, with
what is deployed), and only when the stack changes one of `gate-paths`. Off, or
on without `gate-paths`: every ready PR the caller's triggers start diffs.
Turn it on together with, in the caller: `types: [opened, synchronize,
reopened, ready_for_review]`, and its `paths:` filter moved into `gate-paths`
(a filter on the caller sees only the top PR's own commits).
required: false
type: boolean
default: false
gate-paths:
description: "With `pr-gate`: globs, one per line (`*` crosses `/`): what the diff reads."
required: false
type: string
default: ""
secrets:
BE_NPM_TOKEN:
description: >-
Expand All @@ -87,6 +105,7 @@ jobs:
packages: ${{ steps.plan.outputs.packages }}
region: ${{ steps.estate.outputs.region }}
marker: ${{ steps.estate.outputs.marker }}
run: ${{ steps.gate.outputs.run || 'true' }}
steps:
- uses: actions/checkout@v4
# `beplus infra` reads beplus.estate.json and nothing
Expand Down Expand Up @@ -140,9 +159,21 @@ jobs:
echo "region=$region" >> "$GITHUB_OUTPUT"
echo "marker=$marker" >> "$GITHUB_OUTPUT"

# Last in `plan`: with `gate-paths` it checks out the PR's head with its history.
# Without `gate-paths` a stack's lower PR still diffs: the caller's own `paths:`
# filter may have started only it.
- name: PR gate
id: gate
if: inputs.pr-gate
uses: beplus/setup-beplus/pr-gate@v2
with:
stack: ${{ inputs.gate-paths != '' && 'top-only' || 'every' }}
paths: ${{ inputs.gate-paths }}

diff:
name: ${{ matrix.package }} · ${{ matrix.env }}
needs: plan
if: needs.plan.outputs.run == 'true'
runs-on: ubuntu-latest
# Claiming the environment is how the job reaches BE_NPM_TOKEN, which is an
# environment secret. On GitHub Free it adds no gate; with Environment
Expand Down Expand Up @@ -176,7 +207,7 @@ jobs:
comment:
name: comment
needs: [plan, diff]
if: always() && github.event_name == 'pull_request'
if: always() && github.event_name == 'pull_request' && needs.plan.outputs.run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
Loading
Loading