Skip to content

Commit 1a4dbcf

Browse files
authored
🧪 Delegate artifact merge and garbage collection to GH (ansible#16019)
* 🧪 Unpersist Git creds @ cov combine job This is one of the things Zizmor [[1]] warns about. [1]: https://docs.zizmor.sh * 🧪 Download all coverage artifacts in one go * 🧪 Delegate artifact garbage collection to GH This is implemented by setting the retention days input to 1 on the initial upload.
1 parent c449c4c commit 1a4dbcf

File tree

1 file changed

+5
-54
lines changed

1 file changed

+5
-54
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ jobs:
335335
with:
336336
name: coverage-${{ matrix.target-regex.name }}
337337
path: ~/.ansible/collections/ansible_collections/awx/awx/tests/output/coverage/
338+
retention-days: 1
338339

339340
- uses: ./.github/actions/upload_awx_devel_logs
340341
if: always()
@@ -352,6 +353,7 @@ jobs:
352353
steps:
353354
- uses: actions/checkout@v4
354355
with:
356+
persist-credentials: false
355357
show-progress: false
356358

357359
- uses: ./.github/actions/setup-python
@@ -361,23 +363,12 @@ jobs:
361363
- name: Upgrade ansible-core
362364
run: python3 -m pip install --upgrade ansible-core
363365

364-
- name: Download coverage artifacts A to H
366+
- name: Download coverage artifacts
365367
uses: actions/download-artifact@v4
366368
with:
367-
name: coverage-a-h
368-
path: coverage
369-
370-
- name: Download coverage artifacts I to P
371-
uses: actions/download-artifact@v4
372-
with:
373-
name: coverage-i-p
374-
path: coverage
375-
376-
- name: Download coverage artifacts Z to Z
377-
uses: actions/download-artifact@v4
378-
with:
379-
name: coverage-r-z0-9
369+
merge-multiple: true
380370
path: coverage
371+
pattern: coverage-*
381372

382373
- name: Combine coverage
383374
run: |
@@ -395,46 +386,6 @@ jobs:
395386
echo '## AWX Collection Integration Coverage HTML' >> $GITHUB_STEP_SUMMARY
396387
echo 'Download the HTML artifacts to view the coverage report.' >> $GITHUB_STEP_SUMMARY
397388
398-
# This is a huge hack, there's no official action for removing artifacts currently.
399-
# Also ACTIONS_RUNTIME_URL and ACTIONS_RUNTIME_TOKEN aren't available in normal run
400-
# steps, so we have to use github-script to get them.
401-
#
402-
# The advantage of doing this, though, is that we save on artifact storage space.
403-
404-
- name: Get secret artifact runtime URL
405-
uses: actions/github-script@v6
406-
id: get-runtime-url
407-
with:
408-
result-encoding: string
409-
script: |
410-
const { ACTIONS_RUNTIME_URL } = process.env;
411-
return ACTIONS_RUNTIME_URL;
412-
413-
- name: Get secret artifact runtime token
414-
uses: actions/github-script@v6
415-
id: get-runtime-token
416-
with:
417-
result-encoding: string
418-
script: |
419-
const { ACTIONS_RUNTIME_TOKEN } = process.env;
420-
return ACTIONS_RUNTIME_TOKEN;
421-
422-
- name: Remove intermediary artifacts
423-
env:
424-
ACTIONS_RUNTIME_URL: ${{ steps.get-runtime-url.outputs.result }}
425-
ACTIONS_RUNTIME_TOKEN: ${{ steps.get-runtime-token.outputs.result }}
426-
run: |
427-
echo "::add-mask::${ACTIONS_RUNTIME_TOKEN}"
428-
artifacts=$(
429-
curl -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \
430-
${ACTIONS_RUNTIME_URL}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview \
431-
| jq -r '.value | .[] | select(.name | startswith("coverage-")) | .url'
432-
)
433-
434-
for artifact in $artifacts; do
435-
curl -i -X DELETE -H "Accept: application/json;api-version=6.0-preview" -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" "$artifact"
436-
done
437-
438389
- name: Upload coverage report as artifact
439390
uses: actions/upload-artifact@v4
440391
with:

0 commit comments

Comments
 (0)