|
1 | 1 | name: Fresh Install Tests |
2 | 2 |
|
3 | | -# Periodically tests BlockNote with the latest versions of its dependencies |
4 | | -# (within declared ranges), without a lockfile. This catches breakage when a |
| 3 | +# Periodically tests BlockNote with the latest versions of its production |
| 4 | +# dependencies (within declared semver ranges). This catches breakage when a |
5 | 5 | # new release of a dep like @tiptap/* or prosemirror-* ships and conflicts |
6 | 6 | # with BlockNote's declared ranges — the kind of failure a user would hit when |
7 | 7 | # running `npm install @blocknote/react` in a fresh project. |
8 | 8 | # |
9 | | -# DevDependencies (vitest, vite, typescript, etc.) are still bounded by their |
10 | | -# declared ranges in package.json; only prod/peer deps get freshly resolved. |
| 9 | +# Only production dependencies of published (non-private) packages are updated. |
| 10 | +# DevDependencies (vitest, vite, typescript, etc.) stay pinned to the lockfile, |
| 11 | +# so test tooling churn doesn't cause false positives. |
11 | 12 |
|
12 | 13 | on: |
13 | 14 | schedule: |
14 | 15 | - cron: "0 2 * * *" # Daily at 02:00 UTC |
15 | 16 | workflow_dispatch: # Allow manual runs |
16 | 17 |
|
| 18 | +env: |
| 19 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 20 | + pnpm_config_store_dir: ./node_modules/.pnpm-store |
| 21 | + |
17 | 22 | jobs: |
18 | 23 | fresh-install-unit-tests: |
19 | 24 | name: Unit Tests (Fresh Dep Resolution) |
20 | 25 | runs-on: ubuntu-latest |
21 | 26 | timeout-minutes: 30 |
22 | 27 |
|
23 | 28 | steps: |
24 | | - - uses: actions/checkout@v4 |
| 29 | + - id: checkout |
| 30 | + uses: actions/checkout@v6 |
25 | 31 |
|
26 | | - - name: Install pnpm |
27 | | - uses: pnpm/action-setup@v4 |
| 32 | + - id: install_pnpm |
| 33 | + name: Install pnpm |
| 34 | + uses: pnpm/action-setup@v5 |
28 | 35 |
|
29 | | - - uses: actions/setup-node@v4 |
| 36 | + - id: setup_node |
| 37 | + uses: actions/setup-node@v6 |
30 | 38 | with: |
31 | 39 | node-version-file: ".nvmrc" |
32 | | - # Intentionally no pnpm cache — we want a genuinely fresh install |
| 40 | + # Intentionally no pnpm cache — we want fresh prod dep resolution |
33 | 41 |
|
34 | | - # Required for the `canvas` native dependency |
35 | | - - name: Install system dependencies |
36 | | - run: sudo apt-get update && sudo apt-get install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev pkg-config |
| 42 | + - id: install_dependencies |
| 43 | + name: Install dependencies |
| 44 | + run: pnpm install |
37 | 45 |
|
38 | | - - name: Remove lockfile to force fresh dep resolution |
39 | | - # Removing pnpm-lock.yaml causes pnpm to resolve all dependencies to |
40 | | - # the latest versions that satisfy the ranges declared in package.json |
41 | | - # (including pnpm-workspace.yaml overrides). This is equivalent to what |
42 | | - # a new user experiences when installing BlockNote in a blank project. |
43 | | - run: rm pnpm-lock.yaml |
| 46 | + - id: update_prod_deps |
| 47 | + name: Update prod deps of published packages |
| 48 | + # Resolves production dependencies of every published (non-private) |
| 49 | + # workspace package to the latest version within their declared semver |
| 50 | + # ranges. This simulates what a user gets when running |
| 51 | + # `npm install @blocknote/react` in a fresh project. |
| 52 | + # DevDependencies are left at their lockfile versions. |
| 53 | + run: | |
| 54 | + FILTERS=$(node -e " |
| 55 | + const fs = require('fs'); |
| 56 | + const path = require('path'); |
| 57 | + fs.readdirSync('packages').forEach(dir => { |
| 58 | + try { |
| 59 | + const pkg = JSON.parse(fs.readFileSync(path.join('packages', dir, 'package.json'), 'utf8')); |
| 60 | + if (!pkg.private && pkg.name) process.stdout.write('--filter ' + pkg.name + ' '); |
| 61 | + } catch {} |
| 62 | + }); |
| 63 | + ") |
| 64 | + echo "Updating prod deps for: $FILTERS" |
| 65 | + eval pnpm update --prod $FILTERS |
44 | 66 |
|
45 | | - - name: Install dependencies |
46 | | - run: pnpm install --no-frozen-lockfile |
| 67 | + - id: dedupe_deps |
| 68 | + name: Dedupe transitive dependencies |
| 69 | + # After bumping the publishable packages' prod deps, collapse any |
| 70 | + # duplicate transitive resolutions (e.g. @tiptap/core + @tiptap/pm) |
| 71 | + # that would otherwise differ between the updated publishable packages |
| 72 | + # and the un-updated examples/playground. Without this, TypeScript |
| 73 | + # treats the two copies' exports as unrelated types and example-editor |
| 74 | + # fails to build (TS2322 on Extension<any, any> vs AnyExtension). |
| 75 | + # Dedupe only rewrites the lockfile — it does NOT modify package.json, |
| 76 | + # so the examples' "@blocknote/*": "latest" specs (which is what |
| 77 | + # CodeSandbox users see) stay intact. |
| 78 | + run: pnpm dedupe |
47 | 79 |
|
48 | | - - name: Build packages |
| 80 | + - id: build_packages |
| 81 | + name: Build packages |
49 | 82 | run: pnpm run build |
50 | 83 | env: |
51 | 84 | NX_SKIP_NX_CACHE: "true" |
52 | 85 |
|
53 | | - - name: Run unit tests |
| 86 | + - id: run_unit_tests |
| 87 | + name: Run unit tests |
54 | 88 | run: pnpm run test |
55 | 89 | env: |
56 | 90 | NX_SKIP_NX_CACHE: "true" |
| 91 | + |
| 92 | + - name: Notify Slack on workflow failure |
| 93 | + if: ${{ failure() }} |
| 94 | + env: |
| 95 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 96 | + REPOSITORY: ${{ github.repository }} |
| 97 | + WORKFLOW: ${{ github.workflow }} |
| 98 | + RUN_ID: ${{ github.run_id }} |
| 99 | + RUN_NUMBER: ${{ github.run_number }} |
| 100 | + RUN_ATTEMPT: ${{ github.run_attempt }} |
| 101 | + BRANCH: ${{ github.ref_name }} |
| 102 | + run: | |
| 103 | + if [ -z "$SLACK_WEBHOOK_URL" ]; then |
| 104 | + echo "SLACK_WEBHOOK_URL is not configured; skipping Slack notification." |
| 105 | + exit 0 |
| 106 | + fi |
| 107 | +
|
| 108 | + failed_step="Unknown step" |
| 109 | + if [ "${{ steps.checkout.outcome }}" = "failure" ]; then |
| 110 | + failed_step="Checkout repository" |
| 111 | + elif [ "${{ steps.install_pnpm.outcome }}" = "failure" ]; then |
| 112 | + failed_step="Install pnpm" |
| 113 | + elif [ "${{ steps.setup_node.outcome }}" = "failure" ]; then |
| 114 | + failed_step="Setup Node.js" |
| 115 | + elif [ "${{ steps.install_dependencies.outcome }}" = "failure" ]; then |
| 116 | + failed_step="Install dependencies" |
| 117 | + elif [ "${{ steps.update_prod_deps.outcome }}" = "failure" ]; then |
| 118 | + failed_step="Update prod deps of published packages" |
| 119 | + elif [ "${{ steps.dedupe_deps.outcome }}" = "failure" ]; then |
| 120 | + failed_step="Dedupe transitive dependencies" |
| 121 | + elif [ "${{ steps.build_packages.outcome }}" = "failure" ]; then |
| 122 | + failed_step="Build packages" |
| 123 | + elif [ "${{ steps.run_unit_tests.outcome }}" = "failure" ]; then |
| 124 | + failed_step="Run unit tests" |
| 125 | + fi |
| 126 | +
|
| 127 | + run_url="https://github.com/${REPOSITORY}/actions/runs/${RUN_ID}" |
| 128 | + message=$(printf '%s\n%s\n%s\n%s' \ |
| 129 | + ":warning: Fresh Install Tests failed in *${REPOSITORY}* on branch *${BRANCH}*." \ |
| 130 | + "*Workflow:* ${WORKFLOW}" \ |
| 131 | + "*Run:* <${run_url}|#${RUN_NUMBER} (attempt ${RUN_ATTEMPT})>" \ |
| 132 | + "*Failed step:* ${failed_step}") |
| 133 | + payload=$(jq --compact-output --null-input --arg text "$message" '{text: $text}') |
| 134 | +
|
| 135 | + curl -sS -X POST \ |
| 136 | + --fail \ |
| 137 | + --retry 4 \ |
| 138 | + --retry-all-errors \ |
| 139 | + --retry-max-time 60 \ |
| 140 | + --connect-timeout 10 \ |
| 141 | + --max-time 30 \ |
| 142 | + -H "Content-type: application/json" \ |
| 143 | + --data "$payload" \ |
| 144 | + "$SLACK_WEBHOOK_URL" |
0 commit comments