7171 path : junit-reports-first-index-4
7272 upload-artifact : false
7373
74+ - name : Checkout JUnit reports (non-existent branch)
75+ uses : ./checkout-junit-reports
76+ with :
77+ split-index : 0
78+ git-branch : junit-reports-it-${{ github.sha }}-nonexistent
79+ path : junit-reports-nonexistent-branch
80+ upload-artifact : false
81+
82+ - name : Assert non-existent branch checkout
83+ run : |
84+ echo "Verifying that checkout with non-existent branch succeeded"
85+ if [ ! -d "junit-reports-nonexistent-branch" ]; then
86+ echo "Error: Directory junit-reports-nonexistent-branch was not created!"
87+ exit 1
88+ fi
89+ cd junit-reports-nonexistent-branch
90+ # Should be on the default branch, verify we have the action files
91+ if [ ! -f "action.yml" ]; then
92+ echo "Error: action.yml not found - checkout didn't work properly!"
93+ ls -la
94+ exit 1
95+ fi
96+ # Verify we're not on the non-existent branch
97+ CURRENT_BRANCH=$(git branch --show-current)
98+ if [ "$CURRENT_BRANCH" == "junit-reports-it-${{ github.sha }}-nonexistent" ]; then
99+ echo "Error: Should not be on the non-existent branch!"
100+ exit 1
101+ fi
102+ echo "Successfully verified checkout with non-existent branch stays on default branch"
103+ cd ..
104+
74105 - name : Assert JUnit reports
75106 run : |
76107 for SPLIT_INDEX in {0..3}; do
@@ -99,7 +130,10 @@ jobs:
99130 git config user.name "${{ github.actor }}"
100131 git config user.email "${{ github.actor }}@users.noreply.github.com"
101132 git commit -m "Second commit for JUnit reports branch"
133+ UPDATED_SHA=$(git rev-parse HEAD)
102134 git push origin HEAD:junit-reports-it-${{ github.sha }}-download
135+ echo "Saving updated JUnit reports SHA $UPDATED_SHA"
136+ echo "updated-junit-reports-sha=${UPDATED_SHA}" >> "$GITHUB_ENV"
103137
104138 - name : Download JUnit reports
105139 uses : ./checkout-junit-reports
@@ -108,7 +142,7 @@ jobs:
108142 git-branch : junit-reports-it-${{ github.sha }}-download
109143 path : junit-reports-second
110144
111- - name : Assert JUnit reports
145+ - name : Assert JUnit reports (updated branch)
112146 working-directory : junit-reports-second
113147 run : |
114148 REPORT_FILE="first.xml"
@@ -117,12 +151,19 @@ jobs:
117151 ls -l
118152 exit 1
119153 fi
154+ SECOND_REPORT_FILE="second.xml"
155+ if [[ ! -f "$SECOND_REPORT_FILE" ]]; then
156+ echo "Error: JUnit report $SECOND_REPORT_FILE not found!"
157+ ls -l
158+ exit 1
159+ fi
120160 FILE_COUNT=$(ls -1 | wc -l)
121- if [[ "$FILE_COUNT" -ne 1 ]]; then
122- echo "Error: Expected 1 JUnit reports, but found $FILE_COUNT files!"
161+ if [[ "$FILE_COUNT" -ne 2 ]]; then
162+ echo "Error: Expected 2 JUnit reports, but found $FILE_COUNT files!"
123163 ls -l
124164 exit 1
125165 fi
166+ echo "Successfully verified updated JUnit reports branch contains both files"
126167
127168 - name : Download JUnit reports SHA artifact
128169 uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
@@ -146,10 +187,17 @@ jobs:
146187 exit 1
147188 fi
148189 ARTIFACT_SHA=$(cat $SHA_FILE)
149- if [ "$ARTIFACT_SHA" != "${{ env.expected-junit-reports-sha }}" ]; then
150- echo "Error: JUnit reports SHA $ARTIFACT_SHA in artifact does not match expected SHA ${{ env.expected-junit-reports-sha }}"
190+ # After the branch update, we should have the updated SHA
191+ EXPECTED_SHA="${{ env.updated-junit-reports-sha }}"
192+ if [ -z "$EXPECTED_SHA" ]; then
193+ # Fallback to original SHA if update didn't happen
194+ EXPECTED_SHA="${{ env.expected-junit-reports-sha }}"
195+ fi
196+ if [ "$ARTIFACT_SHA" != "$EXPECTED_SHA" ]; then
197+ echo "Error: JUnit reports SHA $ARTIFACT_SHA in artifact does not match expected SHA $EXPECTED_SHA"
151198 exit 1
152199 fi
200+ echo "Successfully verified JUnit reports SHA artifact contains expected SHA $EXPECTED_SHA"
153201
154202 - name : Clean up JUnit reports branch
155203 if : always()
0 commit comments