From 2f3ed31fb058d775eee7d761e88bd3572ce10fa6 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 25 Jul 2024 15:05:18 +0200 Subject: [PATCH 1/5] ci: improve jest execution on both CI and Local machine --- jest.preset.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jest.preset.js b/jest.preset.js index 74a60c2c..1499c2f3 100644 --- a/jest.preset.js +++ b/jest.preset.js @@ -7,4 +7,13 @@ module.exports = { // @see https://github.com/nrwl/nx/blob/master/packages/jest/preset/jest-preset.ts#L8-L13 '^.+\\.(ts|js|html)$': ['@swc/jest'], }, + maxWorkers: isCI() ? 1 : '50%', }; + +function isCI() { + return ( + (process.env.CI && process.env.CI !== 'false') || + process.env.TF_BUILD === 'true' || + process.env.GITHUB_ACTIONS === 'true' + ); +} From d40ffa7e9a4b32c7e87f1fe36a6761b80286ca02 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 25 Jul 2024 15:37:33 +0200 Subject: [PATCH 2/5] ci: simplify pr jobs and use env variables to set nx commoan params --- .github/workflows/ci.yml | 41 +++++++++++++++----------------------- .github/workflows/docs.yml | 7 ++++++- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aef67c86..e87faff5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,18 @@ on: - main pull_request: +env: + NX_PARALLEL: 2 # ubuntu-latest = 2-core CPU / 7 GB of RAM + NX_PREFER_TS_NODE: true + NX_VERBOSE_LOGGING: true + jobs: main: runs-on: ubuntu-latest + permissions: + contents: 'read' + actions: 'read' + steps: - uses: actions/checkout@v4 with: @@ -31,34 +40,16 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - - run: yarn nx affected --target=verify-integrity --parallel --max-parallel=3 - - run: yarn nx affected --target=type-check --parallel --max-parallel=3 - - run: yarn nx affected --target=build --parallel --max-parallel=3 - - run: yarn nx affected --target=build-storybook --parallel --max-parallel=3 - - run: yarn nx affected --target=test --parallel --max-parallel=2 - - run: yarn nx affected --target=component-test --skipInstall --parallel --max-parallel=2 - - run: yarn nx affected --target=lint --parallel --max-parallel=3 + - run: yarn nx affected --target=verify-integrity + - run: yarn nx affected --target=build + - run: yarn nx affected --target=build-storybook + - run: yarn nx affected --target=type-check + - run: yarn nx affected --target=lint + - run: yarn nx affected --target=test + - run: yarn nx affected --target=component-test - run: yarn nx format:check --base origin/main - name: 'Check for unstaged changes' run: | git status --porcelain git diff-index --quiet HEAD -- || exit 1 - - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - - - uses: actions/setup-node@v4 - with: - cache: 'yarn' - node-version: '20' - - - run: yarn install --frozen-lockfile - - run: yarn nx affected --target=build-storybook --parallel --max-parallel=3 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index de67537a..a77fff35 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -11,6 +11,11 @@ permissions: pages: write id-token: write +env: + NX_PARALLEL: 2 # ubuntu-latest = 2-core CPU / 7 GB of RAM + NX_PREFER_TS_NODE: true + NX_VERBOSE_LOGGING: true + # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: @@ -36,7 +41,7 @@ jobs: node-version: '20' - run: yarn install --frozen-lockfile - - run: yarn nx run-many --target=build-storybook --parallel --max-parallel=3 + - run: yarn nx run-many --target=build-storybook - name: Setup Pages uses: actions/configure-pages@v3 From 907761b34ef896253c1fbc86edf76c4ed94728d5 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 25 Jul 2024 15:40:01 +0200 Subject: [PATCH 3/5] fixup! ci: simplify pr jobs and use env variables to set nx commoan params --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e87faff5..4f006605 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: fetch-depth: 0 - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 + uses: nrwl/nx-set-shas@v4 - uses: actions/setup-node@v4 with: From 3a1c7a77eb1cfc0b62349d1437bdbfae7f0ec414 Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 25 Jul 2024 15:42:47 +0200 Subject: [PATCH 4/5] fixup! fixup! ci: simplify pr jobs and use env variables to set nx commoan params --- .github/workflows/ci.yml | 1 - .github/workflows/docs.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f006605..ac9c40d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: env: NX_PARALLEL: 2 # ubuntu-latest = 2-core CPU / 7 GB of RAM - NX_PREFER_TS_NODE: true NX_VERBOSE_LOGGING: true jobs: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a77fff35..2439351d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,6 @@ permissions: env: NX_PARALLEL: 2 # ubuntu-latest = 2-core CPU / 7 GB of RAM - NX_PREFER_TS_NODE: true NX_VERBOSE_LOGGING: true # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. From 12430677f1525c4ba986faf6cdd62ba0337fca1a Mon Sep 17 00:00:00 2001 From: Martin Hochel Date: Thu, 25 Jul 2024 15:45:19 +0200 Subject: [PATCH 5/5] fixup! fixup! fixup! ci: simplify pr jobs and use env variables to set nx commoan params --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac9c40d9..7a65501c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,7 @@ jobs: - run: yarn nx affected --target=type-check - run: yarn nx affected --target=lint - run: yarn nx affected --target=test - - run: yarn nx affected --target=component-test + - run: yarn nx affected --target=component-test --skipInstall - run: yarn nx format:check --base origin/main - name: 'Check for unstaged changes'