Skip to content

Commit 5d935c3

Browse files
committed
Don't upload multiple times to same artifact in "Manage PRs" workflow
The `check-submissions` job of the "Run integration tests" GitHub Actions workflow is configured to generate multiple parallel jobs, one for each of the submitted libraries. The subsequent jobs must be able to determine whether any of the libraries failed the checks. This is done by the matrix jobs in which checks failed uploading a flag file to a GitHub Actions workflow artifact, then the subsequent jobs checking for the presence of an artifact. The "actions/upload-artifact" and "actions/download-artifact" actions are used for this purpose. Previously, a single artifact was used for all flag files, with each of the parallel jobs uploading its flag file to that single artifact. However, support for uploading multiple times to a single artifact was dropped in version 4.0.0 of the "actions/upload-artifact" action. So it is now necessary to use a dedicated artifact for each of the parallel jobs. These artifacts can be downloaded in aggregate by using the artifact name globbing feature which was introduced in version 4.1.0 of the "actions/download-artifact" action.
1 parent 4a42992 commit 5d935c3

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

.github/workflows/manage-prs.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env:
55
MAINTAINERS: |
66
# GitHub user names to request reviews from in cases where PRs can't be managed automatically.
77
- per1234
8-
CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT: check-submissions-failed
8+
CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PREFIX: check-submissions-failed-
99
ERROR_MESSAGE_PREFIX: ":x: **ERROR:** "
1010

1111
on:
@@ -376,6 +376,13 @@ jobs:
376376
if: env.PASS == 'false'
377377
run: touch ${{ env.FAIL_FLAG_PATH }} # Arbitrary file to provide content for the flag artifact
378378

379+
# Each workflow artifact must have a unique name. The job matrix doesn't provide a guaranteed unique string to use
380+
# for a name so it is necessary to generate one.
381+
- name: Generate unique artifact suffix
382+
if: env.PASS == 'false'
383+
run: |
384+
echo "CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_SUFFIX=$(cat /proc/sys/kernel/random/uuid)" >> "$GITHUB_ENV"
385+
379386
# The value of a job matrix output is set by whichever job happened to run last, not of use for this application.
380387
# So it's necessary to use an alternative means of indicating that at least one submission failed the checks.
381388
- name: Upload failure flag artifact
@@ -385,7 +392,7 @@ jobs:
385392
if-no-files-found: error
386393
include-hidden-files: true
387394
path: ${{ env.FAIL_FLAG_PATH }}
388-
name: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT }}
395+
name: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PREFIX }}${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_SUFFIX }}
389396

390397
check-submissions-result:
391398
needs: check-submissions
@@ -394,13 +401,22 @@ jobs:
394401
outputs:
395402
pass: ${{ steps.failure-flag-exists.outcome == 'failure' }}
396403

404+
env:
405+
CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH: ${{ github.workspace }}/artifacts
406+
397407
steps:
408+
- name: Download submission check failure flag artifacts
409+
uses: actions/download-artifact@v4
410+
with:
411+
path: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH }}
412+
pattern: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PREFIX }}*
413+
398414
- name: Check for existence of submission check failure flag artifact
399415
id: failure-flag-exists
400-
uses: actions/download-artifact@v4
401416
continue-on-error: true
402-
with:
403-
name: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT }}
417+
# actions/download-artifact does not create a folder per its `path` input if no artifacts match `pattern`.
418+
run: |
419+
test -d "${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH }}"
404420
405421
check-submissions-fail:
406422
needs:

0 commit comments

Comments
 (0)