Skip to content
Draft
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
28 changes: 4 additions & 24 deletions .github/workflows/tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,8 @@ jobs:
uses: ./.github/actions/setup-cli-deps
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Get schemas for codegen
run: pnpm graphql-codegen:get-graphql-schemas
- name: Run graphql-codegen
run: pnpm graphql-codegen
- name: Run git diff
run: git diff
- name: Fail if any changes were made
run: 'test -z "$(git status --porcelain)" || { echo -e "Run pnpm graphql-codegen when queries are changed, committing any fixes and generated files" ; exit 1; }'
- name: Check graphql-codegen is up to date
run: pnpm codegen:check:graphql

oclif-checks:
name: 'Check OCLIF manifests & readme & docs'
Expand All @@ -133,22 +127,8 @@ jobs:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Build
run: pnpm build --output-style=stream
- name: Refresh manifests
run: pnpm refresh-manifests
- name: Check if there are changes
run: 'test -z "$(git status --porcelain "**/oclif.manifest.json" )" || { echo -e "Run pnpm refresh-manifests before pushing new commands or flags. Diff here:\n\n$(git diff)" ; exit 1; }'
- name: Refresh readme
run: pnpm refresh-readme
- name: Check if there are changes
run: 'test -z "$(git status --porcelain "packages/cli/README.md" )" || { echo -e "Run pnpm refresh-readme before pushing new commands or flags. Diff here:\n\n$(git diff)" ; exit 1; }'
- name: Refresh code documentation
run: pnpm refresh-code-documentation
- name: Check if there are changes
run: 'test -z "$(git status --porcelain)" || { echo -e "Run pnpm refresh-code-documentation when you update functions with autogenerated examples. Diff here:\n\n$(git diff)" ; exit 1; }'
- name: Build shopify.dev docs
run: pnpm build-dev-docs
- name: Check if there are changes
run: 'test -z "$(git status --porcelain "docs-shopify.dev/generated/*.json" )" || { echo -e "Run (pnpm build-dev-docs) before pushing new commands or flags." ; exit 1; }'
- name: Check OCLIF manifests, readme & docs are up to date
run: pnpm codegen:check:oclif

unit-tests:
name: "Unit tests with Node ${{ matrix.node }} in ${{ matrix.os }}${{ matrix.shard != '' && format(' (shard {0})', matrix.shard) || '' }}"
Expand Down
46 changes: 46 additions & 0 deletions bin/check-codegen-clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Asserts that a codegen step left the working tree clean for its owned paths.
// Single source of truth for the codegen freshness checks run both locally
// (via `pnpm codegen:check*`) and in CI (tests-pr.yml). Each key mirrors one
// regenerate-then-verify step; the message tells the developer how to fix it.
import {execFileSync} from 'node:child_process'

const CHECKS = {
graphql: {
pathspec: [],
message: 'Run pnpm graphql-codegen when queries are changed, committing any fixes and generated files',
},
'oclif:manifests': {
pathspec: ['**/oclif.manifest.json'],
message: 'Run pnpm refresh-manifests before pushing new commands or flags.',
},
'oclif:readme': {
pathspec: ['packages/cli/README.md'],
message: 'Run pnpm refresh-readme before pushing new commands or flags.',
},
'oclif:code-docs': {
pathspec: [],
message: 'Run pnpm refresh-code-documentation when you update functions with autogenerated examples.',
},
'oclif:dev-docs': {
pathspec: ['docs-shopify.dev/generated/*.json'],
message: 'Run pnpm build-dev-docs before pushing new commands or flags.',
},
}

const key = process.argv[2]
const check = CHECKS[key]
if (!check) {
console.error(`Unknown codegen check "${key}". Known checks: ${Object.keys(CHECKS).join(', ')}`)
process.exit(2)
}

const porcelain = execFileSync('git', ['status', '--porcelain', ...check.pathspec], {encoding: 'utf8'})
if (porcelain.trim() === '') {
process.exit(0)
}

const diff = execFileSync('git', ['diff', ...check.pathspec], {encoding: 'utf8'})
console.error(check.message)
console.error('\nDiff here:\n')
console.error(diff)
process.exit(1)
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"bundle-for-release": "nx run-many --target=bundle --all --skip-nx-cache",
"changeset-manifests": "changeset version && pnpm install --no-frozen-lockfile && pnpm refresh-manifests && pnpm refresh-readme && pnpm refresh-code-documentation && bin/update-cli-kit-version.js",
"clean": "nx run-many --target=clean --all --skip-nx-cache && nx reset",
"codegen": "pnpm graphql-codegen:get-graphql-schemas && pnpm graphql-codegen && pnpm refresh-manifests && pnpm refresh-code-documentation && pnpm build-dev-docs",
"codegen:check:graphql": "pnpm graphql-codegen:get-graphql-schemas && pnpm graphql-codegen && node ./bin/check-codegen-clean.js graphql",
"codegen:check:oclif": "pnpm refresh-manifests && node ./bin/check-codegen-clean.js oclif:manifests && pnpm refresh-readme && node ./bin/check-codegen-clean.js oclif:readme && pnpm refresh-code-documentation && node ./bin/check-codegen-clean.js oclif:code-docs && pnpm build-dev-docs && node ./bin/check-codegen-clean.js oclif:dev-docs",
"create-app": "nx build create-app && node packages/create-app/bin/dev.js --package-manager pnpm",
"deploy-experimental": "node bin/deploy-experimental.js",
"graph": "nx graph",
Expand Down
Loading