Skip to content

Commit

Permalink
ci: More Nx Cloud features (#6906)
Browse files Browse the repository at this point in the history
* adding root level checks to agent execution

* making root level scripts cacheable

* correctly setting inputs

* adding agents to ci.yml

* adding dynamic changesets to fix variable size PRs

* fixing resource name in dynamic-changesets.yaml

* reruning tests

* Delete tsbuildinfo file

* Update PR and CI scripts

* Add stop-agents-on-failure=false

* parallel=3

* Ignore .pnpm-store

---------

Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
  • Loading branch information
ZackDeRose and lachlancollins committed Feb 17, 2024
1 parent 65a5540 commit 496cd8c
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 70 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ jobs:
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: Run Tests
run: pnpm run test:ci
run: pnpm run test:ci --parallel=3
- name: Stop Nx Agents
if: ${{ always() }}
run: npx nx-cloud stop-all-agents
- name: Publish
run: |
git config --global user.name 'Tanner Linsley'
Expand Down
68 changes: 3 additions & 65 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ concurrency:

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 3

jobs:
main:
Expand All @@ -34,8 +32,8 @@ jobs:
with:
node-version-file: .nvmrc
cache: pnpm
- name: Start Agents
run: npx nx-cloud start-ci-run --distribute-on="12 linux-medium-js"
- 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: Get base and head commits for `nx affected`
Expand All @@ -44,70 +42,10 @@ jobs:
main-branch-name: 'main'
- name: Run Tests
run: pnpm run test:pr --parallel=3
- name: Stop Agents
- name: Stop Nx Agents
if: ${{ always() }}
run: npx nx-cloud stop-all-agents
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
directory: packages
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Run prettier
run: pnpm run test:format
sherif:
name: Sherif
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Run prettier
run: pnpm run test:sherif
knip:
name: Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Run Knip
run: pnpm knip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ stats.html
*.tsbuildinfo
.DS_Store
.cache
.pnpm-store
.idea

.nx/cache
4 changes: 4 additions & 0 deletions .nx/workflows/dynamic-changesets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
distribute-on:
small-changeset: 8 linux-medium-js
medium-changeset: 10 linux-medium-js
large-changeset: 12 linux-medium-js

This file was deleted.

12 changes: 12 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
"inputs": ["default", "^public"],
"outputs": ["{projectRoot}/build", "{projectRoot}/dist"],
"cache": true
},
"test:knip": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
},
"test:format": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
},
"test:sherif": {
"cache": true,
"inputs": ["{workspaceRoot}/**/*"]
}
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm",
"install:csb": "corepack enable && pnpm install --frozen-lockfile",
"test": "pnpm run test:ci",
"test:pr": "nx affected --targets=test:eslint,test:lib,test:types,test:build,build",
"test:ci": "nx run-many --targets=test:format,test:sherif,test:eslint,test:lib,test:types,test:build,build",
"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 -i react-scripts",
"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:types": "nx affected --target=test:types --exclude=examples/**",
"test:knip": "knip",
"build": "nx affected --target=build --exclude=examples/**",
"build:all": "nx run-many --target=build --exclude=examples/**",
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
Expand All @@ -32,7 +33,8 @@
"nx": {
"includedScripts": [
"test:format",
"test:sherif"
"test:sherif",
"test:knip"
]
},
"namespace": "@tanstack",
Expand Down

0 comments on commit 496cd8c

Please sign in to comment.