Skip to content

Commit

Permalink
chore: improve CI (#4288)
Browse files Browse the repository at this point in the history
* chore: get rit of rescript

* chore: solid-query doesn't need jscodeshift

* chore: move react dependencies to react packages

* chore: move react dependencies to react packages

* chore: add descriptions

* chore: remove special lint tsconfigs

we want to use the same tsconfigs for linting as for everything else

* chore: make all tests run in parallel with pnpm

* chore: chunk ci pipeline

* chore: move react specific test setup into react packages

* chore: remove jest configs from tsconfig.json

because they live outside of the root dir (src)

* chore: fix weird type errors in solid tests

* chore: fix running the lint task

* chore: run the typecheck task in parallel

* chore: add a clean task

* Revert "chore: run the typecheck task in parallel"

This reverts commit 53573f5.

* chore: no idea why this is errors

* chore: fix codecov upload

* chore: add runInBand

* Revert "chore: add runInBand"

This reverts commit 568e12c.

* chore: make jest tests temporarily exit with 0

so that we can test code-coverage

* chore: only run test jests

* Revert "chore: make jest tests temporarily exit with 0"

This reverts commit ad09900.

* chore: fix solid-query tests with a custom transform

* chore: use checkout v3

* chore: fix node-version for Test React 17 pipeline

* chore: fix watch mode

we cannot run jest:dev anymore because streaming watch mode to multiple packages is not a thing; you'd need to go into a separate package and watch those tests there
  • Loading branch information
TkDodo committed Oct 12, 2022
1 parent df598a7 commit 4ae9956
Show file tree
Hide file tree
Showing 63 changed files with 1,376 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .codesandbox/ci.json
@@ -1,6 +1,6 @@
{
"installCommand": "install:csb",
"sandboxes": ["/examples/react/basic", "/examples/react/basic-typescript", "/examples/solid/basic-typescript", "/examples/vue/basic"],
"sandboxes": ["/examples/react/basic-typescript", "/examples/solid/basic-typescript", "/examples/vue/basic"],
"packages": ["packages/**"],
"node": "16"
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
name: 'Test & Publish'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: pnpm/action-setup@v2.2.2
Expand Down
99 changes: 82 additions & 17 deletions .github/workflows/pr.yml
Expand Up @@ -2,33 +2,98 @@ name: pr
on: [pull_request]
jobs:
test:
name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}'
name: 'Test'
runs-on: ubuntu-latest
strategy:
matrix:
node: [16.14.2]
react: [17, 18]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: 16.14.2
cache: 'pnpm'
- name: Install dependencies
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
- run: |
pnpm run test:ci
pnpm run test:size
if: matrix.react == '18'
env:
REACTJS_VERSION: ${{ matrix.react }}
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
- run: pnpm run test:jest
if: matrix.react == '17'
env:
REACTJS_VERSION: ${{ matrix.react }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
lint:
name: 'Lint'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: 'pnpm'
- name: Install dependencies
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
- run: pnpm run test:eslint
typecheck:
name: 'Typecheck'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: 'pnpm'
- name: Install dependencies
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
- run: pnpm run typecheck
format:
name: 'Format'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: 'pnpm'
- name: Install dependencies
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
- run: pnpm run test:format
test-react-17:
name: 'Test React 17'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: 'pnpm'
- name: Install dependencies
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
- run: pnpm run test:react:17
env:
REACTJS_VERSION: 17
test-size:
name: 'Size'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.2
with:
version: 7
- uses: actions/setup-node@v3
with:
node-version: 16.14.2
cache: 'pnpm'
- name: Install dependencies
run: pnpm --filter "./packages/**" --filter query --prefer-offline install
- run: pnpm run test:size
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion examples/react/basic-typescript/index.html
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />

<title>Tanstack Query React Basic Typescript Example App</title>
<title>Tanstack Query React Basic TypeScript Example App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
2 changes: 1 addition & 1 deletion examples/react/basic-typescript/public/emblem-light.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 16 additions & 12 deletions jest.config.ts → jest-preset.js
Expand Up @@ -15,7 +15,7 @@ const moduleNameMapper = {
...packages.reduce(
(acc, name) => ({
...acc,
[`${namespace}/${name}(.*)$`]: `<rootDir>/packages/./${name}/src/$1`,
[`${namespace}/${name}(.*)$`]: `<rootDir>/../../packages/./${name}/src/$1`,
}),
{},
),
Expand All @@ -24,16 +24,20 @@ const moduleNameMapper = {
module.exports = {
collectCoverage: true,
coverageReporters: ['json', 'lcov', 'text', 'clover', 'text-summary'],
projects: packages.map((d: string) => ({
displayName: d,
clearMocks: true,
testEnvironment: 'jsdom',
testMatch: [`<rootDir>/packages/${d}/**/*.test.[jt]s?(x)`],
setupFilesAfterEnv: [`<rootDir>/jest.setup.js`],
snapshotFormat: {
printBasicPrototype: false,
testMatch: ['<rootDir>/**/*.test.[jt]s?(x)'],
transform: { '^.+\\.(ts|tsx)$': 'ts-jest' },
clearMocks: true,
testEnvironment: 'jsdom',
snapshotFormat: {
printBasicPrototype: false,
},
globals: {
'ts-jest': {
isolatedModules: true,
diagnostics: {
exclude: ['**'],
},
},
moduleNameMapper,
preset: d.includes("solid") ? 'solid-jest/preset/browser' : undefined,
})),
},
moduleNameMapper,
}
13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -2,21 +2,20 @@
"name": "query",
"repository": "https://github.com/tanstack/query.git",
"scripts": {
"clean": "pnpm --filter \"./packages/**\" --parallel --no-bail run clean",
"preinstall": "if [ \"$CI\" = \"true\" ]; then echo \"Skipping preinstall...\"; else npx -y only-allow pnpm; fi",
"install:csb": "pnpm install --frozen-lockfile",
"test": "(is-ci && pnpm run test:ci) || pnpm run test:dev",
"test": "pnpm run test:ci",
"test:ci": "pnpm run typecheck && pnpm run test:format && pnpm run test:eslint && pnpm run test:jest",
"test:dev": "pnpm run typecheck && pnpm run test:format && pnpm run test:eslint && pnpm run test:jest:dev",
"test:dev:17": "REACTJS_VERSION=17 jest --watch",
"test:react:17": "pnpm --filter \"./packages/react-*\" run test:jest",
"test:eslint": "pnpm --filter \"./packages/**\" --parallel --no-bail run test:eslint",
"test:format": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\" --check",
"test:jest": "pnpm --filter \"./packages/**\" --parallel --no-bail run test:codemods && jest --config ./jest.config.ts",
"test:jest:dev": "jest --config ./jest.config.ts --watch",
"test:jest": "pnpm --filter \"./packages/**\" --parallel --no-bail run test:jest",
"test:size": "pnpm run build && bundlewatch",
"build": "rollup --config rollup.config.js && pnpm run typecheck && pnpm run build:copyTypes",
"build:copyTypes": "cp packages/react-query-devtools/build/lib/index.d.ts packages/react-query-devtools/build/lib/index.prod.d.ts",
"typecheck": "tsc -b",
"watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"pnpm run typecheck --watch\" \"pnpm run test\"",
"watch": "concurrently --kill-others \"rollup --config rollup.config.js -w\" \"pnpm run typecheck --watch\"",
"dev": "pnpm run watch",
"prettier": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\"",
"prettier:write": "pnpm run prettier -- --write",
Expand Down Expand Up @@ -84,11 +83,11 @@
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-visualizer": "^5.6.0",
"solid-jest": "^0.2.0",
"solid-js": "^1.5.7",
"solid-testing-library": "^0.3.0",
"stream-to-array": "^2.3.0",
"svelte": "^3.48.0",
"ts-jest": "^27.1.1",
"ts-node": "^10.7.0",
"typescript": "^4.7.4",
"vue": "^3.2.33"
Expand Down
2 changes: 1 addition & 1 deletion packages/query-async-storage-persister/.eslintrc
@@ -1,6 +1,6 @@
{
"parserOptions": {
"project": "./tsconfig.lint.json",
"project": "./tsconfig.json",
"sourceType": "module"
}
}
4 changes: 4 additions & 0 deletions packages/query-async-storage-persister/jest.config.ts
@@ -0,0 +1,4 @@
export default {
displayName: 'query-async-storage-persister',
preset: '../../jest-preset.js',
}
6 changes: 4 additions & 2 deletions packages/query-async-storage-persister/package.json
@@ -1,7 +1,7 @@
{
"name": "@tanstack/query-async-storage-persister",
"version": "4.10.3",
"description": "TODO",
"description": "A persister for asynchronous storages, to be used with TanStack/Query",
"author": "tannerlinsley",
"license": "MIT",
"repository": "tanstack/query",
Expand Down Expand Up @@ -29,7 +29,9 @@
],
"scripts": {
"clean": "rm -rf ./build",
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src"
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
"test:jest": "../../node_modules/.bin/jest --config ./jest.config.ts",
"test:dev": "pnpm run test:jest --watch"
},
"dependencies": {
"@tanstack/query-persist-client-core": "workspace:*"
Expand Down
13 changes: 0 additions & 13 deletions packages/query-async-storage-persister/tsconfig.lint.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/query-broadcast-client-experimental/.eslintrc
@@ -1,6 +1,6 @@
{
"parserOptions": {
"project": "./tsconfig.lint.json",
"project": "./tsconfig.json",
"sourceType": "module"
}
}
4 changes: 4 additions & 0 deletions packages/query-broadcast-client-experimental/jest.config.ts
@@ -0,0 +1,4 @@
export default {
displayName: 'query-broadcast-client-experimental',
preset: '../../jest-preset.js',
}
5 changes: 3 additions & 2 deletions packages/query-broadcast-client-experimental/package.json
@@ -1,7 +1,7 @@
{
"name": "@tanstack/query-broadcast-client-experimental",
"version": "4.10.3",
"description": "TODO",
"description": "An experimental plugin to for broadcasting the state of your queryClient between browser tabs/windows",
"author": "tannerlinsley",
"license": "MIT",
"repository": "tanstack/query",
Expand Down Expand Up @@ -30,7 +30,8 @@
"scripts": {
"clean": "rm -rf ./build",
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
"compile": "../../node_modules/.bin/tsc -p tsconfig.json --noEmit --emitDeclarationOnly false"
"test:jest": "../../node_modules/.bin/jest --config ./jest.config.ts --passWithNoTests",
"test:dev": "pnpm run test:jest --watch"
},
"dependencies": {
"@tanstack/query-core": "workspace:*",
Expand Down
11 changes: 0 additions & 11 deletions packages/query-broadcast-client-experimental/tsconfig.lint.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/query-core/.eslintrc
@@ -1,6 +1,6 @@
{
"parserOptions": {
"project": "./tsconfig.lint.json",
"project": "./tsconfig.json",
"sourceType": "module"
}
}
4 changes: 4 additions & 0 deletions packages/query-core/jest.config.ts
@@ -0,0 +1,4 @@
export default {
displayName: 'query-core',
preset: '../../jest-preset.js',
}
6 changes: 4 additions & 2 deletions packages/query-core/package.json
@@ -1,7 +1,7 @@
{
"name": "@tanstack/query-core",
"version": "4.10.3",
"description": "TODO",
"description": "The framework agnostic core that powers TanStack Query",
"author": "tannerlinsley",
"license": "MIT",
"repository": "tanstack/query",
Expand Down Expand Up @@ -29,6 +29,8 @@
],
"scripts": {
"clean": "rm -rf ./build",
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src"
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
"test:jest": "../../node_modules/.bin/jest --config ./jest.config.ts",
"test:dev": "pnpm run test:jest --watch"
}
}
10 changes: 6 additions & 4 deletions packages/query-core/src/tests/utils.ts
Expand Up @@ -65,11 +65,13 @@ export const executeMutation = (
// so that we can pretend to be in a server environment
export function setIsServer(isServer: boolean) {
const original = utils.isServer
// @ts-ignore
utils.isServer = isServer
Object.defineProperty(utils, 'isServer', {
get: () => isServer,
})

return () => {
// @ts-ignore
utils.isServer = original
Object.defineProperty(utils, 'isServer', {
get: () => original,
})
}
}
10 changes: 0 additions & 10 deletions packages/query-core/tsconfig.lint.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/query-persist-client-core/.eslintrc
@@ -1,6 +1,6 @@
{
"parserOptions": {
"project": "./tsconfig.lint.json",
"project": "./tsconfig.json",
"sourceType": "module"
}
}
4 changes: 4 additions & 0 deletions packages/query-persist-client-core/jest.config.ts
@@ -0,0 +1,4 @@
export default {
displayName: 'query-persist-client-core',
preset: '../../jest-preset.js',
}

0 comments on commit 4ae9956

Please sign in to comment.