[AAE-30877] - fixed the unit test tasks

This commit is contained in:
VitoAlbano
2025-03-13 07:54:11 +00:00
committed by Wojciech Duda
parent 33d1e1b21d
commit 714da3ecc9

View File

@@ -64,7 +64,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Ensure SHA pinned actions - name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@4830be28ce81da52ec70d65c552a7403821d98d4 # v3.0.23 uses: zgosalvez/github-actions-ensure-sha-pinned-actions@25ed13d0628a1601b4b44048e63cc4328ed03633 # v3.0.22
- name: Check package-lock.json version - name: Check package-lock.json version
run: | run: |
@@ -84,10 +84,10 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Get branch name - name: Get branch name
uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@45bb8b664779b691f8a21d9fd49e360916726c11 # v8.18.1 uses: Alfresco/alfresco-build-tools/.github/actions/get-branch-name@c1236aee36bb9b35c5972819fcf8a4d07572e6cd # v8.16.0
- name: Save commit message - name: Save commit message
uses: Alfresco/alfresco-build-tools/.github/actions/get-commit-message@45bb8b664779b691f8a21d9fd49e360916726c11 # v8.18.1 uses: Alfresco/alfresco-build-tools/.github/actions/get-commit-message@c1236aee36bb9b35c5972819fcf8a4d07572e6cd # v8.16.0
- name: ci:force flag parser - name: ci:force flag parser
shell: bash shell: bash
@@ -172,39 +172,50 @@ jobs:
npx nx run cli:bundle npx nx run cli:bundle
- uses: ./.github/actions/upload-node-modules-and-artifacts - uses: ./.github/actions/upload-node-modules-and-artifacts
unit-tests: generate-affected-matrix:
timeout-minutes: 30 name: "Generate affected matrix"
name: "Unit tests: ${{ matrix.unit-tests.name }}"
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [setup] needs: [setup, build-libs, lint]
strategy: outputs:
fail-fast: false matrix: ${{ steps.set-matrix.outputs.matrix }}
# max-parallel: 4
matrix:
unit-tests:
- name: js-api
exclude: "core,insights,content-services,process-services,process-services-cloud,eslint-plugin-eslint-angular"
- name: content-services
exclude: "insights,core,extensions,process-services,process-services-cloud,eslint-plugin-eslint-angular,js-api"
- name: core
exclude: "insights,extensions,content-services,process-services,process-services-cloud,eslint-plugin-eslint-angular,js-api"
- name: insights
exclude: "core,extensions,content-services,process-services-cloud,process-services,eslint-plugin-eslint-angular,js-api"
- name: process-services
exclude: "core,extensions,content-services,process-services-cloud,insights,eslint-plugin-eslint-angular,js-api"
- name: process-services-cloud
exclude: "insights,core,extensions,content-services,process-services$,eslint-plugin-eslint-angular,js-api"
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with: with:
fetch-depth: 0 # Fetch all history for all tags and branches fetch-depth: 0
- name: Install dependencies
run: npm ci
- name: Generate affected projects matrix
id: set-matrix
run: |
BASE_REF="${{ github.event.pull_request.base.ref }}"
echo "Base ref is $BASE_REF"
AFFECTED=$(npx nx show projects --affected --target=test --base=origin/$BASE_REF --select=projects --plain --exclude=stories,eslint-angular)
echo "Affected projects: $AFFECTED"
MATRIX_JSON=$(echo $AFFECTED | xargs -n1 | jq -R -s -c 'split("\n")[:-1] | map({ "project": . })')
MATRIX_JSON=$(echo "$MATRIX_JSON" | tr -d '\n' | sed 's/"$//')
echo "Matrix JSON: $MATRIX_JSON"
core.setOutput('matrix', matrix);
unit-tests:
if: ${{ needs.generate-affected-matrix.outputs.matrix != '' }}
name: "Unit tests for affected project: ${{ matrix.project }}"
runs-on: ubuntu-latest
needs: [generate-affected-matrix]
strategy:
matrix: ${{ fromJson(needs.generate-affected-matrix.outputs.matrix) }}
max-parallel: 4
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- uses: ./.github/actions/setup - uses: ./.github/actions/setup
- uses: ./.github/actions/download-node-modules-and-artifacts - uses: ./.github/actions/download-node-modules-and-artifacts
- name: Run unit tests - name: Run test for ${{ matrix.project }}
env:
NODE_OPTIONS: "--max-old-space-size=5120"
run: | run: |
/usr/bin/xvfb-run --auto-servernum npx nx affected:test --exclude=${{ matrix.unit-tests.exclude }} xvfb-run --auto-servernum npx nx run ${{ matrix.project }}:test
lint: lint:
# long timeout required when cache has to be recreated # long timeout required when cache has to be recreated
timeout-minutes: 30 timeout-minutes: 30