Skip to content

Commit b98648d

Browse files
committed
Fix concurrent usage of check-junit-reports sub-action
1 parent 2918ad5 commit b98648d

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

.github/workflows/integration-test.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,61 @@ jobs:
3535
echo "Saving expexted JUnit reports SHA $SHA"
3636
echo "expected-junit-reports-sha=${SHA}" >> "$GITHUB_ENV"
3737
38-
- name: Download JUnit reports
38+
- name: Checkout JUnit reports (split-index 1)
39+
uses: ./checkout-junit-reports
40+
with:
41+
split-index: 1
42+
git-branch: junit-reports-it-${{ github.sha }}-download
43+
path: junit-reports-first-index-1
44+
45+
- name: Checkout JUnit reports (split-index 0)
3946
uses: ./checkout-junit-reports
4047
with:
48+
split-index: 0
4149
git-branch: junit-reports-it-${{ github.sha }}-download
42-
path: junit-reports-first
50+
path: junit-reports-first-index-0
51+
52+
- name: Checkout JUnit reports (split-index 2)
53+
uses: ./checkout-junit-reports
54+
with:
55+
split-index: 2
56+
git-branch: junit-reports-it-${{ github.sha }}-download
57+
path: junit-reports-first-index-2
4358

4459
- name: Assert JUnit reports
45-
working-directory: junit-reports-first
4660
run: |
47-
REPORT_FILE="first.xml"
48-
if [[ ! -f "$REPORT_FILE" ]]; then
49-
echo "Error: JUnit report $REPORT_FILE not found!"
50-
ls -l
51-
exit 1
52-
fi
53-
FILE_COUNT=$(ls -1 | wc -l)
54-
if [[ "$FILE_COUNT" -ne 1 ]]; then
55-
echo "Error: Expected 1 JUnit reports, but found $FILE_COUNT files!"
56-
ls -l
57-
exit 1
58-
fi
61+
for SPLIT_INDEX in {0..2}; do
62+
echo "Checking JUnit reports for split-index $SPLIT_INDEX"
63+
cd junit-reports-first-index-$SPLIT_INDEX
64+
REPORT_FILE="first.xml"
65+
if [[ ! -f "$REPORT_FILE" ]]; then
66+
echo "Error: JUnit report $REPORT_FILE not found!"
67+
ls -l
68+
exit 1
69+
fi
70+
FILE_COUNT=$(ls -1 | wc -l)
71+
if [[ "$FILE_COUNT" -ne 1 ]]; then
72+
echo "Error: Expected 1 JUnit reports, but found $FILE_COUNT files!"
73+
ls -l
74+
exit 1
75+
fi
76+
cd ..
77+
done
5978
6079
- name: Update JUnit reports
61-
working-directory: junit-reports-first
80+
working-directory: junit-reports-first-index-0
6281
run: |
6382
touch second.xml
6483
git add *.xml
6584
git config user.name "${{ github.actor }}"
6685
git config user.email "${{ github.actor }}@users.noreply.github.com"
6786
git commit -m "Second commit for JUnit reports branch"
68-
git push
87+
git push origin HEAD:junit-reports-it-${{ github.sha }}-download
6988
7089
- name: Download JUnit reports
7190
uses: ./checkout-junit-reports
7291
with:
92+
split-index: 0
7393
git-branch: junit-reports-it-${{ github.sha }}-download
7494
path: junit-reports-second
7595

checkout-junit-reports/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ branding:
55
icon: download
66
color: blue
77
inputs:
8+
split-index:
9+
description: Index of this instance executing the tests (integer)
10+
required: true
11+
type: number
812
git-branch:
913
description: The Git branch in this repository to download the JUnit reports from (string)
1014
required: true
@@ -55,6 +59,11 @@ runs:
5559
else
5660
echo "Checking out JUnit reports from previously used SHA $CHECKOUT_REF"
5761
fi
62+
# we can only upload the artifact once, so only do this on the first split
63+
if [ "${{ inputs.split-index }}" != "0" ]; then
64+
echo "Skipping upload of JUnit reports SHA on this index"
65+
UPLOAD_SHA_ARTIFACT=false
66+
fi
5867
echo "upload-artifact=${UPLOAD_SHA_ARTIFACT}" >> "$GITHUB_OUTPUT"
5968
echo "ref=${CHECKOUT_REF}" >> "$GITHUB_OUTPUT"
6069

0 commit comments

Comments
 (0)