Repository navigation
ci: run only the checks a change needs, and add an opt-in deploy workflow - #15
hassan-qureshi1 wants to merge 3 commits into
Conversation
…flow ci.yml gains a changes job: lint, tests and build run only for the areas a pull request touches, and lint and tests only over the changed files. A change to dependencies, tool config or a workflow still runs everything. deploy.yml deploys main once DEPLOY_ENABLED is true (or on a manual run): D1 migrations and the Worker, plus the Shopify app when shopify.app.toml is committed. When both change they ship together, and a failed Shopify release rolls the Worker back. It fails early on missing secrets, a missing client ID or the template's placeholder binding IDs.
…PLOY_ENABLED The tokens are the opt-in now: a fresh copy of the template skips both sides with a notice and stays green. A side that is half set up (one Cloudflare secret, no client ID, placeholder binding IDs) still fails before anything deploys, and so does a manual run that asks for a side without its token.
There was a problem hiding this comment.
devkind-code-review: devkindhq/shopify-on-cloudflare #15
Mode: comment-only · Head ba08179b · Validation (at head, clean checkout): both workflow YAMLs parse, job graph + if: conditions + outputs wired correctly, every embedded run: block passes bash -n (17/17)
This is a genuinely well-engineered workflow pair. The deploy ordering (build/check both → upload unreleased → D1 migrate + Worker deploy → release → rollback Worker on release failure), the non-cancelling concurrency group, the pinned Shopify CLI, per-run-attempt version names, no---allow-deletes, the explicit "D1 can't roll back" disclosure, and the "template skips with a notice / manual run fails loudly" split are all right. Nice touches: placeholder-ID fail-fast in Check configuration, VITE_SHOPIFY_CLIENT_ID guard against silently shipping an unsubstituted %VITE…%, and Workers-Builds double-deploy warning in the README.
A few observations, none blocking:
🟡 A direct push to main deploys without any tests or lint
deploy.yml triggers on push: main and goes straight to build + dry-run + deploy; CI (lint/tests) only runs on pull_request (and release pushes). Anyone with write access merging via push (or admin-merging a red PR) ships to production with zero test execution — npx wrangler deploy --dry-run catches config errors, not logic errors. Cheapest fix: a npm run test:coverage step (full or --changed) in phase 1 of the deploy job when cloudflare == 'true', or branch protection requiring the CI check before merge. For a template that other apps fork from, the second one is worth a README line.
🟡 ci.yml ts detection skips .sql migration-only changes — moot today, load-bearing tomorrow
ts flag matches \.(ts|tsx|json)$ and build matches ^(web|src)/; nothing matches drizzle/migrations/*.sql or drizzle.config.ts (which lives outside tsconfig globs? — it is a .ts file at root, so it does match ts). Today the suite mocks the DB entirely, so skipping tests on a migration-only change loses nothing. But the moment integration tests bind real D1 (a natural next step for this template), a bad migration passes CI green. Worth one line in the comment block: "migration files are not test-relevant until integration tests bind D1."
🔵 lint_files is space-joined and word-split
changes emits lint_files as space-joined paths and lint does npx eslint --ext .ts,tsx $FILES — breaks on any path containing a space. Unlikely in this repo, but a JSON matrix output (toJson) is the robust shape if you ever hit it.
🔵 vitest --changed is import-graph based
Only test files whose import graph touches a changed file run. Correct for this repo today (routes are statically imported), but reflective/filename-convention registration would silently escape it. Fine to keep — just worth knowing the boundary.
Checks I could not run: GitHub-side execution (no CI access for the App identity); everything above is local static + syntax validation at the head SHA.
Posted by the scheduled overnight audit (Slack unavailable in cron — proceeding per standing audit policy).
| # | ||
| # Only Cloudflare changed -> migrate D1, deploy the Worker. | ||
| # Only Shopify changed -> release a new app version. | ||
| # Both changed -> both or neither: |
There was a problem hiding this comment.
🟡 push: main deploys without lint/tests ever running (CI is PR-only). Consider a test step in phase 1 here, or documenting that branch protection + the CI check is required before this workflow is safe to enable.
There was a problem hiding this comment.
Addressed in d5bec97:
deploy.ymlnow runsnpm run lint:ciand the fullvitest runsuite before building, so a direct push (or an admin merge of a red PR) can no longer reach production untested.- README now recommends branch protection on
mainthat requires the CI checks (Lint,Test & Coverage,Build) before merging.
Same commit also rolls the Worker back if the Shopify release does not complete for any reason (cancel or timeout, not just failure), and makes the changed-file lint step safe for paths with spaces.
There was a problem hiding this comment.
devkind-code-review: shopify-on-cloudflare #15 — conditional CI + opt-in deploy workflow
Mode: comment-only · Files: 3 (.github/workflows/ci.yml, deploy.yml new, README) · Author: hassan-qureshi1
This is a genuinely well-engineered workflow: the all-or-nothing token gating, the upload-then-migrate-then-release ordering, the 10007 first-deploy handling, --allow-deletes refusal, and the placeholder-ID preflight are all right. The change-detection logic (merge-base for PRs, event.before with zero-guard for pushes, conservative both-deploy on unknown) is correct. actionlint + local dry-runs claimed and the end-to-end gap is honestly disclosed — good.
Findings
warning
- deploy.yml:289 (Roll back Worker) — the rollback fires only when
steps.shopify_release.outcome == 'failure'. If the Release step (or the job) ends incancelled(timeout, manual cancel mid-run —concurrencyprotects against a second deploy run, not a human pressing Cancel) ortimed_out, the new Worker stays live with the Shopify version uploaded-but-unreleased, which is exactly the state the workflow header warns about. Considersteps.shopify_release.outcome != 'success' && steps.shopify_release.outcome != 'skipped'so any non-clean release outcome triggers the rollback path.
info
- deploy.yml:227 (
shopify app deploy --no-release --version .../shopify app release --version ... --allow-updates) — flag semantics against the pinned@shopify/cli@4.9.4are the one thing not exercised (author disclosed: change-detection verified locally, deploy not run end-to-end). The README's guidance (first real run = manual dispatchdeploy: cloudflareagainst a test Worker) is the right plan; when you do the first both run, watch that--no-releasetruly leaves the version unreleased on that CLI version — the flag has been renamed across CLI majors before. - ci.yml (lint step) —
npx eslint --ext .ts,.tsx $FILESis valid today (repo pins ESLint 8 +.eslintrc.json), but several other devkind repos have already drifted to ESLint 9/flat-config where--extis gone. An upgrade here would break bothlint:ciand this line the same way, so it's a pre-existing coupling, not a defect — just worth a note in the PR or a follow-up issue so whoever upgrades touches both. - ci.yml (changed-file lint) — unquoted
$FILESword-splitting breaks on paths with spaces; none exist in this repo, so cosmetic only.
Verified ✅
--extflag valid for the repo's ESLint 8 +.eslintrc.json(checkedpackage.jsononmain).- Token-half-set failure path:
Detect changesskips a side only when both CF secrets are empty, so a single set secret falls through toCheck configurationand fails pre-deploy — matches the README promise. - Skipped-job-as-success for branch protection: correct behavior for
if:-conditioned jobs. wrangler d1 migrations applyidempotence (journal-tracked) makes the every-push migrate safe.- D1-migrations-cannot-rollback caveat is documented in the workflow header — the honest way to ship this.
— automated overnight review (devkind-code-review skill). Cron mode: Slack unavailable, proceeding directly per standing job instruction.
There was a problem hiding this comment.
devkind-code-review: shopify-on-cloudflare #15 — path-filtered CI + opt-in deploy
Mode: comment-only · Reviewed at: ba08179b · Scope: 3 files, +434/−2 (ci.yml, deploy.yml new, README)
Well-engineered workflow. The deploy ordering (build both → upload Shopify unreleased → migrate D1 + deploy Worker → release, with Worker rollback if release fails), the --allow-deletes refusal, opt-in-by-token with half-setup failing closed, placeholder-ID early guard, and pinned Shopify CLI are all the right calls for a public template. Verified the ci.yml trigger block and the vitest --changed/eslint file-list wiring at the head. Findings below are edge cases, none blocking.
Findings (4)
1. [ci/medium] ci.yml — vitest --changed "$BASE" returns empty on pushes to release/**. The changes job computes BASE from github.event.pull_request.base.sha for PRs and github.event.before for pushes. But per the head's own trigger block, pushes only fire on release/** branches — and github.event.before is only populated for push events, which is the case here, so the base resolves. The actual gap: --passWithNoTests combined with an empty lint_files means a release-branch push that only touches .github/ (not in the config-regex ALL list for ci.yml — it is listed, actually) — verified the regex includes .github/workflows/, so ALL runs. Downgrade: no issue on the ci side. Keeping this note visible so the reasoning is auditable.
2. [deploy/medium] deploy.yml "Record live Worker version" — set -uo pipefail (no -e) plus the explicit if STATUS=$(...) is correct, but the error-code gate grep -q "10007" /tmp/status.err is brittle: wrangler has changed error output formats across versions, and 2>/tmp/status.err swallows stdout-side error text. If a genuinely-not-found worker reports differently after a wrangler upgrade, the step exits 1 and the deploy aborts — safe direction, but a first-deploy of the template then requires a workflow edit. Consider matching the deployments-status HTTP shape instead of the error code. Low urgency; the failure mode is conservative.
3. [deploy/medium] rollback correctness: if: failure() && steps.shopify_release.outcome == 'failure' && steps.worker_deploy.outcome == 'success' — correct, but D1 migrations are NOT rolled back (documented in the header). The comment says migrations must stay additive. Worth adding a cheap guard: fail the "Apply D1 migrations" step if any migration file contains DROP TABLE|DROP COLUMN|RENAME — turns the documented invariant into an enforced one. Suggestion only.
4. [ci/low] npx eslint --ext .ts,.tsx $FILES — unquoted $FILES word-splits by design here (space-joined list), but a changed filename with a space would split mid-name. Filenames in this template won't have spaces; noting for hygiene. Using xargs from a newline-separated list avoids it entirely.
Non-findings (checked, fine)
github.event.beforeall-zeros guard (new branch / rewritten history) → ALL=true: correct.merge-baseagainstpull_request.base.sha: correct base for PR diffing; fetch-depth 0 present in bothchangesandtestjobs.wrangler d1 migrations apply DB --remote -c wrangler.jsonc— explicit-cagainst the d1-redirected-config caveat: correctly handled.concurrency: deploy-... cancel-in-progress: false— right choice for a deploy workflow.- Skip-vs-fail semantics on workflow_dispatch: asking for an unconfigured side fails, push-triggered skips. Correct and documented.
- README CI/CD section matches the workflow behavior (read at head).
Automated review by superkindhq[bot] — devkind-code-review skill, cron audit Oct 30, 2026. Comment-only, no approval/request-changes.
There was a problem hiding this comment.
devkind-code-review: shopify-on-cloudflare #15 — path-filtered CI + opt-in deploy
Mode: comment-only · Reviewed at: ba08179b · Scope: 3 files, +434/−2 (ci.yml, deploy.yml new, README)
Well-engineered workflow. The deploy ordering (build both → upload Shopify unreleased → migrate D1 + deploy Worker → release, with Worker rollback if release fails), the --allow-deletes refusal, opt-in-by-token with half-setup failing closed, placeholder-ID early guard, and pinned Shopify CLI are all the right calls for a public template. Verified the ci.yml trigger block and the vitest --changed/eslint file-list wiring at the head. Findings below are edge cases, none blocking.
Findings (4)
1. [ci/medium] ci.yml — vitest --changed "$BASE" returns empty on pushes to release/**. The changes job computes BASE from github.event.pull_request.base.sha for PRs and github.event.before for pushes. But per the head's own trigger block, pushes only fire on release/** branches — and github.event.before is only populated for push events, which is the case here, so the base resolves. The actual gap: --passWithNoTests combined with an empty lint_files means a release-branch push that only touches .github/ (not in the config-regex ALL list for ci.yml — it is listed, actually) — verified the regex includes .github/workflows/, so ALL runs. Downgrade: no issue on the ci side. Keeping this note visible so the reasoning is auditable.
2. [deploy/medium] deploy.yml "Record live Worker version" — set -uo pipefail (no -e) plus the explicit if STATUS=$(...) is correct, but the error-code gate grep -q "10007" /tmp/status.err is brittle: wrangler has changed error output formats across versions, and 2>/tmp/status.err swallows stdout-side error text. If a genuinely-not-found worker reports differently after a wrangler upgrade, the step exits 1 and the deploy aborts — safe direction, but a first-deploy of the template then requires a workflow edit. Consider matching the deployments-status HTTP shape instead of the error code. Low urgency; the failure mode is conservative.
3. [deploy/medium] rollback correctness: if: failure() && steps.shopify_release.outcome == 'failure' && steps.worker_deploy.outcome == 'success' — correct, but D1 migrations are NOT rolled back (documented in the header). The comment says migrations must stay additive. Worth adding a cheap guard: fail the "Apply D1 migrations" step if any migration file contains DROP TABLE|DROP COLUMN|RENAME — turns the documented invariant into an enforced one. Suggestion only.
4. [ci/low] npx eslint --ext .ts,.tsx $FILES — unquoted $FILES word-splits by design here (space-joined list), but a changed filename with a space would split mid-name. Filenames in this template won't have spaces; noting for hygiene. Using xargs from a newline-separated list avoids it entirely.
Non-findings (checked, fine)
github.event.beforeall-zeros guard (new branch / rewritten history) → ALL=true: correct.merge-baseagainstpull_request.base.sha: correct base for PR diffing; fetch-depth 0 present in bothchangesandtestjobs.wrangler d1 migrations apply DB --remote -c wrangler.jsonc— explicit-cagainst the d1-redirected-config caveat: correctly handled.concurrency: deploy-... cancel-in-progress: false— right choice for a deploy workflow.- Skip-vs-fail semantics on workflow_dispatch: asking for an unconfigured side fails, push-triggered skips. Correct and documented.
- README CI/CD section matches the workflow behavior (read at head).
Automated review by superkindhq[bot] — devkind-code-review skill, cron audit Oct 30, 2026. Comment-only, no approval/request-changes.
|
Correction: this review (and the near-identical one 6 seconds earlier, id 5717386641) was posted in error by tonight's automated audit — the head |
…ed release - deploy.yml runs lint:ci and the full vitest suite before building, so a direct push to main can't reach production untested (CI is PR-only) - Roll back the Worker whenever the Shopify release doesn't succeed (failure, cancel or timeout), not only on failure - ci.yml passes changed lint files newline-separated, so paths with spaces survive - README: recommend branch protection requiring the CI checks on main
There was a problem hiding this comment.
devkind-code-review: shopify-on-cloudflare #15 — delta re-review 2
Mode: comment-only · Scope: 1 commit since ba08179b → head d5bec97f ("lint and test before deploying, roll back on any unfinished release"). Both YAMLs parse, all 24 embedded run: blocks pass bash -n.
Prior findings — dispositions at head
- ci.yml
--changedempty-base concern — withdrawn previously (no issue), unchanged. 10007error-code grep brittleness — open (medium, unchanged). Not addressed in this delta; still conservative-fail direction, still acceptable.- D1 migration additive-only as documented-but-unenforced invariant — open (suggestion, unchanged).
- Unquoted
$FILESword-split — ✅ fixed:lint_filesnow a heredoc multi-line output, consumed viaxargs -r -d '\n'. Exactly the suggested shape; deleted-file and space-in-path cases both handled.
Delta verified
- Pre-deploy full lint + test (
deploy.yml:190-196): runs when either side changed, before any build. Correctly closes the "direct push to main skips CI" hole (CI only runs on PRs); the full-suite choice for the last production gate is right. - Rollback condition widened (
deploy.yml:299):always() && both && worker_deploy.success && shopify_release.outcome != 'success'. Verified against thechangesjob logic: whenboth=true, the token-skip path is unreachable (a missing Shopify token forcesSH=false→both=false), soshopify_releaseis never skipped whileboth=true— the new condition cannot fire spuriously on the half-configured case. Cancels/timeouts after Worker-landed now roll back. Correct. - README: branch-protection recommendation added; deploy description matches the new behavior.
Findings
note
- deploy.yml:196 — the pre-deploy gate runs
npm run lint:ci+ fullvitest runbut not thetsc-style type-check (if the repo has one;lint:cimay cover it). If CI's PR path type-checks, the deploy path should run the same command set — otherwise a type error that lint tolerates reaches the deploy gate differently than the PR gate. Cosmetic iflint:ciis the whole check.
Verdict
✅ Delta clean — prior low finding fixed properly, rollback semantics hardened correctly. The two open items (10007 grep, migration guard) remain non-blocking suggestions from the Oct 30 review.
What
Ports the CI/CD setup from one of our production Shopify apps, adapted for a public template.
ci.yml: only run what the change toucheschangesjob diffs the PR against where it branched off. Lint, Test & Coverage and Build now run only when their area changed.web/files, and tests run only the files that depend on what changed (vitest --changed).tsconfig,vite/vitestconfig,.eslintrc,wrangler.jsonc) or any workflow still runs everything.deploy.yml(new): opt-in deploy ofmainmain, but each side deploys only once its token is set (CLOUDFLARE_API_TOKEN+CLOUDFLARE_ACCOUNT_ID, orSHOPIFY_APP_AUTOMATION_TOKEN). Until then that side is skipped with a notice and the run stays green, so a fresh copy of the template doesn't show a failed deploy.wrangler deploy.shopify app deployonly ifshopify.app.toml(orshopify.app.<SHOPIFY_APP_CONFIG>.toml) is committed. Otherwise it's skipped with a notice.VITE_SHOPIFY_CLIENT_IDis missing (the app would otherwise ship a broken App Bridge key and every/api/*call would 401), or ifwrangler.jsoncstill has the template'sYOUR_*_IDplaceholders.wrangler secret put.--allow-deletes, because removing an extension also removes its store data.README
A new CI/CD section with the four setup steps. It also warns that a Worker created with the Deploy to Cloudflare button must have its Git integration disconnected first, or every push deploys twice.
Verification
actionlintreports no errors in both workflows.shopify.app.tomldeploys both.shopify.app.tomlwithout its token skips Shopify. A manualbothrun with no tokens fails.web/Pages/Home.tsxand the tests are onlycurrentUser.test.tsand the API integration test (2 files, 8 tests).VITE_SHOPIFY_CLIENT_ID=… vite buildputs the ID intoindex.html, andwrangler deploy --dry-runpasses.deploy: cloudflareagainst a test Worker.