Skip to content

Commit 2425d1f

Browse files
chore: support separate TypeScript and Rust builds (#1294)
* Install nx * Nx repair * Single build command * Add token support * Remove build from evm * rename command * Support rs build * Common build command * Restore lerna * Update paths * Add ignore tokens script * Rename token files * style: resolve style guide violations [ci-lint-fix] * Use default cache * Cache .nx in workflow * empty commit --------- Co-authored-by: oXtxNt9U <120286271+oXtxNt9U@users.noreply.github.com>
1 parent d522424 commit 2425d1f

8 files changed

Lines changed: 309 additions & 241 deletions

File tree

.github/workflows/_dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: actions/cache@v5.0.3
3636
with:
3737
key: ${{ runner.os }}-lerna
38-
path: ./.cache
38+
path: ./.nx
3939
restore-keys: ${{ runner.os }}-lerna-
4040
- name: Install dependencies
4141
run: pnpm install

.github/workflows/_test.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
uses: actions/cache/save@v4
6363
with:
6464
key: lerna-${{ github.sha }}
65-
path: ./.cache
65+
path: ./.nx
6666

6767
unit:
6868
name: "Unit"
@@ -101,7 +101,7 @@ jobs:
101101
uses: actions/cache/restore@v5.0.3
102102
with:
103103
key: lerna-${{ github.sha }}
104-
path: ./.cache
104+
path: ./.nx
105105
- uses: dtolnay/rust-toolchain@stable
106106
with:
107107
components: llvm-tools-preview
@@ -297,7 +297,7 @@ jobs:
297297
uses: actions/cache/restore@v5.0.3
298298
with:
299299
key: lerna-${{ github.sha }}
300-
path: ./.cache
300+
path: ./.nx
301301
- name: Install dependencies
302302
run: pnpm install
303303
- name: Build
@@ -348,7 +348,7 @@ jobs:
348348
uses: actions/cache/restore@v5.0.3
349349
with:
350350
key: lerna-${{ github.sha }}
351-
path: ./.cache
351+
path: ./.nx
352352
- name: Install dependencies
353353
run: pnpm install
354354
- name: Build
@@ -433,7 +433,7 @@ jobs:
433433
uses: actions/cache/restore@v5.0.3
434434
with:
435435
key: lerna-${{ github.sha }}
436-
path: ./.cache
436+
path: ./.nx
437437
- name: Install dependencies
438438
run: pnpm install
439439
- name: Build
@@ -491,7 +491,7 @@ jobs:
491491
uses: actions/cache/restore@v5.0.3
492492
with:
493493
key: lerna-${{ github.sha }}
494-
path: ./.cache
494+
path: ./.nx
495495
- name: Install dependencies
496496
run: pnpm install
497497
- name: Build
@@ -570,7 +570,7 @@ jobs:
570570
uses: actions/cache/restore@v5.0.3
571571
with:
572572
key: lerna-${{ github.sha }}
573-
path: ./.cache
573+
path: ./.nx
574574
- name: Install dependencies
575575
run: pnpm install
576576
- name: Build
@@ -655,7 +655,7 @@ jobs:
655655
uses: actions/cache/restore@v5.0.3
656656
with:
657657
key: lerna-${{ github.sha }}
658-
path: ./.cache
658+
path: ./.nx
659659
- name: Install dependencies
660660
run: pnpm install
661661
- name: Build

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ CODE_OF_CONDUCT.md
88
packages/p2p/source/socket-server/codecs/proto/protos.*
99

1010
/.nx/cache
11-
/.nx/workspace-data
11+
/.nx/workspace-data
12+
.nx/self-healing

nx.json

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
{
22
"namedInputs": {
3-
"default": [
4-
"{projectRoot}/source/**/!(*.test).ts",
5-
"{projectRoot}/source/**/*.json",
6-
"{projectRoot}/core/**/*.rs",
7-
"{projectRoot}/bindings/**/*.rs",
8-
"{projectRoot}/**/Cargo.toml"
9-
],
3+
"typescript": ["{projectRoot}/source/**/!(*.test).ts", "{projectRoot}/source/**/*.json"],
4+
"evm": ["{projectRoot}/core/**/*.rs", "{projectRoot}/bindings/**/*.rs", "{projectRoot}/**/Cargo.toml"],
5+
"tsToken": ["{workspaceRoot}/.build-ts"],
6+
"rsToken": ["{workspaceRoot}/.build-rs"],
107
"production": ["default"]
118
},
129
"targetDefaults": {
1310
"build": {
1411
"dependsOn": ["^build"],
15-
"inputs": ["default"],
16-
"outputs": [
17-
"{projectRoot}/distribution",
18-
"{projectRoot}/tsconfig.tsbuildinfo",
19-
"{projectRoot}/index.d.ts",
20-
"{projectRoot}/index.js",
21-
"{projectRoot}/evm.*.node"
22-
],
12+
"inputs": ["tsToken", "typescript"],
13+
"outputs": ["{projectRoot}/distribution", "{projectRoot}/tsconfig.tsbuildinfo"],
14+
"cache": true
15+
},
16+
"build-rs": {
17+
"dependsOn": [""],
18+
"inputs": ["rsToken", "evm"],
19+
"outputs": ["{projectRoot}/index.d.ts", "{projectRoot}/index.js", "{projectRoot}/evm.*.node"],
2320
"cache": true
2421
}
2522
},
2623
"$schema": "./node_modules/nx/schemas/nx-schema.json",
27-
"cacheDirectory": "./.cache",
2824
"analytics": false
2925
}

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
"plugins/*"
99
],
1010
"scripts": {
11-
"build": "lerna run build",
12-
"build:rs": "lerna run build --scope=@mainsail/evm",
13-
"build:ts": "pnpm run build:rs && lerna run build --ignore=@mainsail/evm",
14-
"clean": "pnpm run clean:packages && rm -r .cache && rm -r .nx",
11+
"build": "pnpm run build:rs && pnpm run build:ts",
12+
"build:rs": "lerna run build-rs --scope=@mainsail/evm",
13+
"build:rs:token": "echo \"force-rs $(date +%s)\" > .build-rs",
14+
"build:ts": "lerna run build",
15+
"build:ts:token": "echo \"force-ts $(date +%s)\" > .build-ts",
16+
"clean": "pnpm run clean:packages && rm -r .nx",
1517
"clean:all": "pnpm run clean && pnpm run clean:node_modules",
1618
"clean:node_modules": "rm -rf packages/*/node_modules && rm -rf node_modules",
1719
"clean:packages": "rm -rf packages/*/distribution && rm -f packages/*/tsconfig.tsbuildinfo && lerna run clean --parallel",
@@ -20,6 +22,7 @@
2022
"deps:check": "node ./scripts/deps/check.js",
2123
"deps:types": "./node_modules/typesync/bin/typesync",
2224
"format": "pnpm run lint && pnpm run prettier",
25+
"ignore:tokens": "bash scripts/git-ignore-tokens.sh",
2326
"lint": "eslint packages/*/source --fix",
2427
"lint:dry": "eslint packages/*/source",
2528
"lint:error": "eslint packages/*/source --quiet",

packages/evm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"types": "index.d.ts",
99
"scripts": {
1010
"artifacts": "napi artifacts",
11-
"build": "pnpm run clean && pnpm run build-napi",
1211
"build-napi": "napi build --platform --output-dir ./ --manifest-path bindings/Cargo.toml --release",
1312
"build-napi:debug": "napi build --platform --output-dir ./ --manifest-path bindings/Cargo.toml",
13+
"build-rs": "pnpm run clean && pnpm run build-napi",
1414
"clean": "rm -f index.js && rm -f index.d.ts && rm -f evm.*.node && rm -rf target",
1515
"prepublishOnly": "napi prepublish -t pnpm",
1616
"release": "pnpm publish --access public",

0 commit comments

Comments
 (0)