-
Notifications
You must be signed in to change notification settings - Fork 21
Fail CI on ProseMirror schema drift #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: ProseMirror Schema Check | ||
|
|
||
| # Fails when schemas/prosemirror/ is out of date — i.e. an editor extension | ||
| # change (or a TipTap dependency bump) landed without a regenerated schema. | ||
| # The export is byte-deterministic, so a plain diff is a reliable check. | ||
| # See schemas/prosemirror/README.md. | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| schema-drift: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| TIPTAP_PRO_TOKEN: ${{ secrets.TIPTAP_PRO_TOKEN }} | ||
| FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Check registry secrets | ||
| run: | | ||
| if [ -z "$TIPTAP_PRO_TOKEN" ] || [ -z "$FONTAWESOME_NPM_AUTH_TOKEN" ]; then | ||
| echo "::error::Missing TIPTAP_PRO_TOKEN and/or FONTAWESOME_NPM_AUTH_TOKEN repo secrets; npm ci needs them for the private TipTap Pro and Font Awesome registries." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: npm | ||
|
|
||
| # Same registry mapping developers keep in their local .npmrc; the | ||
| # ${VAR} references are expanded by npm itself from the job env. | ||
| - name: Configure private npm registries | ||
| run: | | ||
| { | ||
| echo '@tiptap-pro:registry=https://registry.tiptap.dev/' | ||
| echo '//registry.tiptap.dev/:_authToken=${TIPTAP_PRO_TOKEN}' | ||
| echo '@awesome.me:registry=https://npm.fontawesome.com/' | ||
| echo '@fortawesome:registry=https://npm.fontawesome.com/' | ||
| echo '//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN}' | ||
| } > .npmrc | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
Check warning on line 55 in .github/workflows/schema-check.yml
|
||
|
|
||
|
|
||
| - name: Export ProseMirror schemas | ||
| run: npm run schema:export | ||
|
|
||
| - name: Fail on schema drift | ||
| run: | | ||
| if [ -n "$(git status --porcelain -- schemas/prosemirror/)" ]; then | ||
| echo '::error::schemas/prosemirror/ is out of date. Run `npm run schema:export` and commit the result (see schemas/prosemirror/README.md).' | ||
| echo | ||
| echo 'Drift:' | ||
| git status --porcelain -- schemas/prosemirror/ | ||
| git diff -- schemas/prosemirror/ | ||
| exit 1 | ||
| fi | ||
| echo 'Schemas are up to date.' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,6 +152,7 @@ | |
| "prettier --write --ignore-path .gitignore", | ||
| "eslint --fix --no-warn-ignored" | ||
| ], | ||
| "**/*.{ts,tsx}": "bash -c 'npm run type-check'" | ||
| "**/*.{ts,tsx}": "bash -c 'npm run type-check'", | ||
| "{components/Editor/extensions/**/*.{ts,tsx},components/Comment/lib/**/*.{ts,tsx},scripts/export-prosemirror-schema.ts}": "bash -c 'npm run schema:export && git add schemas/prosemirror'" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this hook runs while a developer has an unrelated unstaged edit under Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For same-repository pull requests, these job-wide secrets remain available after checkout while both
npm ciand the PR-controlledschema:exportscript execute, so a contributor can alterprepare, the export script, or an imported module to transmit both private-registry credentials. This is not limited to explicit export code: npm documents thatnpm ciruns install and prepare lifecycle scripts. Install with scripts disabled and ensure the environment variables and generated.npmrcare removed before executing any code from the pull request.Useful? React with 👍 / 👎.