From ad7d259a4a28d8735b618e9bd9a085de190b05ea Mon Sep 17 00:00:00 2001 From: David Sondermann Date: Tue, 11 Mar 2025 05:25:27 +0000 Subject: [PATCH] Fix concurrent usage of check-junit-reports sub-action --- .github/workflows/integration-test.yml | 54 ++++++++++++++++++-------- checkout-junit-reports/action.yml | 9 +++++ 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index fbad8df..650f02f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -35,41 +35,61 @@ jobs: echo "Saving expexted JUnit reports SHA $SHA" echo "expected-junit-reports-sha=${SHA}" >> "$GITHUB_ENV" - - name: Download JUnit reports + - name: Checkout JUnit reports (split-index 1) + uses: ./checkout-junit-reports + with: + split-index: 1 + git-branch: junit-reports-it-${{ github.sha }}-download + path: junit-reports-first-index-1 + + - name: Checkout JUnit reports (split-index 0) uses: ./checkout-junit-reports with: + split-index: 0 git-branch: junit-reports-it-${{ github.sha }}-download - path: junit-reports-first + path: junit-reports-first-index-0 + + - name: Checkout JUnit reports (split-index 2) + uses: ./checkout-junit-reports + with: + split-index: 2 + git-branch: junit-reports-it-${{ github.sha }}-download + path: junit-reports-first-index-2 - name: Assert JUnit reports - working-directory: junit-reports-first run: | - REPORT_FILE="first.xml" - if [[ ! -f "$REPORT_FILE" ]]; then - echo "Error: JUnit report $REPORT_FILE not found!" - ls -l - exit 1 - fi - FILE_COUNT=$(ls -1 | wc -l) - if [[ "$FILE_COUNT" -ne 1 ]]; then - echo "Error: Expected 1 JUnit reports, but found $FILE_COUNT files!" - ls -l - exit 1 - fi + for SPLIT_INDEX in {0..2}; do + echo "Checking JUnit reports for split-index $SPLIT_INDEX" + cd junit-reports-first-index-$SPLIT_INDEX + REPORT_FILE="first.xml" + if [[ ! -f "$REPORT_FILE" ]]; then + echo "Error: JUnit report $REPORT_FILE not found!" + ls -l + exit 1 + fi + FILE_COUNT=$(ls -1 | wc -l) + if [[ "$FILE_COUNT" -ne 1 ]]; then + echo "Error: Expected 1 JUnit reports, but found $FILE_COUNT files!" + ls -l + exit 1 + fi + cd .. + done - name: Update JUnit reports - working-directory: junit-reports-first + working-directory: junit-reports-first-index-0 run: | touch second.xml git add *.xml git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" git commit -m "Second commit for JUnit reports branch" - git push + git push origin HEAD:junit-reports-it-${{ github.sha }}-download - name: Download JUnit reports uses: ./checkout-junit-reports with: + split-index: 0 git-branch: junit-reports-it-${{ github.sha }}-download path: junit-reports-second diff --git a/checkout-junit-reports/action.yml b/checkout-junit-reports/action.yml index afef257..5a0c346 100644 --- a/checkout-junit-reports/action.yml +++ b/checkout-junit-reports/action.yml @@ -5,6 +5,10 @@ branding: icon: download color: blue inputs: + split-index: + description: Index of this instance executing the tests (integer) + required: true + type: number git-branch: description: The Git branch in this repository to download the JUnit reports from (string) required: true @@ -55,6 +59,11 @@ runs: else echo "Checking out JUnit reports from previously used SHA $CHECKOUT_REF" fi + # we can only upload the artifact once, so only do this on the first split + if [ "${{ inputs.split-index }}" != "0" ]; then + echo "Skipping upload of JUnit reports SHA on this index" + UPLOAD_SHA_ARTIFACT=false + fi echo "upload-artifact=${UPLOAD_SHA_ARTIFACT}" >> "$GITHUB_OUTPUT" echo "ref=${CHECKOUT_REF}" >> "$GITHUB_OUTPUT"