@@ -418,11 +418,126 @@ jobs:
418418 run : |
419419 git push origin --delete junit-reports-it-${{ github.sha }}-existing || true
420420
421+ merge-junit-reports-with-concurrent-push :
422+ name : Merge JUnit reports with concurrent push
423+ runs-on : ubuntu-latest
424+ needs :
425+ - integration-test
426+ permissions :
427+ contents : write
428+ env :
429+ BRANCH : junit-reports-it-${{ github.sha }}-concurrent
430+ steps :
431+ - name : Checkout split-tests-java-action
432+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
433+
434+ - name : Create JUnit reports branch
435+ run : |
436+ echo "Creating branch $BRANCH"
437+ git switch --orphan $BRANCH
438+ git config user.name "${{ github.actor }}"
439+ git config user.email "${{ github.actor }}@users.noreply.github.com"
440+ git commit --allow-empty -m "Initial commit for JUnit reports branch"
441+ git push origin --set-upstream $BRANCH
442+ git switch ${{ github.ref_name }}
443+
444+ - name : Checkout JUnit reports for concurrent push
445+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
446+ with :
447+ path : junit-reports-concurrent
448+ ref : ${{ env.BRANCH }}
449+
450+ - name : Prepare concurrent commit
451+ working-directory : junit-reports-concurrent
452+ run : |
453+ git config user.name "${{ github.actor }}"
454+ git config user.email "${{ github.actor }}@users.noreply.github.com"
455+ echo '<testsuite name="de.donnerbart.example.ConcurrentTest"/>' > TEST-de.donnerbart.example.ConcurrentTest.xml
456+ git add TEST-de.donnerbart.example.ConcurrentTest.xml
457+ git commit -m "Concurrent JUnit reports update"
458+ echo "concurrent-sha=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
459+
460+ - name : Install pre-push hook that pushes the concurrent commit first
461+ run : |
462+ HOOKS_DIR="$RUNNER_TEMP/git-hooks"
463+ mkdir -p "$HOOKS_DIR"
464+ cat > "$HOOKS_DIR/pre-push" <<'HOOK'
465+ #!/usr/bin/env bash
466+ MARKER="$RUNNER_TEMP/concurrent-push-done"
467+ if [[ -f "$MARKER" ]]; then
468+ exit 0
469+ fi
470+ touch "$MARKER"
471+ env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE \
472+ git -C "$GITHUB_WORKSPACE/junit-reports-concurrent" push --quiet origin HEAD:$BRANCH
473+ HOOK
474+ chmod +x "$HOOKS_DIR/pre-push"
475+ git config --global core.hooksPath "$HOOKS_DIR"
476+
477+ - name : Merge JUnit reports
478+ uses : ./merge-junit-reports
479+ with :
480+ git-branch : ${{ env.BRANCH }}
481+ artifact-name : junit-xml-report-concurrent
482+ split-artifact-pattern : junit-xml-reports-*
483+ split-artifact-delete-merged : false
484+
485+ - name : Remove pre-push hook
486+ if : always()
487+ run : git config --global --unset core.hooksPath || true
488+
489+ - name : Checkout JUnit reports
490+ uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
491+ with :
492+ path : junit-reports-assertion
493+ ref : ${{ env.BRANCH }}
494+ fetch-depth : 0
495+
496+ - name : Assert JUnit reports
497+ working-directory : junit-reports-assertion
498+ run : |
499+ if [[ ! -f "$RUNNER_TEMP/concurrent-push-done" ]]; then
500+ echo "Error: The pre-push hook did not push the concurrent commit!"
501+ exit 1
502+ fi
503+ if ! git merge-base --is-ancestor ${{ env.concurrent-sha }} HEAD; then
504+ echo "Error: The concurrent commit ${{ env.concurrent-sha }} is not part of $BRANCH!"
505+ git log --oneline
506+ exit 1
507+ fi
508+ for SPLIT_INDEX in {0..3}; do
509+ REPORT_FILE="TEST-de.donnerbart.example.ActionSplit${SPLIT_INDEX}Test.xml"
510+ SEARCH_STRING='name="de.donnerbart.example.ActionSplit'${SPLIT_INDEX}'Test"'
511+ if [[ ! -f "$REPORT_FILE" ]]; then
512+ echo "Error: JUnit report $REPORT_FILE not found!"
513+ ls -l
514+ exit 1
515+ fi
516+ if ! grep -q "$SEARCH_STRING" "$REPORT_FILE"; then
517+ echo "Error: JUnit report $REPORT_FILE does not contain the required string '$SEARCH_STRING'!"
518+ cat $REPORT_FILE
519+ exit 1
520+ fi
521+ echo "JUnit report $REPORT_FILE is valid"
522+ done
523+ FILE_COUNT=$(ls -1 | wc -l)
524+ if [[ "$FILE_COUNT" -ne 4 ]]; then
525+ echo "Error: Expected 4 JUnit reports, but found $FILE_COUNT files!"
526+ ls -l
527+ exit 1
528+ fi
529+
530+ - name : Clean up JUnit reports branch
531+ if : always()
532+ run : |
533+ git push origin --delete $BRANCH || true
534+
421535 merge-junit-reports-with-new-branch :
422536 name : Merge JUnit reports with new branch
423537 runs-on : ubuntu-latest
424538 needs :
425539 - merge-junit-reports-with-existing-branch
540+ - merge-junit-reports-with-concurrent-push
426541 permissions :
427542 contents : write
428543 steps :
0 commit comments