Files
alfresco-ng2-components/.github/workflows/unit-test-workflow.yml
T
Workflow config file is invalid. Please check your config file: getMatrixes: matrix include must be a list of mappings

88 lines
3.1 KiB
YAML

name: "Unit Tests Workflow"
on:
workflow_call:
inputs:
base_ref:
description: 'Base branch for affected calculation'
required: false
type: string
default: 'develop'
jobs:
generate-affected-matrix:
name: "Generate affected matrix"
runs-on: ubuntu-latest
outputs:
unitMatrix: ${{ steps.set-matrix.outputs.unitMatrix }}
hasProjects: ${{ steps.set-matrix.outputs.hasProjects }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Setup environment
id: setup-env
uses: ./.github/actions/setup
with:
cache-suffix: test-matrix
- name: Install dependencies
if: ${{ steps.setup-env.outputs.node-modules-cache-hit != 'true' }}
run: pnpm install --frozen-lockfile
- name: Generate affected projects matrix
id: set-matrix
env:
BASE_REF: ${{ inputs.base_ref }}
run: |
echo "Base ref is $BASE_REF"
AFFECTED_UNIT=$(npx nx show projects --affected --target=test --base=origin/$BASE_REF --head=HEAD --select=projects --plain --exclude=cli,stories,eslint-angular)
echo "Affected projects for UNIT: $AFFECTED_UNIT"
if [ -z "$AFFECTED_UNIT" ]; then
echo "No affected projects found"
echo "hasProjects=false" >> $GITHUB_OUTPUT
echo "unitMatrix=[]" >> $GITHUB_OUTPUT
else
UNIT_MATRIX_JSON=$(echo "$AFFECTED_UNIT" | xargs -n1 | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({ "project": . })')
echo "Matrix UNIT: $UNIT_MATRIX_JSON"
echo "hasProjects=true" >> $GITHUB_OUTPUT
echo "unitMatrix=$UNIT_MATRIX_JSON" >> $GITHUB_OUTPUT
fi
- name: Save nx cache
if: ${{ success() }}
uses: ./.github/actions/save-nx-cache
with:
cache-suffix: test-matrix
unit-tests:
timeout-minutes: 30
runs-on: ubuntu-latest
needs: generate-affected-matrix
if: ${{ needs.generate-affected-matrix.outputs.hasProjects == 'true' }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-affected-matrix.outputs.unitMatrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup environment
id: setup-env
uses: ./.github/actions/setup
with:
cache-suffix: test-${{ matrix.project }}
full-setup: 'false'
- name: Install dependencies
if: ${{ steps.setup-env.outputs.node-modules-cache-hit != 'true' }}
run: pnpm install --frozen-lockfile
- name: Run unit tests for ${{ matrix.project }}
env:
NODE_OPTIONS: "--max-old-space-size=5120"
run: |
xvfb-run --auto-servernum npx nx run ${{ matrix.project }}:test
- name: Save nx cache
if: ${{ success() }}
uses: ./.github/actions/save-nx-cache
with:
cache-suffix: test-${{ matrix.project }}