Skip to content

Commit

Permalink
feat: rely on Nx Parallel env var (#2561)
Browse files Browse the repository at this point in the history
## Proposed change

feat: rely on Nx Parallel env var
docs: add developers explanation

<!--
Please include a summary of the changes and the related issue.
Please also include relevant motivation and context.
-->

## Related issues

<!--
Please make sure to follow the [contribution
guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md)
-->

*- No issue associated -*

<!-- * 🐛 Fix #issue -->
<!-- * 🐛 Fix resolves #issue -->
<!-- * 🚀 Feature #issue -->
<!-- * 🚀 Feature resolves #issue -->
<!-- * :octocat: Pull Request #issue -->
  • Loading branch information
kpanot authored Dec 6, 2024
2 parents 352c82a + 6287e14 commit 96eecc0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
16 changes: 15 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ To ease the process, we are providing a set of:
- [Linters configuration](./packages/@o3r/eslint-config/README.md)
- [Component generator](./packages/@o3r/core/README.md#generators) (and more)

### Accelerate your build thanks to Nx Cloud
### Accelerate your build

#### Thanks to Nx Cloud

[Nx Cloud](https://nx.dev/nx-cloud) offers a way to accelerate the build of your project locally thanks to [Remote Cache](https://nx.dev/ci/features/remote-cache).

Expand All @@ -81,6 +83,18 @@ When building (`yarn build`) the project on the `main` branch (or another `relea
> Only Otter Team members can write Remote Cache on Nx Cloud, logged-in users will be able to use Remote Cache in readonly mode.
> The Local Cache is available for all users (logged or not to Nx Cloud).
#### Increase the number of parallel process

By default, the number of tasks that can run in parallel is 3 (see [Nx Documentation](https://nx.dev/recipes/running-tasks/run-tasks-in-parallel)).
This number can be increased in the developer machine thanks to the [NX_PARALLEL](https://nx.dev/reference/environment-variables) environment variable by using the following command:

```bash
yarn print:nx-parallel >> .env
```

> [!NOTE]
> The command will set this number to the maximum possible value for your machine, it can be adapted manually after generation
### DevTools to create new Otter monorepo elements

To help developers create new items in the Otter monorepo, several scripts have been provided at root level to accelerate development:
Expand Down
35 changes: 18 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,32 @@
"ng": "yarn nx",
"amaterasu": "node packages/@ama-terasu/cli/dist/src/cli/ama.js",
"get:cpus-number": "node -e 'process.stdout.write(`${process.env.NX_PARALLEL || Math.max(require(\"os\").cpus().length - 1, 2)}`);'",
"print:nx-parallel": "node -e \"process.stdout.write(`NX_PARALLEL=$(yarn get:cpus-number)`)\"",
"get:current-dir": "node -e 'process.stdout.write(process.cwd());'",
"create:scope": "yarn create-monorepo-scope",
"build": "yarn nx run-many --target=build --parallel $(yarn get:cpus-number)",
"build:affected": "yarn nx affected --target=build --parallel $(yarn get:cpus-number) --output-style stream",
"build:tools": "yarn nx run-many --target=build --projects=eslint-plugin,workspace --parallel $(yarn get:cpus-number)",
"build:lint": "yarn nx run-many --target=build --projects=eslint-plugin --parallel $(yarn get:cpus-number)",
"build:swagger-gen": "yarn nx run-many --target=build-swagger --parallel $(yarn get:cpus-number)",
"build": "yarn nx run-many --target=build",
"build:affected": "yarn nx affected --target=build --output-style stream",
"build:tools": "yarn nx run-many --target=build --projects=eslint-plugin,workspace",
"build:lint": "yarn nx run-many --target=build --projects=eslint-plugin",
"build:swagger-gen": "yarn nx run-many --target=build-swagger",
"prepare:publish": "yarn prepare-publish \"$(yarn workspaces:list)\" --append dist",
"publish": "yarn run prepare:publish && yarn nx run-many --target=publish --exclude=tag:private --parallel $(yarn get:cpus-number) --nx-bail",
"publish:extensions": "yarn nx run-many --target=publish-extension --parallel $(yarn get:cpus-number)",
"publish:extensions:affected": "yarn nx affected --target=publish-extension --parallel $(yarn get:cpus-number)",
"package-github-actions:affected": "yarn nx affected --target=package-github-action --parallel $(yarn get:cpus-number)",
"lint": "yarn nx run-many --target=lint --parallel $(yarn get:cpus-number)",
"lint:affected": "yarn nx affected --target=lint --parallel $(yarn get:cpus-number)",
"test": "yarn nx run-many --target=test --parallel $(yarn get:cpus-number) --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test:affected": "yarn nx affected --target=test --parallel $(yarn get:cpus-number) --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test-e2e": "yarn nx run-many --target=test-e2e --parallel $(yarn get:cpus-number)",
"test-int": "yarn nx run-many --target=test-int --parallel $(yarn get:cpus-number)",
"publish": "yarn run prepare:publish && yarn nx run-many --target=publish --exclude=tag:private --nx-bail",
"publish:extensions": "yarn nx run-many --target=publish-extension",
"publish:extensions:affected": "yarn nx affected --target=publish-extension",
"package-github-actions:affected": "yarn nx affected --target=package-github-action",
"lint": "yarn nx run-many --target=lint",
"lint:affected": "yarn nx affected --target=lint",
"test": "yarn nx run-many --target=test --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test:affected": "yarn nx affected --target=test --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test-e2e": "yarn nx run-many --target=test-e2e",
"test-int": "yarn nx run-many --target=test-int",
"postinstall": "husky && yarn build:lint && yarn harmonize:version && yarn update-yarn-sdks",
"update-yarn-sdks": "node -e \"'pnp' !== '$(yarn config get nodeLinker)' || process.exit(1)\" || yarn dlx @yarnpkg/sdks",
"build:storybook": "yarn doc:generate:json && yarn ng run storybook:extract-style && build-storybook",
"clear": "rimraf -g './{packages,tools,apps}/{@*/,}{amaterasu/,}*/{dist,build,dist-*}/'",
"set:version": "yarn o3r-set-version --placeholder 0.0.0-placeholder --include '{apps,packages}/**/dist/{package,manifest}.json'",
"harmonize:version": "eslint '**/package.json*' '.yarnrc.yml' --quiet --fix",
"doc:packages": "yarn nx run-many --target=documentation --parallel $(yarn get:cpus-number)",
"doc:packages": "yarn nx run-many --target=documentation",
"doc:root": "yarn prepare-doc-root-menu-template && yarn update-doc-summary ./docs && yarn compodoc",
"doc:generate": "rimraf ./generated-doc && yarn doc:root && yarn doc:packages && yarn doc-links --docs ./docs --generated-doc ./generated-doc",
"doc:generate:json": "yarn update-doc-summary ./docs && yarn compodoc -e json -d .",
Expand All @@ -44,7 +45,7 @@
"verdaccio:clean": "rimraf -g \".verdaccio/storage/@{o3r,ama-sdk,ama-terasu}\"",
"verdaccio:login": "yarn cpy --cwd=./.verdaccio/conf .npmrc . --rename=.npmrc-logged && npx --yes npm-cli-login -u verdaccio -p verdaccio -e [email protected] -r http://127.0.0.1:4873 --config-path \".verdaccio/conf/.npmrc-logged\"",
"verdaccio:prepare-publish": "yarn verdaccio:clean && yarn set:version 999.0.$(node -e 'process.stdout.write(String(Date.now()))') --include \"!**/!(dist)/package.json\" --include !package.json && yarn verdaccio:login && replace-in-files --regex=\"private(.*)true\" --replacement=private\\$1false '**/dist/package.json' && yarn run prepare:publish",
"verdaccio:publish": "yarn run verdaccio:prepare-publish && yarn nx run-many --target=publish --parallel $(yarn get:cpus-number) --nx-bail --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873 --@o3r-training:registry=http://127.0.0.1:4873",
"verdaccio:publish": "yarn run verdaccio:prepare-publish && yarn nx run-many --target=publish --nx-bail --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873 --@o3r-training:registry=http://127.0.0.1:4873",
"verdaccio:stop": "docker container stop $(docker ps -a -q --filter=\"name=verdaccio\")",
"verdaccio:all": "yarn verdaccio:stop && yarn verdaccio:start && yarn verdaccio:publish",
"watch:vscode-extension": "yarn nx run vscode-extension:compile:watch",
Expand Down

0 comments on commit 96eecc0

Please sign in to comment.