Use native bash retry instead of third-party action #1324
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build-test | |
| permissions: | |
| contents: read | |
| on: | |
| # Run for pushes (from collaborators) | |
| push: | |
| # Scope to only branches (no tags) to avoid duplicate runs for pushes of | |
| # tags, handled by `release.yml` with a `workflow_call`. | |
| branches: | |
| - "**" | |
| # Run for any pull requests | |
| pull_request: | |
| # Allow this to be called from other workflows | |
| workflow_call: | |
| # Run weekly on Sundays at 9 AM UTC to proactively catch new `pnpm audit` | |
| # issues, external breaking changes (since we test against the latest Tiptap | |
| # version), etc. | |
| schedule: | |
| - cron: "0 9 * * 0" | |
| jobs: | |
| build_and_test: | |
| name: tiptap=${{ matrix.tiptap-version || 'current' }}, TS=${{ matrix.typescript-version || 'current' }} | |
| # Dedupe PRs from branches created by collaborators within this repo: | |
| # - Always run for internal branch `push` (for/before a PR) and | |
| # `workflow_call` (releases). | |
| # - For `pull_request`, only run when the PR originates from a fork. | |
| if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [20] | |
| # Run against different versions of Tiptap to ensure compatibility: the | |
| # version used in our lockfile, an older version we support, the latest | |
| # v2 version, and the latest v3 major. | |
| tiptap-version: [null, 2.0.4, "^2.10.0", "^3.0.0"] | |
| # Run against this package's TS version, as well as the minimum TS | |
| # version that MUI supports, based on DefinitelyType's support window | |
| # (https://mui.com/material-ui/getting-started/supported-platforms/#typescript). | |
| # We skip testing against some combinations of TS+Tiptap versions to | |
| # avoid excessive CI runs. | |
| typescript-version: [null, 4.9] | |
| exclude: | |
| - tiptap-version: "^2.10.0" | |
| typescript-version: 4.9 | |
| - tiptap-version: "^3.0.0" | |
| typescript-version: 4.9 | |
| include: | |
| # Specify the version of y-prosemirror to use to ensure proper peer | |
| # dependency compatibility and resolution on older Tiptap versions. | |
| # This package is not a peer in Tiptap v3. | |
| - tiptap-version: 2.0.4 | |
| y-prosemirror-version: 1.0.20 | |
| - tiptap-version: "^2.10.0" | |
| y-prosemirror-version: ^1.2.15 | |
| env: | |
| # Note that we also use this env var in our eslint config, to ignore some | |
| # overly strict lints when testing builds against older Tiptap versions. | |
| TIPTAP_MAJOR: ${{ (startsWith(matrix.tiptap-version, '2.') || startsWith(matrix.tiptap-version, '^2')) && '2' || '3' }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Install Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "pnpm" | |
| - run: pnpm install | |
| - if: ${{ matrix.typescript-version != null }} | |
| name: Install TypeScript ${{ matrix.typescript-version }} | |
| # Install in both projects for consistent linting | |
| run: | | |
| pnpm add -D "typescript@${{ matrix.typescript-version }}" | |
| pnpm --dir example add -D "typescript@${{ matrix.typescript-version }}" | |
| - name: Dependencies audit | |
| run: pnpm audit --audit-level=high | |
| - if: ${{ env.TIPTAP_MAJOR == '2' }} | |
| name: Swap out v3-specific dependencies for v2 versions | |
| run: | | |
| pnpm remove -D "@tiptap/extension-collaboration-caret" | |
| pnpm remove -D "@tiptap/y-tiptap" | |
| pnpm add -D "@tiptap/extension-collaboration-cursor@${{ matrix.tiptap-version }}" | |
| - if: ${{ matrix.y-prosemirror-version }} | |
| name: Install y-prosemirror peer dependency ${{ matrix.y-prosemirror-version }} | |
| run: pnpm add -D "y-prosemirror@${{ matrix.y-prosemirror-version }}" | |
| - if: ${{ matrix.tiptap-version != null }} | |
| name: Override tiptap version to ${{ matrix.tiptap-version }} | |
| # So that we can update all tiptap packages at once, we use | |
| # `pnpm update`, which allows wildcard syntax and version specifier | |
| # (unlike `pnpm install`). We have to separately install the indirect | |
| # dependencies of @tiptap/react with the desired version (the floating | |
| # and bubble menu packages), since `update` doesn't apply to them. | |
| run: | | |
| pnpm update -D "@tiptap/*@${{ matrix.tiptap-version }}" | |
| pnpm add -D "@tiptap/extension-floating-menu@${{ matrix.tiptap-version }}" "@tiptap/extension-bubble-menu@${{ matrix.tiptap-version }}" | |
| pnpm dedupe | |
| # For our current lockfile-managed dependencies, ensure no duplicates | |
| - if: ${{ matrix.tiptap-version == null }} | |
| name: Check for duplicate dependencies | |
| run: pnpm dedupe --check | |
| - if: ${{ env.TIPTAP_MAJOR == '2' }} | |
| name: Resolve known inconsequential TS differences in Tiptap v2 | |
| # NodeViewContent wasn't generic in Tiptap v2, so remove the generic | |
| # syntax | |
| run: | | |
| sed -i 's/NodeViewContent<"span">/NodeViewContent/g' src/extensions/HeadingWithAnchorComponent.tsx | |
| - if: ${{ matrix.tiptap-version == '2.0.4' }} | |
| name: Resolve known inconsequential TS differences in Tiptap 2.0.4 | |
| # 1) Delete the `@ts-expect-error` comments where needed, as older | |
| # versions of Tiptap didn't have the same types that required this | |
| # override. | |
| # 2) Add `@ts-expect-error` to TableImproved.ts where the typing in | |
| # older versions was incorrect (as Tiptap itself did here | |
| # https://github.com/ueberdosis/tiptap/blob/b0198eb14b98db5ca691bd9bfe698ffaddbc4ded/packages/extension-table/src/table.ts#L253, | |
| # and we did prior to updating to newer Tiptap). | |
| run: | | |
| sed -i '/@ts-expect-error/d' src/extensions/HeadingWithAnchor.ts src/extensions/ResizableImage.ts | |
| sed -i '/View: this.options.View/i\ | |
| // @ts-expect-error incorrect type\ | |
| ' src/extensions/TableImproved.ts | |
| - name: Build | |
| run: pnpm run build | |
| - name: Install dependencies in example project | |
| # In order to lint both our main project and the example sub-project, we | |
| # need to install the dependencies for the example project too. | |
| run: pnpm run example:install | |
| - if: ${{ env.TIPTAP_MAJOR != '2' }} | |
| name: Type check | |
| # Though this largely happens as part of `pnpm run build`, there are | |
| # some files that are not part of the publishable build but which we'd | |
| # also like to type-check. As such, we only bother doing this for the | |
| # newer Tiptap versions. | |
| run: pnpm run type:check | |
| # prettier's organize-imports plugin depends on TypeScript, so we only run | |
| # format-checking against the current TS version | |
| - if: ${{ matrix.typescript-version == null }} | |
| name: Format check | |
| run: pnpm run format:check | |
| - name: Lint check | |
| run: pnpm run lint:check | |
| - name: Spell check | |
| run: pnpm run spell:check | |
| # We run the spell check so we can see the output in CI if/when we like, | |
| # but we won't enforce it, since there are too many technical/product | |
| # words used that are outside the standard dictionary. | |
| continue-on-error: true | |
| - name: Validate markdown links | |
| # Since most of our documentation is in README.md, notably with lots of | |
| # internal anchor links, validate that they're formed properly. As the | |
| # README and documentation is updated, we want to ensure that links | |
| # remain correct. (This also checks external links, though that's a | |
| # secondary concern.) | |
| # Retry once if the check fails due to transient network issues or other | |
| # flakiness. | |
| run: pnpm run md-link:check || (echo "Retrying markdown link check..." && pnpm run md-link:check) | |
| - name: Test | |
| # Run the tests and print out the coverage information. In the future, | |
| # we could integrate with Codecov or something. | |
| run: pnpm run test:coverage | |
| - name: Validate the build's packaging CJS and ESM compatibility | |
| # For now, we ignore the named-exports rule, as this gets triggered for | |
| # the `node16 (from ESM)` context, and appears hard to resolve while | |
| # still avoiding these issues: | |
| # - https://github.com/sjdemartini/mui-tiptap/issues/256 | |
| # - https://github.com/sjdemartini/mui-tiptap/issues/264 | |
| # Ideally we can fix this in the future without breaking Node and NextJS | |
| # contexts. | |
| run: npx @arethetypeswrong/[email protected] --pack --ignore-rules named-exports |