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

pr.yml

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