From e35aea549402000c1bbf55485c404cb372d8ddc1 Mon Sep 17 00:00:00 2001 From: Kilian Panot Date: Wed, 6 Nov 2024 16:43:01 +0900 Subject: [PATCH] chore: setup Nx Cloud Id for PAT support --- .github/workflows/code-check.yml | 5 +--- .github/workflows/main.yml | 10 ++----- .github/workflows/publish.yml | 3 +- CONTRIBUTING.md | 2 +- nx.json | 11 +++++++- package.json | 1 + yarn.lock | 47 ++++++++++++++++++++++++++++---- 7 files changed, 59 insertions(+), 20 deletions(-) diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml index e8e46e923e..6d2a539533 100644 --- a/.github/workflows/code-check.yml +++ b/.github/workflows/code-check.yml @@ -21,6 +21,7 @@ on: env: NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }} YARN_ENABLE_HARDENED_MODE: 0 + NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} permissions: contents: read @@ -43,8 +44,6 @@ jobs: matrix: os: ${{ fromJson(github.event_name != 'push' && '["ubuntu-latest", "windows-latest"]' || '["ubuntu-latest"]') }} runs-on: ${{ matrix.os }} - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -83,8 +82,6 @@ jobs: tools/**/dist-test/ut-report.xml lint: runs-on: ubuntu-latest - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6917c298e3..48f0891030 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,11 +21,14 @@ on: env: YARN_ENABLE_HARDENED_MODE: 0 + NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} jobs: # Check the integrity of yarn lock yarn_lock_check: runs-on: ubuntu-latest + env: + NX_SKIP_NX_CACHE: true steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: ./tools/github-actions/setup @@ -36,7 +39,6 @@ jobs: runs-on: ubuntu-latest needs: [yarn_lock_check] env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} NX_SKIP_NX_CACHE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -81,8 +83,6 @@ jobs: checks: uses: ./.github/workflows/code-check.yml - secrets: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} needs: [yarn_lock_check] with: affected: ${{ github.event_name == 'pull_request' }} @@ -90,16 +90,12 @@ jobs: it-tests: uses: ./.github/workflows/it-tests.yml - secrets: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} needs: [yarn_lock_check, build] with: skipNxCache: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }} e2e-tests: uses: ./.github/workflows/e2e-tests.yml - secrets: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} needs: [yarn_lock_check, build] with: skipNxCache: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6b9773ab40..823e333cc0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -48,6 +48,7 @@ on: env: NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }} + NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} permissions: contents: read @@ -55,8 +56,6 @@ permissions: jobs: publish: runs-on: ubuntu-latest - env: - NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} environment: ${{inputs.isPullRequest && 'development' || 'production'}} permissions: contents: read diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 44e7ff536c..89188ff50a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,7 @@ To be able to benefit from this feature, you will need to perform the following 1. Create an account on [Nx Cloud App](https://cloud.nx.app/) 2. Create a Personal Access Token on [profile page](https://cloud.nx.app/profile/tokens). -3. Create a local environment variable **NX_CLOUD_ACCESS_TOKEN** with your previously generated PAT *(example on Linux: `export NX_CLOUD_ACCESS_TOKEN=xxxxxxx`)* +3. Follow [Nx Cloud instruction](https://nx.dev/ci/recipes/security/personal-access-tokens) to setup your previously generated PAT. When building (`yarn build`) the project on the `main` branch (or another `release/*` branch), the remote cache will be downloaded. diff --git a/nx.json b/nx.json index 4085282f36..31f0e0a096 100644 --- a/nx.json +++ b/nx.json @@ -515,5 +515,14 @@ "appsDir": "apps" }, "useDaemonProcess": false, - "cacheDirectory": ".cache/nx" + "cacheDirectory": ".cache/nx", + "nxCloudId": "63e6951e043da20dd8321aec", + "tasksRunnerOptions": { + "default": { + "runner": "nx-cloud", + "options": { + "nxCloudId": "63e6951e043da20dd8321aec" + } + } + } } diff --git a/package.json b/package.json index 52004f08e3..e9daa4de6e 100644 --- a/package.json +++ b/package.json @@ -249,6 +249,7 @@ "ngx-highlightjs": "^12.0.0", "npm-run-all2": "^6.0.0", "nx": "~19.5.0", + "nx-cloud": "^19.1.0", "playwright-lighthouse": "~4.0.0", "postcss": "~8.4.31", "postcss-scss": "~4.0.9", diff --git a/yarn.lock b/yarn.lock index 6d836af936..e24db2bca3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6601,6 +6601,15 @@ __metadata: languageName: node linkType: hard +"@nrwl/nx-cloud@npm:19.1.0": + version: 19.1.0 + resolution: "@nrwl/nx-cloud@npm:19.1.0" + dependencies: + nx-cloud: "npm:19.1.0" + checksum: 10/ecae86aa0af80fb5d82f7f1cfc8e985231624f19b0131237a891895804def6f20a3c69fb2dbab020889b0351361ba9e9108a104c6f40243b029a7f98868a0042 + languageName: node + linkType: hard + "@nrwl/tao@npm:19.5.9": version: 19.5.9 resolution: "@nrwl/tao@npm:19.5.9" @@ -8759,6 +8768,7 @@ __metadata: ngx-highlightjs: "npm:^12.0.0" npm-run-all2: "npm:^6.0.0" nx: "npm:~19.5.0" + nx-cloud: "npm:^19.1.0" pixelmatch: "npm:^5.2.1" playwright-lighthouse: "npm:~4.0.0" pngjs: "npm:^7.0.0" @@ -15963,7 +15973,7 @@ __metadata: languageName: node linkType: hard -"axios@npm:1.7.7, axios@npm:^1.6.7, axios@npm:^1.7.2": +"axios@npm:1.7.7, axios@npm:^1.6.0, axios@npm:^1.6.7, axios@npm:^1.7.2": version: 1.7.7 resolution: "axios@npm:1.7.7" dependencies: @@ -19279,6 +19289,13 @@ __metadata: languageName: node linkType: hard +"dotenv@npm:~10.0.0": + version: 10.0.0 + resolution: "dotenv@npm:10.0.0" + checksum: 10/55f701ae213e3afe3f4232fae5edfb6e0c49f061a363ff9f1c5a0c2bf3fb990a6e49aeada11b2a116efb5fdc3bc3f1ef55ab330be43033410b267f7c0809a9dc + languageName: node + linkType: hard + "dotgitignore@npm:^2.1.0": version: 2.1.0 resolution: "dotgitignore@npm:2.1.0" @@ -26745,7 +26762,7 @@ __metadata: languageName: node linkType: hard -"node-machine-id@npm:1.1.12": +"node-machine-id@npm:1.1.12, node-machine-id@npm:^1.1.12": version: 1.1.12 resolution: "node-machine-id@npm:1.1.12" checksum: 10/46bf3d4fab8d0e63b24c42bcec2b6975c7ec5bc16e53d7a589d095668d0fdf0bfcbcdc28246dd1ef74cf95a37fbd774cd4b17b41f518d79dfad7fdc99f995903 @@ -27004,6 +27021,26 @@ __metadata: languageName: node linkType: hard +"nx-cloud@npm:19.1.0, nx-cloud@npm:^19.1.0": + version: 19.1.0 + resolution: "nx-cloud@npm:19.1.0" + dependencies: + "@nrwl/nx-cloud": "npm:19.1.0" + axios: "npm:^1.6.0" + chalk: "npm:^4.1.0" + dotenv: "npm:~10.0.0" + fs-extra: "npm:^11.1.0" + ini: "npm:4.1.3" + node-machine-id: "npm:^1.1.12" + open: "npm:~8.4.0" + tar: "npm:6.2.1" + yargs-parser: "npm:>=21.1.1" + bin: + nx-cloud: bin/nx-cloud.js + checksum: 10/c4cfaac8b048580e6d0b18d1cc6c94107762c91fc9530806465a7286f2fff924bc98914883ddb052c53c4066fbe2bfe19674f69729e28fe4928e25dd1e911828 + languageName: node + linkType: hard + "nx@npm:19.5.9, nx@npm:~19.5.0": version: 19.5.9 resolution: "nx@npm:19.5.9" @@ -27276,7 +27313,7 @@ __metadata: languageName: node linkType: hard -"open@npm:^8.0.0, open@npm:^8.0.4, open@npm:^8.0.9, open@npm:^8.4.0": +"open@npm:^8.0.0, open@npm:^8.0.4, open@npm:^8.0.9, open@npm:^8.4.0, open@npm:~8.4.0": version: 8.4.2 resolution: "open@npm:8.4.2" dependencies: @@ -31996,7 +32033,7 @@ __metadata: languageName: node linkType: hard -"tar@npm:^6.0.5, tar@npm:^6.1.11, tar@npm:^6.2.1": +"tar@npm:6.2.1, tar@npm:^6.0.5, tar@npm:^6.1.11, tar@npm:^6.2.1": version: 6.2.1 resolution: "tar@npm:6.2.1" dependencies: @@ -34589,7 +34626,7 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:21.1.1, yargs-parser@npm:^21.0.0, yargs-parser@npm:^21.1.1": +"yargs-parser@npm:21.1.1, yargs-parser@npm:>=21.1.1, yargs-parser@npm:^21.0.0, yargs-parser@npm:^21.1.1": version: 21.1.1 resolution: "yargs-parser@npm:21.1.1" checksum: 10/9dc2c217ea3bf8d858041252d43e074f7166b53f3d010a8c711275e09cd3d62a002969a39858b92bbda2a6a63a585c7127014534a560b9c69ed2d923d113406e