Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

pr.yml

238 lines8.6 KB

1name: PR
2​
3on:
4 pull_request:
5​
6 # Allows you to run this workflow manually from the Actions tab
7 workflow_dispatch:
8​
9concurrency:
10 group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
11 cancel-in-progress: true
12​
13permissions:
14 contents: read
15​
16jobs:
17 lint:
18 name: Lint
19 runs-on: ubuntu-latest
20 steps:
21 - name: Checkout
22 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23 with:
24 # The run-budget report compares changed files with the merge-base.
25 fetch-depth: 0
26 persist-credentials: false
27 - name: Setup Tools
28 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
29 - name: Check lint
30 run: pnpm run lint:check
31 - name: Check release versioning
32 run: pnpm run test:release
33 - name: Typecheck doc and skill examples
34 run: pnpm run test:doc-snippets
35 - name: Check oracle lint without inline directives
36 run: pnpm run lint:oracles
37 - name: Report lowered oracle run budgets
38 run: node scripts/check-oracle-run-counts.mjs --format=github
39 - name: Test oracle lint rules
40 run: pnpm run test:lint-rules
41 minified-db:
42 name: Minified DB public API
43 runs-on: ubuntu-latest
44 steps:
45 - name: Checkout
46 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
47 with:
48 persist-credentials: false
49 - name: Setup Tools
50 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
51 - name: Check private-member mangle cache
52 run: pnpm run check:mangle
53 - name: Build DB packages
54 run: pnpm --filter @tanstack/db-ivm --filter @tanstack/db --filter @tanstack/react-db build
55 - name: Check minified public API
56 run: pnpm run test:minified-db
57 - name: Check client-only query bundles
58 run: pnpm run test:ssr-bundle
59 - name: Check production error text
60 run: pnpm run test:production-errors
61 - name: Check DB tests against built dist
62 run: pnpm --filter @tanstack/db test:dist
63 test-db:
64 name: Test (${{ matrix.group }})
65 runs-on: ubuntu-latest
66 strategy:
67 fail-fast: false
68 matrix:
69 group: [db-1, db-2, db-replay]
70 env:
71 TEST_GROUP: ${{ matrix.group }}
72 steps:
73 - name: Checkout
74 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
75 with:
76 persist-credentials: false
77 - name: Setup Tools
78 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
79 - name: Build dependencies
80 run: node scripts/ci-tests.mjs build "$TEST_GROUP"
81 - name: Run tests
82 run: node scripts/ci-tests.mjs test "$TEST_GROUP"
83 - name: Upload DB report
84 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
85 with:
86 name: db-report-${{ matrix.group }}
87 path: packages/db/.vitest-reports/*.json
88 include-hidden-files: true
89 if-no-files-found: error
90 retention-days: 1
91 test-packages:
92 name: Test (${{ matrix.group }})
93 runs-on: ubuntu-latest
94 strategy:
95 fail-fast: false
96 matrix:
97 group:
98 [ivm-offline, sqlite-core, sqlite-adapters, frameworks, collections]
99 env:
100 TEST_GROUP: ${{ matrix.group }}
101 steps:
102 - name: Checkout
103 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
104 with:
105 persist-credentials: false
106 - name: Setup Tools
107 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
108 - name: Build dependencies
109 run: node scripts/ci-tests.mjs build "$TEST_GROUP"
110 - name: Typecheck Test Sources
111 if: matrix.group == 'ivm-offline'
112 run: pnpm run typecheck:tests
113 - name: Run tests
114 run: node scripts/ci-tests.mjs test "$TEST_GROUP"
115 - name: Check dependency versions
116 if: matrix.group == 'ivm-offline'
117 run: |
118 if ! pnpm run test:sherif; then
119 echo ""
120 echo "=========================================="
121 echo "❌ Sherif found dependency version mismatches"
122 echo ""
123 echo "To fix this locally, run:"
124 echo " pnpm exec sherif --fix -i zod"
125 echo ""
126 echo "Then commit the changes to package.json files."
127 echo "=========================================="
128 exit 1
129 fi
130 test:
131 name: Test
132 if: always()
133 needs: [lint, test-db, test-packages]
134 runs-on: ubuntu-latest
135 steps:
136 - name: Require lint and every test group to succeed
137 env:
138 LINT_RESULT: ${{ needs.lint.result }}
139 DB_RESULT: ${{ needs.test-db.result }}
140 PACKAGES_RESULT: ${{ needs.test-packages.result }}
141 run: test "$LINT_RESULT" = success && test "$DB_RESULT" = success && test "$PACKAGES_RESULT" = success
142 - name: Checkout
143 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
144 with:
145 persist-credentials: false
146 - name: Setup Tools
147 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
148 - name: Download DB reports
149 uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
150 with:
151 pattern: db-report-*
152 path: packages/db/.vitest-reports
153 merge-multiple: true
154 - name: Merge DB coverage and test reports
155 run: pnpm --dir packages/db exec vitest --mergeReports .vitest-reports
156 preview:
157 name: Preview
158 runs-on: ubuntu-latest
159 permissions:
160 contents: read
161 pull-requests: write
162 steps:
163 - name: Checkout
164 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
165 with:
166 fetch-depth: 0
167 persist-credentials: false
168 - name: Setup Tools
169 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
170 - name: Build Packages
171 run: pnpm run build
172 - name: Publish Previews
173 run: pnpx pkg-pr-new publish --pnpm --compact './packages/*' --template './examples/*/*'
174 size:
175 name: Compressed size
176 if: github.event_name == 'pull_request'
177 runs-on: ubuntu-latest
178 permissions:
179 contents: read
180 pull-requests: write
181 steps:
182 - name: Checkout
183 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
184 with:
185 fetch-depth: 0
186 persist-credentials: false
187 - name: Setup Tools
188 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
189 - name: Compare DB and React DB sizes
190 uses: preactjs/compressed-size-action@66325aad6443cb7cf89c4bfcd414aea2367cda94 # 2.9.1
191 with:
192 repo-token: '${{ secrets.GITHUB_TOKEN }}'
193 pattern: './packages/{db,react-db}/dist/**/*.{js,mjs}'
194 comment-key: 'db-and-react-package-size'
195 # The action installs and builds both head and base. Use commands
196 # already present on the base, including the minified build's deps.
197 install-script: bash -c "pnpm install --frozen-lockfile && pnpm --filter @tanstack/react-router-with-db... build"
198 build-script: 'build:minified'
199 build-example:
200 name: Build Example Site
201 runs-on: ubuntu-latest
202 steps:
203 - name: Checkout
204 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
205 with:
206 persist-credentials: false
207 - name: Setup Tools
208 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
209 - name: Build Packages
210 run: pnpm run build
211 - name: Check action enforcement example
212 run: |
213 pnpm --filter @tanstack/db-example-react-action-enforcement test
214 pnpm --filter @tanstack/db-example-react-action-enforcement lint
215 pnpm --filter @tanstack/db-example-react-action-enforcement build
216 - name: Build Example Site
217 run: |
218 cd examples/react/todo
219 pnpm build
220 - name: Build Angular Todo Example
221 run: pnpm --dir examples/angular/todos build
222 build-starter:
223 name: Build Example Site
224 runs-on: ubuntu-latest
225 steps:
226 - name: Checkout
227 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
228 with:
229 persist-credentials: false
230 - name: Setup Tools
231 uses: tanstack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3
232 - name: Build Packages
233 run: pnpm run build
234 - name: Build Starter Site
235 run: |
236 cd examples/react/projects
237 cp .env.example .env
238 pnpm build