Skip to content

Publish Jest Results #3323

Publish Jest Results

Publish Jest Results #3323

# This workflow will publish the Jest unit test results and retain them for a period of 30 days. This also gives permission
# to forked repositories and dependabots to do write operations which are configured in this workflow.
name: Publish Jest Results
on:
workflow_run:
workflows: [buildNPM Snapshot, buildNPM Release]
types: [completed]
jobs:
publish-jest-results:
env:
JEST_JUNIT_OUTPUT_DIR: 'artifacts/jest-junit'
runs-on: ubuntu-latest
steps:
- name: Download test results artifact
if: ${{github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'push'}}
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "jest-test-results"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/jest-test-results.zip`, Buffer.from(download.data));
- name: Unzip Test Results
id: unzip-test-res
run: unzip jest-test-results.zip
- name: Publish Jest unit test results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_name: ${{ github.event.workflow_run.event }}
files: "junit.xml"
check_name: Jest Unit Test Results
comment_mode: off
comment_title: Jest Unit Test Results