From a80cea38964a4b7003330cda3780d70cb0a9f6fc Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:18:25 +1000 Subject: [PATCH] ci: Optimise Nx workflow (#7648) * ci: Optimise Nx workflow * Merge test:build and test:attw --- .github/workflows/ci.yml | 15 +++------------ .github/workflows/pr.yml | 17 +++++------------ .nx/workflows/dynamic-changesets.yaml | 6 +++--- nx.json | 5 ----- package.json | 5 ++--- .../package.json | 3 +-- .../angular-query-experimental/package.json | 3 +-- packages/eslint-plugin-query/package.json | 3 +-- .../query-async-storage-persister/package.json | 3 +-- .../package.json | 3 +-- packages/query-core/package.json | 3 +-- packages/query-devtools/package.json | 3 +-- packages/query-persist-client-core/package.json | 3 +-- .../query-sync-storage-persister/package.json | 3 +-- packages/react-query-devtools/package.json | 3 +-- .../react-query-next-experimental/package.json | 3 +-- .../react-query-persist-client/package.json | 3 +-- packages/react-query/package.json | 3 +-- packages/solid-query-devtools/package.json | 3 +-- .../solid-query-persist-client/package.json | 3 +-- packages/solid-query/package.json | 3 +-- packages/svelte-query-devtools/package.json | 3 +-- .../svelte-query-persist-client/package.json | 3 +-- packages/svelte-query/package.json | 3 +-- packages/vue-query-devtools/package.json | 3 +-- packages/vue-query/package.json | 3 +-- 26 files changed, 34 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 004d255a75..1935a790a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,18 +25,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: '0' - - name: Setup pnpm - uses: pnpm/action-setup@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: pnpm + fetch-depth: 0 - name: Start Nx Agents run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" - - name: Install dependencies - run: pnpm install --frozen-lockfile --prefer-offline + - name: Setup Tools + uses: tanstack/config/.github/setup@main - name: Run Tests run: pnpm run test:ci --parallel=3 - name: Stop Nx Agents @@ -49,10 +42,8 @@ jobs: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" pnpm run cipublish env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GH_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} TAG: ${{ inputs.tag }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 44216b2048..2d54af7083 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -13,27 +13,20 @@ env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} jobs: - main: - name: Nx Cloud - Main Job + test: + name: Test runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup pnpm - uses: pnpm/action-setup@v4 - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: pnpm - name: Start Nx Agents run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" - - name: Install dependencies - run: pnpm install --frozen-lockfile --prefer-offline + - name: Setup Tools + uses: tanstack/config/.github/setup@main - name: Get base and head commits for `nx affected` - uses: nrwl/nx-set-shas@v3 + uses: nrwl/nx-set-shas@v4 with: main-branch-name: 'main' - name: Run Tests diff --git a/.nx/workflows/dynamic-changesets.yaml b/.nx/workflows/dynamic-changesets.yaml index 29c58231b2..d3536f3ba7 100644 --- a/.nx/workflows/dynamic-changesets.yaml +++ b/.nx/workflows/dynamic-changesets.yaml @@ -1,4 +1,4 @@ distribute-on: - small-changeset: 8 linux-medium-js - medium-changeset: 10 linux-medium-js - large-changeset: 12 linux-medium-js + small-changeset: 3 linux-medium-js + medium-changeset: 6 linux-medium-js + large-changeset: 10 linux-medium-js diff --git a/nx.json b/nx.json index 2e7b0163a0..6570b33474 100644 --- a/nx.json +++ b/nx.json @@ -46,11 +46,6 @@ "inputs": ["default", "^public"], "cache": true }, - "test:attw": { - "dependsOn": ["build"], - "inputs": ["default", "^public"], - "cache": true - }, "build": { "dependsOn": ["^build"], "inputs": ["default", "^public"], diff --git a/package.json b/package.json index b9712c09fb..0de7e54ea3 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,14 @@ "preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...')} else {process.exit(1)}\" || npx -y only-allow pnpm", "prepare": "husky", "test": "pnpm run test:ci", - "test:pr": "nx affected --targets=test:format,test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build,test:attw", - "test:ci": "nx run-many --targets=test:format,test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build,test:attw", + "test:pr": "nx affected --targets=test:format,test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build", + "test:ci": "nx run-many --targets=test:format,test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build", "test:eslint": "nx affected --target=test:eslint --exclude=examples/**", "test:format": "pnpm run prettier --check", "test:sherif": "sherif -p \"./integrations/*\" -p \"./examples/*\"", "test:lib": "nx affected --target=test:lib --exclude=examples/**", "test:lib:dev": "pnpm run test:lib && nx watch --all -- pnpm run test:lib", "test:build": "nx affected --target=test:build --exclude=examples/**", - "test:attw": "nx affected --target=test:attw --exclude=examples/**", "test:types": "nx affected --target=test:types --exclude=examples/**", "test:knip": "knip", "build": "nx affected --target=build --exclude=examples/**", diff --git a/packages/angular-query-devtools-experimental/package.json b/packages/angular-query-devtools-experimental/package.json index 4215fd14ea..4a08dab8da 100644 --- a/packages/angular-query-devtools-experimental/package.json +++ b/packages/angular-query-devtools-experimental/package.json @@ -26,8 +26,7 @@ "test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js", "test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js", "test:types:ts53": "tsc", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rimraf ./build/package.json" }, "dependencies": { diff --git a/packages/angular-query-experimental/package.json b/packages/angular-query-experimental/package.json index f5ebc7c98c..731c529e00 100644 --- a/packages/angular-query-experimental/package.json +++ b/packages/angular-query-experimental/package.json @@ -44,8 +44,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rimraf ./build/package.json && api-extractor run --local" }, "dependencies": { diff --git a/packages/eslint-plugin-query/package.json b/packages/eslint-plugin-query/package.json index c84bcf63de..f2b6e0d085 100644 --- a/packages/eslint-plugin-query/package.json +++ b/packages/eslint-plugin-query/package.json @@ -41,8 +41,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "vite build" }, "files": [ diff --git a/packages/query-async-storage-persister/package.json b/packages/query-async-storage-persister/package.json index f88dfbdb66..cc28716cbf 100644 --- a/packages/query-async-storage-persister/package.json +++ b/packages/query-async-storage-persister/package.json @@ -46,8 +46,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "dependencies": { diff --git a/packages/query-broadcast-client-experimental/package.json b/packages/query-broadcast-client-experimental/package.json index 101d788556..9bf7f85623 100644 --- a/packages/query-broadcast-client-experimental/package.json +++ b/packages/query-broadcast-client-experimental/package.json @@ -44,8 +44,7 @@ "test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js", "test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js", "test:types:ts53": "tsc", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "dependencies": { diff --git a/packages/query-core/package.json b/packages/query-core/package.json index 0b5f91b111..f6a1c11bf6 100644 --- a/packages/query-core/package.json +++ b/packages/query-core/package.json @@ -49,8 +49,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" } } diff --git a/packages/query-devtools/package.json b/packages/query-devtools/package.json index 0b123b12dc..16f83a0283 100644 --- a/packages/query-devtools/package.json +++ b/packages/query-devtools/package.json @@ -43,8 +43,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup", "build:dev": "tsup --watch" }, diff --git a/packages/query-persist-client-core/package.json b/packages/query-persist-client-core/package.json index accfd8b81a..7e305dd590 100644 --- a/packages/query-persist-client-core/package.json +++ b/packages/query-persist-client-core/package.json @@ -46,8 +46,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "dependencies": { diff --git a/packages/query-sync-storage-persister/package.json b/packages/query-sync-storage-persister/package.json index a6d1227f89..0c7bd226bb 100644 --- a/packages/query-sync-storage-persister/package.json +++ b/packages/query-sync-storage-persister/package.json @@ -46,8 +46,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "dependencies": { diff --git a/packages/react-query-devtools/package.json b/packages/react-query-devtools/package.json index d9f5255b44..6add0a07ba 100644 --- a/packages/react-query-devtools/package.json +++ b/packages/react-query-devtools/package.json @@ -66,8 +66,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup", "build:dev": "tsup --watch" }, diff --git a/packages/react-query-next-experimental/package.json b/packages/react-query-next-experimental/package.json index 1d0aef70ef..4478348b05 100644 --- a/packages/react-query-next-experimental/package.json +++ b/packages/react-query-next-experimental/package.json @@ -40,8 +40,7 @@ "test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js", "test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js", "test:types:ts53": "tsc", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "devDependencies": { diff --git a/packages/react-query-persist-client/package.json b/packages/react-query-persist-client/package.json index 72d6648ea1..c900985f02 100644 --- a/packages/react-query-persist-client/package.json +++ b/packages/react-query-persist-client/package.json @@ -46,8 +46,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest --retry=3", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "dependencies": { diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 57e3294a67..88adc13536 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -45,8 +45,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest --retry=3", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "pnpm build:tsup && pnpm build:codemods", "build:tsup": "tsup", "build:codemods": "cpy ../query-codemods/* ./build/codemods" diff --git a/packages/solid-query-devtools/package.json b/packages/solid-query-devtools/package.json index 066e791e97..e85eb8f5bf 100644 --- a/packages/solid-query-devtools/package.json +++ b/packages/solid-query-devtools/package.json @@ -41,8 +41,7 @@ "test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js", "test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js", "test:types:ts53": "tsc", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup", "build:dev": "tsup --watch" }, diff --git a/packages/solid-query-persist-client/package.json b/packages/solid-query-persist-client/package.json index aa44282e96..b518dcc825 100644 --- a/packages/solid-query-persist-client/package.json +++ b/packages/solid-query-persist-client/package.json @@ -53,8 +53,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "dependencies": { diff --git a/packages/solid-query/package.json b/packages/solid-query/package.json index ec389b1181..d2c48eaad8 100644 --- a/packages/solid-query/package.json +++ b/packages/solid-query/package.json @@ -50,8 +50,7 @@ "test:types:ts53": "tsc", "test:lib": "vitest --retry=3", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup", "build:watch": "tsup --watch" }, diff --git a/packages/svelte-query-devtools/package.json b/packages/svelte-query-devtools/package.json index 6b85a261ef..bdd93f192a 100644 --- a/packages/svelte-query-devtools/package.json +++ b/packages/svelte-query-devtools/package.json @@ -30,8 +30,7 @@ "clean": "rimraf ./dist && rimraf ./coverage", "test:types": "svelte-check --tsconfig ./tsconfig.json", "test:eslint": "eslint ./src", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "svelte-package --input ./src --output ./dist" }, "dependencies": { diff --git a/packages/svelte-query-persist-client/package.json b/packages/svelte-query-persist-client/package.json index 06cf2e37eb..7defbd280c 100644 --- a/packages/svelte-query-persist-client/package.json +++ b/packages/svelte-query-persist-client/package.json @@ -32,8 +32,7 @@ "test:eslint": "eslint ./src", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "svelte-package --input ./src --output ./dist" }, "dependencies": { diff --git a/packages/svelte-query/package.json b/packages/svelte-query/package.json index ec03ed203d..566379ee5f 100644 --- a/packages/svelte-query/package.json +++ b/packages/svelte-query/package.json @@ -36,8 +36,7 @@ "test:eslint": "eslint ./src", "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "svelte-package --input ./src --output ./dist" }, "dependencies": { diff --git a/packages/vue-query-devtools/package.json b/packages/vue-query-devtools/package.json index 762d318cdf..0016e4cc96 100644 --- a/packages/vue-query-devtools/package.json +++ b/packages/vue-query-devtools/package.json @@ -42,8 +42,7 @@ "clean": "rimraf ./build && rimraf ./coverage", "test:eslint": "eslint ./src", "test:types": "vue-tsc", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "vite build" }, "dependencies": { diff --git a/packages/vue-query/package.json b/packages/vue-query/package.json index 5b14689707..e8e45f7115 100644 --- a/packages/vue-query/package.json +++ b/packages/vue-query/package.json @@ -48,8 +48,7 @@ "test:lib:2.7": "vue-demi-switch 2.7 vue2.7 && vitest", "test:lib:3": "vue-demi-switch 3 && vitest", "test:lib:dev": "pnpm run test:lib --watch", - "test:build": "publint --strict", - "test:attw": "attw --pack", + "test:build": "publint --strict && attw --pack", "build": "tsup" }, "nx": {