Skip to content

updates with matrix workflow #1

updates with matrix workflow

updates with matrix workflow #1

name: matrix-tests-template

Check failure on line 1 in .github/workflows/matrix-tests-template.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/matrix-tests-template.yml

Invalid workflow file

(Line: 7, Col: 9): Required property is missing: type, (Line: 9, Col: 9): Required property is missing: type, (Line: 11, Col: 9): Required property is missing: type, (Line: 15, Col: 9): Required property is missing: type, (Line: 17, Col: 9): Required property is missing: type
on:
workflow_call:
inputs:
stage_name:
required: true
stage_key:
required: true
gradle_task:
required: true
# Where to look for test sources, and the root segment used to compute FQNs:
# (Adjust to your project layout)
src_pattern:
required: true
src_root:
required: true
jobs:
matrix-tests-template:
runs-on: ubuntu-latest-128
environment: dev
strategy:
fail-fast: false
matrix:
shard: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23] # <= number of parallel shards
total: [24]
steps:
- name: Checkout
uses: actions/checkout@v5
with:
submodules: 'recursive'
- name: Prepare
uses: ./.github/actions/prepare
- name: Compute shard ${{ matrix.shard }} of ${{ matrix.total }} for ${{ inputs.stage_name }}
id: shard
shell: bash
run: |
SRC_PATTERN="${{ inputs.src_pattern }}" # e.g. */src/test/java/* or */src/property-test/java/* etc
# 1) Collect test classes by pattern = FQNs
CLASSNAMES=$(find . -type f -name "*.java" -path "$SRC_PATTERN" \
| sed "s@.*/${{ inputs.src_root }}/@@" \
| sed 's@/@.@g' \
| sed 's/.\{5\}$//')
# 2) Modulo split
CLASSES_FOR_SHARD=$(printf "%s\n" "$CLASSNAMES" \
| awk -v shards=${{ matrix.total }} -v shard=${{ matrix.shard }} '((NR-1) % shards) == shard')
if [ -z "$CLASSES_FOR_SHARD" ]; then
echo "args=" >> "$GITHUB_OUTPUT"
exit 0
fi
# 3) Build --tests args
GRADLE_ARGS=$(printf "%s\n" "$CLASSES_FOR_SHARD" | awk '{printf "--tests %s ", $0}')
echo "Prepared arguments for Gradle (${{ inputs.stage_name }}): $GRADLE_ARGS"
echo "args=$GRADLE_ARGS" >> "$GITHUB_OUTPUT"
- name: Run ${{ inputs.stage_name }} (shard)
if: steps.shard.outputs.args != ''
run: |
./gradlew --no-daemon --parallel --info ${{ inputs.gradle_task }} ${{ steps.shard.outputs.args }}
- name: Upload JUnit XML + HTML for ${{ inputs.stage_name }}
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.stage_key }}-reports-${{ matrix.shard }}
path: |
**/build/test-results/**/TEST-*.xml
**/build/reports/tests/**
if-no-files-found: ignore