Skip to content
16 changes: 11 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,20 @@ updates:
# Don't propose bumps to our own internal sibling references (floating @v0).
- dependency-name: "quantecon/actions*"

# ── npm (deploy-cloudflare's wrangler) ─────────────────────────────────────
# deploy-cloudflare installs wrangler with `npm ci` from the lockfile in its
# own directory, so the exact version is committed and bumps arrive here.
# The action harness dry-runs the generated config through the bumped
# wrangler (dc-wrangler-config), so a bump that breaks it goes red in CI.
# ── npm (the CLIs the deploy actions install) ─────────────────────────────
# deploy-cloudflare, preview-cloudflare and preview-netlify install wrangler
# or netlify-cli with `npm ci` from the package.json + package-lock.json
# beside each action.yml, pinned to an exact version because the CLI is
# handed the deploy token (#105, #163). The groups bump all three in one PR
# (a second one for majors). Such a PR cannot run a deploy, so the CI signal
# is the harness: dc-wrangler-config dry-runs deploy-cloudflare's generated
# config through the bumped wrangler, and preview-cli-install runs `npm ci`
# from each preview lockfile and checks `--version`.
- package-ecosystem: "npm"
directories:
- "/deploy-cloudflare"
- "/preview-cloudflare"
- "/preview-netlify"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
Expand Down
55 changes: 54 additions & 1 deletion .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ jobs:
# avoid. Only real step invocations count.
DIRS=$(grep -oE '^[[:space:]]*uses: \./[A-Za-z0-9_.-]+' .github/workflows/test-actions.yml | sed 's|.*\./||' | sort -u)
[ -n "$DIRS" ] || { echo "::error::gate self-test: no 'uses: ./<action>' found in the harness — refusing to decide"; exit 1; }
MUST_RUN=".github/workflows/test-actions.yml .github/fixtures/mini-lectures/environment.yml"
# The lockfiles are listed by hand: preview-cli-install tests them
# without a `uses: ./` line, because the actions need deploy secrets.
MUST_RUN=".github/workflows/test-actions.yml .github/fixtures/mini-lectures/environment.yml preview-cloudflare/package-lock.json preview-netlify/package-lock.json"
for d in $DIRS; do MUST_RUN="$MUST_RUN $d/action.yml"; done
for p in $MUST_RUN; do
if grep -Eq "$IGNORED" <<< "$p"; then
Expand Down Expand Up @@ -1440,6 +1442,56 @@ jobs:
fi
echo "✅ wrangler $("$wrangler" --version | tail -1) accepts the generated config for deploy and versions upload"

# ==========================================================================
# preview-* — the pinned CLIs (install only; a deploy needs provider secrets)
# ==========================================================================

preview-cli-install:
# #105: preview-cloudflare and preview-netlify install their CLI with
# `npm ci` from a lockfile beside action.yml, and Dependabot bumps those
# lockfiles. The actions themselves cannot run here — a deploy needs the
# provider's token, and they skip Dependabot's PRs outright — so without
# this job a CLI bump would merge with no CI signal at all.
#
# Scope, stated honestly: this proves each lockfile installs on a clean
# runner and that the CLI it installs starts and reports the pinned
# version. It does not run the actions' install step itself, and it cannot
# tell whether the new CLI still deploys; that is for the next real PR.
name: 'preview-*: pinned CLIs install from their lockfiles and run'
runs-on: ubuntu-latest
timeout-minutes: 10
needs: gate
if: needs.gate.outputs.relevant == 'true'
steps:
- uses: actions/checkout@v7

# The Node the READMEs tell hosted-runner callers to set up, and the major
# the QuantEcon containers ship.
- uses: actions/setup-node@v7
with:
node-version: '24'

- name: npm ci from each lockfile, then run the CLI
run: |
set -euo pipefail
echo "node $(node --version), npm $(npm --version)"
# action dir, npm package, bin name
for spec in preview-cloudflare:wrangler:wrangler preview-netlify:netlify-cli:netlify; do
IFS=: read -r dir pkg bin <<< "$spec"
want=$(node -p "require('./$dir/package.json').dependencies['$pkg']")
echo "::group::$dir: npm ci ($pkg $want)"
D="$(mktemp -d)"
cp "$dir/package.json" "$dir/package-lock.json" "$D/"
npm ci --prefix "$D" --no-audit --no-fund
echo "::endgroup::"
got=$("$D/node_modules/.bin/$bin" --version) \
|| { echo "::error::$dir: $bin installed from the lockfile but does not run"; exit 1; }
echo "$bin --version: $got"
grep -qF "$want" <<< "$got" \
|| { echo "::error::$dir: $bin reports [$got], expected the pinned $want"; exit 1; }
done
echo "✅ both pinned CLIs install from their lockfiles and run"

# ==========================================================================
# Single anchor for branch protection
# ==========================================================================
Expand Down Expand Up @@ -1472,6 +1524,7 @@ jobs:
- dc-refuses-ungated
- dc-inputs
- dc-wrangler-config
- preview-cli-install
steps:
# This is the job intended to be the single required status check, so it
# has to be correct in BOTH shapes the gate can produce, and must never be
Expand Down
55 changes: 52 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
templates-only PR matches the ignore list and a gated job would skip exactly the PRs
that can introduce drift. Consequence: a Dependabot major bump of such an action (today
only `actions/checkout`) now goes red until the templates move in the same PR. (#109)
- **CI**: `preview-cli-install` harness job — `npm ci` from each preview action's lockfile on
Node 24, after which the CLI must start and report the pinned version. The preview actions
themselves cannot run in the harness (a deploy needs the provider's token, and they skip
Dependabot's PRs outright), so without this job the Dependabot CLI bumps added below would
merge with no CI signal at all. It does not exercise a deploy: a new CLI still needs a real PR
against each provider. The gate's self-test now also treats the two lockfiles as must-run
paths. (#105)

### Changed
- **`preview-cloudflare`, `preview-netlify`**: the CLI is no longer installed globally. Each
job runs `npm ci` into a fresh directory under `RUNNER_TEMP` — not `$GITHUB_ACTION_PATH`, which in a
container job is the `_actions` directory mounted from the host — and the deploy step calls
the binary by the absolute path the install step now outputs as `bin`. The
CLI's own executables (`wrangler`, `wrangler2`, `cf-wrangler`; `netlify`, `ntl`) are linked
into a `bin` directory added to `GITHUB_PATH`, so they stay on `PATH` for later steps in the
caller's job, as the global install left them, without the dependency bins in
`node_modules/.bin` shadowing the caller's tools. (#105)
- **Container images**: Node.js moves from 20 (end-of-life 2026-04-30) to 24 LTS. The
lean image carried 20.17.0 and the full image 20.20.2. It no longer comes from conda,
which cannot supply 24 here: every `jupyterlab` below 4.6 on the defaults channel,
including the 4.5.7 that `anaconda=2026.06` pins, constrains `nodejs` to 20.x. Both
images now install Node from nodejs.org, pinned by version and SHA256 like Miniconda,
after the conda layer. Dropping the conda `nodejs` leaves the full image's solve
unchanged; the lean image holds `icu=73.1`, the version the old `nodejs` pinned, so its
native stack does not re-solve. `netlify-cli@latest` (27.x, which needs node >=22.13) and
`wrangler@latest` (which refuses to run below node 22), both installed into the image
by `preview-netlify` and `preview-cloudflare`, are now inside their supported range.
native stack does not re-solve. `netlify-cli` (27.x, which needs node >=22.13) and
`wrangler` (which refuses to run below node 22), which `preview-netlify` and
`preview-cloudflare` install per job, are now inside their supported range.
- **Templates**: `actions/checkout` moves from `@v4` to `@v7` in `ci.yml`, `cache.yml` and
`publish.yml`, matching this repo's own workflows and the consumer repositories in
`PLAN.md`'s table. `@v4` runs on node20, so every repository scaffolded from the templates brought
Expand Down Expand Up @@ -181,6 +196,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
added/modified filter dropped, so neither preview action linked it. `--no-renames`
decomposes a rename into `D` + `A`, and the `A` half is kept like any added lecture.
(#107)
- **`preview-cloudflare`**: a failed deploy printed no diagnostic at all. Under
`bash -eo pipefail`, `DEPLOY_OUTPUT=$(wrangler pages deploy … 2>&1)` aborted the step on
wrangler's non-zero exit with wrangler's stderr captured into the variable, so the log ended
at `🔍 Deploying preview…` and the output dump and error branch after it were unreachable
(`DEPLOY_EXIT_CODE=$?` could only ever read 0). wrangler's output now streams into the
`Deployment Output` group through `tee`, the exit code is read from `PIPESTATUS` with `set -e`
suspended around the call, and a failure ends with an `::error::` annotation and wrangler's
own exit code. Neither preview action had any `::error::` annotation before. (#105)
- **`preview-netlify`**: the same abort-before-dump shape threw away the captured `--json`
error payload of a failed deploy; netlify's readable error on stderr did reach the log.
stdout now goes through `tee` to a file, with the same `PIPESTATUS` capture and `::error::`.
It is stdout only: merging stderr would corrupt the JSON whenever a successful deploy prints
an npm or Node notice. Separately, the "Raw output was:" guard could not fire in the case it
was written for. `python3 -c "…json.load…"` exits non-zero on non-JSON stdout, and `set -e`
aborted the step at the assignment with a bare traceback, so the guard only ever fired on
valid JSON lacking `deploy_url`/`url`. The parse is now `|| true`, and the guard prints the
raw output and fails with an `::error::`. (#105)
- **CI**: the image-size job in `test-container.yml` has never reported a size, so the
v0.11.0 entry saying image size "is now reported from the manifest" (#108) did not hold.
`docker/build-push-action` attaches a provenance attestation by default, which makes each
Expand Down Expand Up @@ -215,6 +247,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`github.event_name == 'pull_request'`, so under `pull_request_target` the fork check never
fires and the deploy step is skipped. Both READMEs now say fork previews are unsupported and
warn against `pull_request_target`. (#105)
- **`preview-cloudflare`, `preview-netlify`**: `wrangler@latest` and `netlify-cli@latest` were
installed on every run and then handed the deploy credentials — two unpinned npm packages
with large dependency trees, in a repo that SHA-pins every third-party Action against tag
hijacking. Each CLI is now pinned to an exact version (wrangler 4.136.3, netlify-cli 27.8.1)
by a `package.json` and `package-lock.json` beside its `action.yml`, and `npm ci` installs
exactly that lockfile, integrity hashes included. The Dependabot `npm` entry that
`deploy-cloudflare` introduced now covers both preview directories as well, grouped like the
other ecosystems: minor/patch bumps of the three CLI pins in one PR, majors in another. (#105)
- **`preview-netlify`**: the auth token is off the command line and out of the generated step
script. `--auth="${{ inputs.netlify-auth-token }}"` wrote the token into the script file the
runner puts on disk and into the argv of the netlify process. The step now passes it as
`NETLIFY_AUTH_TOKEN` and the site as `NETLIFY_SITE_ID`, both read natively by netlify-cli
(checked against 27.8.1's source), and drops `--auth` and `--site`. The PR number, head SHA
and `build-dir`, also interpolated into the script before, move into `env:` in the same
edit, as v0.11.1 did for `preview-cloudflare`. The deploy also passes `--no-build`: the site
is prebuilt, and netlify-cli 27 would otherwise run any configured build command first, in a
process that inherits the token. Closes `PLAN.md` backlog item 8. (#105)

## [0.11.1] - 2026-08-07

Expand Down
3 changes: 2 additions & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ The container fixture at `containers/quantecon/tests/minimal-jupyter-book/` also
| `build-lectures` | Real HTML build of the fixture on the cache-restored conda env, executed-cell output asserted; plus the negative direction — a page whose code cell raises must fail the step, so a regression that swallows the build status cannot pass silently |
| `build-jupyter-cache` | Smoke build + outputs, then a full round-trip into `restore-jupyter-cache` for both cache types. ⚠️ Its internal `setup-environment`/`build-lectures` calls run `@v0`, not the PR — GitHub forbids expressions in `uses:`, so that chain is untestable pre-release by construction (see #100) |
| `deploy-cloudflare` | Everything short of a real deploy: the Access gate probe against a local stand-in for every response shape (exact team domain passes; wrong org, public `2xx`, same-host redirect, missing `Location`, a `Location` hiding its host behind userinfo, `404`, `5xx`, unreachable, an empty team domain, and a public asset behind a gated root all fail); the action refusing an ungated Worker **before wrangler is even installed**, asserted on the filesystem, with a positive control proving the same inputs reach wrangler once the gate is off; every invalid input failing in validation, with the gate off so a dropped rule cannot hide behind it; and the pinned wrangler accepting the generated config (`--dry-run` deploy and alias upload, with no `Unexpected fields` warning), which is what a Dependabot bump of the lockfile runs against. ❌ A real deploy needs a gated Worker and a token, so the first consumer deploy is its only proof |
| `publish-gh-pages`, `preview-netlify`, `preview-cloudflare` | ❌ Not covered — need real deploy targets and secrets; owned by the post-release canary repo (stage 2+ of #100) |
| `preview-netlify`, `preview-cloudflare` | CLI install only: `npm ci` from each action's lockfile on Node 24, then the CLI must start and report the pinned version, so a Dependabot CLI bump gets some signal (#105). The actions themselves, deploys included, are ❌ not covered — they need real deploy targets and secrets; owned by the post-release canary repo (stage 2+ of #100) |
| `publish-gh-pages` | ❌ Not covered — needs real deploy targets and secrets; owned by the post-release canary repo (stage 2+ of #100) |

---

Expand Down
3 changes: 2 additions & 1 deletion preview-cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ That's it! Changed lecture detection works automatically for files in the `lectu
## Requirements

- **Node.js/npm:** Required for `wrangler` CLI installation
- Current `wrangler` releases need Node.js 22 or later
- The pinned `wrangler` needs Node.js 22 or later
- The QuantEcon containers (`ghcr.io/quantecon/quantecon`, `ghcr.io/quantecon/quantecon-build`) include Node.js 24 LTS
- For other runners, use `actions/setup-node@v7` with `node-version: '24'` before this action
- **`wrangler` version:** pinned exactly in [`package.json`](package.json) and installed per job with `npm ci` from [`package-lock.json`](package-lock.json), so the runner needs access to `registry.npmjs.org`. Dependabot bumps the pin
- **Git history:** Use `fetch-depth: 0` in checkout for change detection
- **Cloudflare secrets:** `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`
- **Cloudflare Pages project:** Must be created beforehand
Expand Down
Loading
Loading