Skip to content

Commit 40ad5aa

Browse files
authored
ci: fix feature branch variable (#15)
- The `is-main-branch` environment variable works in the CI workflow. - Dependencies are updated to at least the same verison as in a fresh Nx 12.3 workspace. - Unnecessary dependencies are removed. - The Nx task runner is optimized for parallelization.
1 parent e5ed3c2 commit 40ad5aa

File tree

4 files changed

+6047
-5207
lines changed

4 files changed

+6047
-5207
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ env:
88
NX_RUN_GROUP: ${{ github.run_id }}
99
PNPM_STORE_PATH: ~/.pnpm-store
1010
PNPM_VERSION: 5.x
11-
is-feature-branch: ${{ github.ref != 'refs/heads/$BASE_BRANCH' && (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch') }}
12-
is-main-branch: ${{ github.ref == 'refs/heads/$BASE_BRANCH' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
11+
is-feature-branch:
12+
${{ github.ref != 'refs/heads/$BASE_BRANCH' && (github.event_name ==
13+
'pull_request' || github.event_name == 'workflow_dispatch') }}
14+
is-main-branch:
15+
${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' ||
16+
github.event_name == 'workflow_dispatch') }}
1317

1418
on:
1519
push:
@@ -52,9 +56,9 @@ jobs:
5256
- run: pnpm store prune
5357

5458
- if: ${{ env.is-main-branch }}
55-
run: pnpm lint
59+
run: pnpm lint -- --max-parallel=2
5660
- if: ${{ env.is-feature-branch }}
57-
run: pnpm affected:lint -- --base=origin/$BASE_BRANCH
61+
run: pnpm affected:lint -- --base=origin/$BASE_BRANCH --max-parallel=2
5862

5963
test:
6064
runs-on: ubuntu-latest
@@ -89,9 +93,9 @@ jobs:
8993
- run: pnpm store prune
9094

9195
- if: ${{ env.is-main-branch }}
92-
run: pnpm test
96+
run: pnpm test -- --max-parallel=2
9397
- if: ${{ env.is-feature-branch }}
94-
run: pnpm affected:test -- --base=origin/$BASE_BRANCH
98+
run: pnpm affected:test -- --base=origin/$BASE_BRANCH --max-parallel=2
9599

96100
build:
97101
runs-on: ubuntu-latest

nx.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"options": {
2121
"accessToken": "ZDQ2ZDk2Y2MtODU2Ny00YzhhLWI5NzMtYzNkN2YzN2ZiYjJlfHJlYWQtd3JpdGU=",
2222
"cacheableOperations": ["build", "test", "lint", "e2e"],
23-
"canTrackAnalytics": false,
23+
"canTrackAnalytics": true,
24+
"maxParallel": 6,
25+
"parallel": true,
2426
"showUsageWarnings": true
2527
}
2628
}

package.json

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
"version": "0.0.0",
66
"license": "MIT",
77
"scripts": {
8-
"preinstall": "(pnpm remove codelyzer --silent || echo ✅ Codelyzer is already removed.) && (pnpm remove tslint --silent || echo ✅ TSLint is already removed.)",
98
"postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main",
109
"nx": "nx",
1110
"start": "nx serve examples-angular-nrwl-airlines-booking-desktop-app",
12-
"build": "nx run-many --target=build --configuration=production --all",
13-
"test": "nx run-many --target=test --all --parallel",
14-
"lint": "nx workspace-lint && nx run-many --target=lint --all --parallel",
15-
"e2e": "nx run-many --target=e2e --all --parallel",
11+
"build": "nx run-many --target=build --configuration=production --all --parallel=false",
12+
"test": "nx run-many --target=test --all",
13+
"lint": "nx workspace-lint && nx run-many --target=lint --all",
14+
"e2e": "nx run-many --target=e2e --all --parallel=false",
1615
"affected:apps": "nx affected:apps",
1716
"affected:libs": "nx affected:libs",
18-
"affected:build": "nx affected:build",
19-
"affected:e2e": "nx affected:e2e --parallel",
20-
"affected:test": "nx affected:test --parallel",
21-
"affected:lint": "nx affected:lint --parallel",
17+
"affected:build": "nx affected:build --parallel=false",
18+
"affected:e2e": "nx affected:e2e",
19+
"affected:test": "nx affected:test",
20+
"affected:lint": "nx affected:lint",
2221
"affected:dep-graph": "nx affected:dep-graph",
2322
"affected": "nx affected",
2423
"contributors:add": "all-contributors add",
@@ -50,7 +49,7 @@
5049
"@ngrx/store": "~12.0.0",
5150
"@nrwl/angular": "~12.3.5",
5251
"luxon": "^1.25.0",
53-
"rxjs": "~6.5.5",
52+
"rxjs": "~6.6.0",
5453
"tslib": "^2.1.0",
5554
"zone.js": "~0.11.4"
5655
},
@@ -79,24 +78,22 @@
7978
"@nrwl/workspace": "~12.3.5",
8079
"@types/jest": "~26.0.8",
8180
"@types/luxon": "^1.25.0",
82-
"@types/node": "14.14.33",
83-
"@typescript-eslint/eslint-plugin": "~4.3.0",
84-
"@typescript-eslint/parser": "~4.3.0",
81+
"@types/node": "^14.14.33",
82+
"@typescript-eslint/eslint-plugin": "~4.19.0",
83+
"@typescript-eslint/parser": "~4.19.0",
8584
"all-contributors-cli": "^6.19.0",
86-
"cypress": "^5.6.0",
85+
"cypress": "^7.4.0",
8786
"dotenv": "~8.2.0",
8887
"eslint": "~7.10.0",
8988
"eslint-config-prettier": "~8.1.0",
9089
"eslint-plugin-cypress": "^2.11.2",
91-
"eslint-plugin-import": "^2.22.1",
92-
"eslint-plugin-jsdoc": "^30.7.13",
93-
"eslint-plugin-prefer-arrow": "^1.2.2",
9490
"git-cz": "^4.7.6",
9591
"husky": "^4.3.7",
9692
"jest": "~26.2.2",
9793
"jest-preset-angular": "~8.4.0",
9894
"json": "^10.0.0",
9995
"lint-staged": "^10.5.3",
96+
"ng-packagr": "~12.0.2",
10097
"prettier": "~2.2.1",
10198
"ts-jest": "~26.5.5",
10299
"ts-node": "~9.1.1",

0 commit comments

Comments
 (0)