From c8a432e0ebdd1436abd0063794b30d1d7adb3652 Mon Sep 17 00:00:00 2001 From: Senthanal Sirpi Manohar Date: Mon, 29 Sep 2025 22:33:04 +0200 Subject: [PATCH 1/4] Optimize node caching in GitHub Actions workflows --- .github/actions/run-many/action.yml | 2 -- .github/workflows/fe-build.yml | 2 +- .github/workflows/fe-code-quality.yml | 2 +- .github/workflows/fe-e2e.yml | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/actions/run-many/action.yml b/.github/actions/run-many/action.yml index 1d5089f7..7db3b5bd 100644 --- a/.github/actions/run-many/action.yml +++ b/.github/actions/run-many/action.yml @@ -19,7 +19,5 @@ inputs: runs: using: 'composite' steps: - - run: cd "$GITHUB_ACTION_PATH/../../.." && pwd && npm ci - shell: bash - run: npx ts-node "$GITHUB_ACTION_PATH/../../../tools/scripts/run-many/run-many.ts" ${{ inputs.target }} ${{ inputs.jobIndex }} ${{ inputs.jobCount }} ${{ inputs.base }} ${{ inputs.ref }} shell: bash diff --git a/.github/workflows/fe-build.yml b/.github/workflows/fe-build.yml index d4116b62..8e6bb526 100644 --- a/.github/workflows/fe-build.yml +++ b/.github/workflows/fe-build.yml @@ -44,7 +44,7 @@ jobs: run: git fetch origin ${{ inputs.GHA_BASE }}:${{ inputs.GHA_BASE }} || true - name: Build and Storybook - uses: collaborationFactory/github-actions/.github/actions/run-many@master + uses: collaborationFactory/github-actions/.github/actions/run-many@poc/pipeline-node-cache-optimization with: target: ${{ matrix.target }} jobIndex: ${{ matrix.jobIndex }} diff --git a/.github/workflows/fe-code-quality.yml b/.github/workflows/fe-code-quality.yml index 250c138b..39e750e5 100644 --- a/.github/workflows/fe-code-quality.yml +++ b/.github/workflows/fe-code-quality.yml @@ -37,7 +37,7 @@ jobs: run: git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} || true - name: Unit Tests - uses: collaborationFactory/github-actions/.github/actions/run-many@master + uses: collaborationFactory/github-actions/.github/actions/run-many@poc/pipeline-node-cache-optimization with: target: ${{ matrix.target }} jobIndex: ${{ matrix.jobIndex }} diff --git a/.github/workflows/fe-e2e.yml b/.github/workflows/fe-e2e.yml index f3513d70..3b302b47 100644 --- a/.github/workflows/fe-e2e.yml +++ b/.github/workflows/fe-e2e.yml @@ -48,7 +48,7 @@ jobs: - name: Affected Regression Tests id: regressionTests continue-on-error: true - uses: collaborationFactory/github-actions/.github/actions/run-many@master + uses: collaborationFactory/github-actions/.github/actions/run-many@poc/pipeline-node-cache-optimization with: target: ${{ matrix.target }} jobIndex: ${{ matrix.jobIndex }} From e61c9f8919ac4084d3800f5f499359d6e22fc0c4 Mon Sep 17 00:00:00 2001 From: Senthanal Sirpi Manohar Date: Mon, 29 Sep 2025 23:23:01 +0200 Subject: [PATCH 2/4] Optimize npm installation steps in GitHub Actions workflows --- .github/actions/artifacts/action.yml | 2 -- .github/workflows/fe-build.yml | 3 +++ .github/workflows/fe-code-quality.yml | 3 +++ .github/workflows/fe-pr-snapshot.yml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/actions/artifacts/action.yml b/.github/actions/artifacts/action.yml index c0fa97cb..f1b20df9 100644 --- a/.github/actions/artifacts/action.yml +++ b/.github/actions/artifacts/action.yml @@ -5,7 +5,5 @@ runs: steps: - run: printenv shell: bash - - run: cd "$GITHUB_ACTION_PATH/../../.." && pwd && npm ci - shell: bash - run: npx ts-node "$GITHUB_ACTION_PATH/../../../tools/scripts/artifacts/main.ts" shell: bash diff --git a/.github/workflows/fe-build.yml b/.github/workflows/fe-build.yml index 8e6bb526..2e68242e 100644 --- a/.github/workflows/fe-build.yml +++ b/.github/workflows/fe-build.yml @@ -40,6 +40,9 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: npm ci + run: npm ci + - name: Fetch base branch run: git fetch origin ${{ inputs.GHA_BASE }}:${{ inputs.GHA_BASE }} || true diff --git a/.github/workflows/fe-code-quality.yml b/.github/workflows/fe-code-quality.yml index 39e750e5..abce1b0f 100644 --- a/.github/workflows/fe-code-quality.yml +++ b/.github/workflows/fe-code-quality.yml @@ -27,6 +27,9 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: npm ci + run: npm ci + - name: Formatter run: npx nx format:check --base=origin/${{ github.event.pull_request.base.ref }} diff --git a/.github/workflows/fe-pr-snapshot.yml b/.github/workflows/fe-pr-snapshot.yml index 9d40c315..beffe774 100644 --- a/.github/workflows/fe-pr-snapshot.yml +++ b/.github/workflows/fe-pr-snapshot.yml @@ -62,7 +62,7 @@ jobs: run: npm ci - name: Build and Push to Jfrog NPM Registry - uses: collaborationFactory/github-actions/.github/actions/artifacts@master + uses: collaborationFactory/github-actions/.github/actions/artifacts@poc/code-coverage-in-code-quality-pr-pipeline env: JFROG_BASE64_TOKEN: ${{ secrets.JFROG_BASE64_TOKEN }} JFROG_URL: ${{ secrets.JFROG_URL }} From 2636b62dac5dd9b4ec5f9d5f1376589946e2dccf Mon Sep 17 00:00:00 2001 From: Senthanal Sirpi Manohar Date: Mon, 29 Sep 2025 23:36:20 +0200 Subject: [PATCH 3/4] Add .npmrc secret handling and optimize npm installation in workflows --- .github/workflows/fe-build.yml | 11 ++++++++++- .github/workflows/fe-code-quality.yml | 14 ++++++++++++-- .github/workflows/fe-e2e.yml | 11 +++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/fe-build.yml b/.github/workflows/fe-build.yml index 2e68242e..7c901ffb 100644 --- a/.github/workflows/fe-build.yml +++ b/.github/workflows/fe-build.yml @@ -2,6 +2,9 @@ name: Frontend Build Workflow on: workflow_call: + secrets: + DOT_NPMRC: + required: true inputs: GHA_REF: type: string @@ -40,7 +43,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - name: npm ci + - name: Use .npmrc + uses: bduff9/use-npmrc@v1.1 + with: + dot-npmrc: ${{ secrets.DOT_NPMRC }} + + - name: Install modules + if: steps.npm-cache.outputs.cache-hit != 'true' run: npm ci - name: Fetch base branch diff --git a/.github/workflows/fe-code-quality.yml b/.github/workflows/fe-code-quality.yml index abce1b0f..8d3dcd02 100644 --- a/.github/workflows/fe-code-quality.yml +++ b/.github/workflows/fe-code-quality.yml @@ -1,6 +1,10 @@ name: Frontend Code Quality Workflow -on: workflow_call +on: + workflow_call: + secrets: + DOT_NPMRC: + required: true jobs: code-quality: @@ -27,7 +31,13 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} - - name: npm ci + - name: Use .npmrc + uses: bduff9/use-npmrc@v1.1 + with: + dot-npmrc: ${{ secrets.DOT_NPMRC }} + + - name: Install modules + if: steps.npm-cache.outputs.cache-hit != 'true' run: npm ci - name: Formatter diff --git a/.github/workflows/fe-e2e.yml b/.github/workflows/fe-e2e.yml index 3b302b47..daf8f96b 100644 --- a/.github/workflows/fe-e2e.yml +++ b/.github/workflows/fe-e2e.yml @@ -3,6 +3,8 @@ name: Frontend E2E Workflow on: workflow_call: secrets: + DOT_NPMRC: + required: true PERCY_TOKEN: required: false inputs: @@ -39,6 +41,15 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Use .npmrc + uses: bduff9/use-npmrc@v1.1 + with: + dot-npmrc: ${{ secrets.DOT_NPMRC }} + + - name: Install modules + if: steps.npm-cache.outputs.cache-hit != 'true' + run: npm ci + - name: Install Cypress Binary run: npx cypress install From a1acd75fc428c8c5baeae578455a42199b63e9e1 Mon Sep 17 00:00:00 2001 From: Senthanal Sirpi Manohar Date: Mon, 29 Sep 2025 23:43:28 +0200 Subject: [PATCH 4/4] Remove redundant cache check for npm module installation in workflows --- .github/workflows/fe-build.yml | 1 - .github/workflows/fe-code-quality.yml | 1 - .github/workflows/fe-e2e.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/fe-build.yml b/.github/workflows/fe-build.yml index 7c901ffb..a3d442b8 100644 --- a/.github/workflows/fe-build.yml +++ b/.github/workflows/fe-build.yml @@ -49,7 +49,6 @@ jobs: dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules - if: steps.npm-cache.outputs.cache-hit != 'true' run: npm ci - name: Fetch base branch diff --git a/.github/workflows/fe-code-quality.yml b/.github/workflows/fe-code-quality.yml index 8d3dcd02..a2ede86d 100644 --- a/.github/workflows/fe-code-quality.yml +++ b/.github/workflows/fe-code-quality.yml @@ -37,7 +37,6 @@ jobs: dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules - if: steps.npm-cache.outputs.cache-hit != 'true' run: npm ci - name: Formatter diff --git a/.github/workflows/fe-e2e.yml b/.github/workflows/fe-e2e.yml index daf8f96b..f7e4f5bb 100644 --- a/.github/workflows/fe-e2e.yml +++ b/.github/workflows/fe-e2e.yml @@ -47,7 +47,6 @@ jobs: dot-npmrc: ${{ secrets.DOT_NPMRC }} - name: Install modules - if: steps.npm-cache.outputs.cache-hit != 'true' run: npm ci - name: Install Cypress Binary