Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce project.json duplication and split prepublish #2658

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
Expand Down Expand Up @@ -72,7 +73,8 @@ jobs:
run: yarn nx run ama-sdk-schematics:build-swagger
- name: Test
env:
testCmd: ${{ inputs.affected && format('test:affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'test'}}
NX_BASE: ${{ format('remotes/origin/{0}', github.base_ref || github.ref_name) }}
testCmd: ${{ inputs.affected && 'test:affected' || 'test'}}
NODE_OPTIONS: ${{ runner.os == 'Windows' && '--max_old_space_size=4096' || '' }}
run: yarn ${{ env.testCmd }} --collectCoverage
- name: Upload results to Codecov
Expand Down Expand Up @@ -114,8 +116,9 @@ jobs:
${{ runner.os }}
- name: Lint
env:
lintCmd: ${{ inputs.affected && format('lint:affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'lint'}}
run: yarn ${{ env.lintCmd }} --configuration ci
NX_BASE: ${{ format('remotes/origin/{0}', github.base_ref || github.ref_name) }}
lintCmd: ${{ inputs.affected && 'lint:affected' || 'lint'}}
run: yarn ${{ env.lintCmd }}

# Check that the packaging of github-actions is still working
github-actions:
Expand All @@ -128,6 +131,7 @@ jobs:
uses: ./tools/github-actions/setup
- name: Package github actions
env:
nxCmd: ${{ inputs.affected && format('nx affected --base=remotes/origin/{0}', github.base_ref || github.ref_name) || 'nx run-many'}}
NX_BASE: ${{ format('remotes/origin/{0}', github.base_ref || github.ref_name) }}
nxCmd: ${{ inputs.affected && 'nx affected' || 'nx run-many'}}
run: yarn ${{ env.nxCmd }} --target=package-github-action

1 change: 1 addition & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/it-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:

env:
NX_PARALLEL: ${{ vars.NX_PARALLEL }}
NX_TASK_TARGET_CONFIGURATION: ci
YARN_ENABLE_HARDENED_MODE: 0
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ jobs:
- run: yarn set:version ${{ inputs.version }}
- name: Publish Extensions
if: '!inputs.prerelease'
run: yarn run ${{ endsWith(inputs.version, '.0') && 'publish:extensions' || 'publish:extensions:affected --base=HEAD~1' }}
run: yarn run ${{ endsWith(inputs.version, '.0') && 'publish:extensions' || 'publish:extensions:affected' }}
env:
NX_BASE: HEAD~1
VSCE_PAT: ${{ secrets.AZURE_VSC_EXT_TOKEN }}
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_EXT_ID: ${{ secrets.CHROME_EXT_ID }}
Expand Down
7 changes: 1 addition & 6 deletions apps/chrome-devtools/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@
}
}
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/chrome-devtools/jest.config.js"
}
},
"test": {},
"copy-assets": {
"executor": "nx:run-script",
"options": {
Expand Down
11 changes: 2 additions & 9 deletions apps/github-cascading-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@
"script": "build"
}
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/github-cascading-app/jest.config.js"
}
}
"lint": {},
"test": {}
},
"tags": []
}
1 change: 0 additions & 1 deletion apps/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"start": "ng run showcase:run",
"build": "yarn run generate:translations && ng build",
"watch": "ng compile --watch --configuration development",
"test": "ng test",
"start:no-translation": "ng serve",
"generate:translations:dev": "ng run showcase:generate-translations",
"generate:translations": "ng run showcase:generate-translations:production",
Expand Down
7 changes: 1 addition & 6 deletions apps/showcase/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,7 @@
},
"dependsOn": ["^build", "^build-builders"]
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/showcase/jest.config.js"
}
},
"test": {},
"generate-theme": {
"executor": "@o3r/design:generate-css",
"outputs": [
Expand Down
18 changes: 3 additions & 15 deletions apps/vscode-extension/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,9 @@
},
"outputs": ["{projectRoot}/dist/src/extension.js"]
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "apps/vscode-extension/jest.config.js"
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
}
},
"lint": {},
"test": {},
"prepare-publish": {},
"publish-extension": {
"executor": "nx:run-commands",
"options": {
Expand Down
52 changes: 51 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
"cache": true
},
"test": {
"executor": "@nx/jest:jest",
"inputs": [
{
"env": "RUNNER_OS"
Expand All @@ -186,6 +187,8 @@
"{projectRoot}/coverage/cobertura-coverage.xml"
],
"options": {
"jestConfig": "{projectRoot}/jest.config.js",
"cacheDirectory": "{workspaceRoot}/.cache/jest",
"passWithNoTests": false,
"silent": true
},
Expand All @@ -198,6 +201,7 @@
"cache": true
},
"test-int": {
"executor": "@nx/jest:jest",
"inputs": [
{
"env": "RUNNER_OS"
Expand All @@ -218,6 +222,7 @@
"{projectRoot}/coverage/cobertura-coverage.xml"
],
"options": {
"jestConfig": "{projectRoot}/testing/jest.config.it.js",
"quiet": false,
"passWithNoTests": false
},
Expand All @@ -229,10 +234,39 @@
},
"cache": true
},
"publish": {
fpaul-1A marked this conversation as resolved.
Show resolved Hide resolved
"cache": false,
"executor": "nx:run-commands",
"options": {
"command": "npm publish {projectRoot}/dist"
},
"outputs": [],
"inputs": [
"{projectRoot}/dist"
],
"dependsOn": [
"prepare-publish"
]
},
"prepare-publish": {
"cache": false,
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
},
"inputs": [
"{workspaceRoot}/readme.md",
"{workspaceRoot}/package.json",
"{workspaceRoot}/LICENSE",
"{workspaceRoot}/.npmignore",
"{projectRoot}/readme.md",
"{projectRoot}/.npmignore",
"{projectRoot}/package.json"
],
"outputs": [
"{projectRoot}/dist/package.json"
"{projectRoot}/dist/package.json",
"{projectRoot}/dist/readme.json",
"{projectRoot}/dist/LICENSE"
]
},
"publish-extension": {
Expand Down Expand Up @@ -332,6 +366,10 @@
"cache": true
},
"prepare-build-builders": {
"executor": "nx:run-script",
"options": {
"script": "prepare:build:builders"
},
"dependsOn": [
"compile"
],
Expand All @@ -352,6 +390,10 @@
"cache": true
},
"build-cli": {
"executor": "nx:run-script",
"options": {
"script": "build:cli"
},
"dependsOn": [
"compile"
],
Expand All @@ -371,6 +413,10 @@
"cache": true
},
"build-builders": {
"executor": "nx:run-script",
"options": {
"script": "build:builders"
},
"dependsOn": [
"^build",
"prepare-build-builders",
Expand Down Expand Up @@ -417,6 +463,10 @@
"cache": true
},
"documentation": {
"executor": "nx:run-script",
"options": {
"script": "compodoc"
},
"outputs": [
"{workspaceRoot}/generated-doc/{projectName}/**/*"
],
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
"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",
Copy link
Contributor

@fpaul-1A fpaul-1A Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of this task was to fix #112, is this no longer applicable?

Copy link
Contributor Author

@kpanot kpanot Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still valid on Nx 19 (4s per prepare-publish task) but it is greatly reduced in Nx 20 (< 200ms).

"publish": "yarn run prepare:publish && yarn nx run-many --target=publish --exclude=tag:private --nx-bail",
"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": "yarn nx run-many --target=test",
"test:affected": "yarn nx affected --target=test",
"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",
Expand All @@ -44,7 +43,7 @@
"verdaccio:start-persistent": "docker run -d -it --rm --name verdaccio -p 4873:4873 -v \"$(yarn get:current-dir)/.verdaccio/conf\":/verdaccio/conf -v \"$(yarn get:current-dir)/.verdaccio/storage\":/verdaccio/storage:z verdaccio/verdaccio",
"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: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'",
"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",
Expand Down Expand Up @@ -186,7 +185,6 @@
"@nx/jest": "~19.8.0",
"@nx/js": "~19.8.0",
"@nx/workspace": "~19.8.0",
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-config": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/telemetry": "workspace:^",
Expand Down
39 changes: 6 additions & 33 deletions packages/@ama-sdk/client-angular/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,12 @@
},
"outputs": ["{projectRoot}/dist/src"]
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "packages/@ama-sdk/client-angular/jest.config.js"
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "npm publish packages/@ama-sdk/client-angular/dist"
}
},
"prepare-build-builders": {
"executor": "nx:run-script",
"options": {
"script": "prepare:build:builders"
}
},
"build-builders": {
"executor": "nx:run-script",
"options": {
"script": "build:builders"
}
}
"lint": {},
"test": {},
"prepare-publish": {},
"publish": {},
"prepare-build-builders": {},
"build-builders": {}
},
"tags": []
}
39 changes: 6 additions & 33 deletions packages/@ama-sdk/client-beacon/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,12 @@
},
"outputs": ["{projectRoot}/dist/src"]
},
"lint": {
"executor": "nx:run-commands"
},
"test": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "packages/@ama-sdk/client-beacon/jest.config.js"
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
"script": "prepare:publish"
}
},
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "npm publish packages/@ama-sdk/client-beacon/dist"
}
},
"prepare-build-builders": {
"executor": "nx:run-script",
"options": {
"script": "prepare:build:builders"
}
},
"build-builders": {
"executor": "nx:run-script",
"options": {
"script": "build:builders"
}
}
"lint": {},
"test": {},
"prepare-publish": {},
"publish": {},
"prepare-build-builders": {},
"build-builders": {}
},
"tags": []
}
Loading
Loading