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

pr.yml

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