Skip to content

Commit

Permalink
⚡ Feat: Add nx distributed cloud execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Cory authored and Will Cory committed Nov 19, 2023
1 parent 17b6ccf commit f56ded9
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 213 deletions.
6 changes: 0 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ runs:
with:
version: nightly

# Workaround for parallel building with forge:
# https://github.com/foundry-rs/foundry/issues/4736
- name: Setup forge hack
shell: bash
run: forge build

- name: Get pnpm store directory
shell: bash
run: |
Expand Down
21 changes: 1 addition & 20 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
# .github/workflows

Workflows that are run in CI
Workflows that are run in CI. They are ran with nx cloud which spins up different workers that accept jobs. This creates really fast worst case and best case CI times.

### docker.yml

Builds all docker containers and deploys to dockerhub on release

## e2e.yml

Runs playwright tests vs the example apps

### lint.yml

Runs prettier and eslint

### npm.yml

Runs npm publish in dry mode. On workflow releases it will actually publish

### unit.yml

Runs run unit tests for all packages
44 changes: 0 additions & 44 deletions .github/workflows/build.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/docs.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/fixtures.yml

This file was deleted.

61 changes: 0 additions & 61 deletions .github/workflows/lint.yml

This file was deleted.

74 changes: 63 additions & 11 deletions .github/workflows/test.yml → .github/workflows/nx.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,83 @@
name: CI
on:
push:
branches:
- main
pull_request:
merge_group:
workflow_dispatch:

name: Test
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
# give extra memory to speed up a bit
NODE_OPTIONS: '--max_old_space_size=4096'
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

jobs:
test:
name: Test
agents:
name: Nx Cloud Agents
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
agent: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org
- name: "Setup"
uses: ./.github/actions/setup
- name: Start Nx Agent ${{ matrix.agent }}
run: bunx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{ matrix.agent }}
main:
name: Nx Cloud - Main Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout [Pull Request]
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- uses: actions/checkout@v4
name: Checkout [Default Branch]
if: ${{ github.event_name != 'pull_request' }}
with:
fetch-depth: 0
submodules: recursive

- name: "Setup"
uses: ./.github/actions/setup

- name: Run tests
# using node because bun nx run-many is not doing coverage correctly in ci for some reason
run: pnpm i && npx nx run-many --target=test:coverage
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
RPC_URL_MAINNET: ${{ secrets.RPC_URL_MAINNET }}
- name: Initialize the Nx Cloud distributed CI run and stop agents when the build tasks are done
run: bunx nx-cloud start-ci-run --stop-agents-after=build:dist

- name: Run verification
uses: JamesHenry/parallel-bash-commands@v0.1
with:
cmd1: bunx nx affected --target build:dist
cmd2: bunx nx affected --target build:types
cmd3: bunx nx affected --target typecheck
cmd4: bunx nx affected --target test:coverage
cmd5: bunx nx affected --target lint:check
cmd6: bunx nx affected --target dev:run
cmd7: bun sort-package-json
cmd8: bunx nx affected --target generate:docs

- name: Stop agents
run: bunx nx-cloud stop-all-agents

- name: Tag main branch if all jobs succeed
if: ${{ github.event_name != 'pull_request' }}
uses: nrwl/nx-tag-successful-ci-run@v1

- name: Run test:coverage from cache to get all coverage reports
run: bunx nx run-many --target=test:coverage

- name: 'Report @evmts/core Coverage'
if: always() # Also generate the report if tests are failing
Expand Down
14 changes: 0 additions & 14 deletions bundler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@
"types",
"src"
],
"scripts": {
"all": "bun run build && bun run format && bun run lint && bun run generate:docs",
"build": "nx run-many --targets=build:dist,build:types --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"build:dist": "nx run-many --targets=build:dist --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"build:types": "nx run-many --targets=build:types --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"clean": "rm -rf node_modules && nx run-many --targets=clean --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"format": "nx run-many --targets=format --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"format:check": "nx run-many --targets=format:check --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"test:run": "nx run-many --targets=test:run --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"test:coverage": "nx run-many --targets=test:coverage --projects=@evmts/base,@evmts/bun,@evmts/config,@evmts/esbuild,@evmts/rollup,@evmts/rspack,@evmts/ts-plugin,@evmts/vite,@evmts/webpack",
"generate:docs": "bun run typedoc",
"lint": "rome check ./src --apply-unsafe",
"lint:check": "rome check ./src --verbose"
},
"dependencies": {
"@evmts/bun-plugin": "workspace:^",
"@evmts/config": "workspace:^",
Expand Down
8 changes: 8 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"defaultProject": "@evmts/example-vite",
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"accessToken": "MDdkNmQwZWEtOGYwNy00ZjhkLWI5NGMtNjBiNGExY2Q5MzI2fHJlYWQ="
}
}
},
"targetDefaults": {
"lint:check": {
"inputs": ["default"],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"contributors": [
"Will Cory <willcory10@gmail.com>"
],
"type": "module",
"type": "commonjs",
"workspaces": [
"bundler/*",
"bundler",
Expand Down

0 comments on commit f56ded9

Please sign in to comment.