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

pr.yml

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