Skip to content

Commit

Permalink
Publish test results from workflow_run only (#5947)
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi authored Nov 6, 2021
1 parent 1ecf91a commit 402a9b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,12 @@ jobs:
name: codecov-umbrella
fail_ci_if_error: false

publish-test-results:
needs: test
event_file:
name: "Event File"
runs-on: ubuntu-latest
# the build-and-test job might be skipped, we don't need to run this job then
if: success() || failure()

steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: test-results

- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
- name: Upload
uses: actions/upload-artifact@v2
with:
files: test-results/**/*.xml
name: Event File
path: ${{ github.event_path }}
17 changes: 6 additions & 11 deletions .github/workflows/publish-test-results.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copied from https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.18/README.md#support-fork-repositories-and-dependabot-branches
# Copied from https://github.com/EnricoMi/publish-unit-test-result-action/blob/v1.23/README.md#support-fork-repositories-and-dependabot-branches

name: Publish test results

Expand All @@ -12,11 +12,7 @@ jobs:
publish-test-results:
name: Publish test results
runs-on: ubuntu-latest
if: >
github.event.workflow_run.conclusion != 'skipped' && (
github.event.sender.login == 'dependabot[bot]' ||
github.event.workflow_run.head_repository.full_name != github.repository
)
if: github.event.workflow_run.conclusion != 'skipped'

steps:
- name: Download and extract artifacts
Expand All @@ -26,13 +22,10 @@ jobs:
mkdir artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
artifacts=$(gh api $artifacts_url -q '.artifacts[] | {name: .name, url: .archive_download_url}')
IFS=$'\n'
for artifact in $artifacts
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
name=$(jq -r .name <<<$artifact)
url=$(jq -r .url <<<$artifact)
IFS=$'\t' read name url <<< "$artifact"
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
done
Expand All @@ -41,4 +34,6 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action@v1
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "artifacts/**/*.xml"

0 comments on commit 402a9b3

Please sign in to comment.