Skip to content

Commit

Permalink
Testing workflow_run which only triggers off default branch
Browse files Browse the repository at this point in the history
Signed-off-by: Albert Teoh <[email protected]>
  • Loading branch information
Albert Teoh committed Dec 24, 2023
1 parent 7d1cc9f commit e76188e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .github/workflows/ci-unit-tests-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Unit Test Results

on:
workflow_run:
workflows: ["Unit Tests"]
types:
- completed

jobs:
unit-test-results:
name: Unit Test Results
runs-on: ubuntu-latest

permissions:
checks: write

# needed unless run with comment_mode: off
pull-requests: write

# required by download step to access artifacts API
actions: read

steps:
- name: Harden Runner
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Download and Extract Artifacts
uses: dawidd6/action-download-artifact@v3
with:
run_id: ${{ github.event.workflow_run.id }}
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
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"
20 changes: 19 additions & 1 deletion .github/workflows/ci-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Unit Tests

on:
push:
branches: [main]
branches: [main, upload-test-report]

pull_request:
branches: [main]
Expand All @@ -14,6 +14,7 @@ concurrency:
# See https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
checks: write

jobs:
unit-tests:
Expand Down Expand Up @@ -41,6 +42,13 @@ jobs:
check_name: Unit Tests Summary
junit_files: junit-report.xml

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: Test Results
path: junit-report.xml

- name: Setup CODECOV_TOKEN
uses: ./.github/actions/setup-codecov

Expand All @@ -52,3 +60,13 @@ jobs:
flags: unittests
fail_ci_if_error: true
token: ${{ env.CODECOV_TOKEN }}

event-file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}

0 comments on commit e76188e

Please sign in to comment.