Skip to content

PR Reports

PR Reports #57

Workflow file for this run

name: PR Reports
on:
workflow_run:
workflows: ['PR Validation']
types: [completed]
permissions:
checks: write
pull-requests: write
actions: read
jobs:
# Check all artifacts in a single job to reduce API calls
check-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled'
outputs:
has-test-results: ${{ steps.check.outputs.test-results }}
has-eslint-results: ${{ steps.check.outputs.eslint-results }}
has-webpack-stats: ${{ steps.check.outputs.webpack-stats }}
steps:
- name: Check for all artifacts
id: check
uses: actions/github-script@v8
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id
});
const hasTestResults = artifacts.data.artifacts.some(a => a.name === 'test-results');
const hasEslintResults = artifacts.data.artifacts.some(a => a.name === 'eslint-results');
const hasWebpackStats = artifacts.data.artifacts.some(a => a.name === 'webpack-stats');
console.log(`Test results: ${hasTestResults ? '✅' : '❌'}`);
console.log(`ESLint results: ${hasEslintResults ? '✅' : '❌'}`);
console.log(`Webpack stats: ${hasWebpackStats ? '✅' : '❌'}`);
core.setOutput('test-results', hasTestResults);
core.setOutput('eslint-results', hasEslintResults);
core.setOutput('webpack-stats', hasWebpackStats);
test-report:
needs: check-artifacts
runs-on: ubuntu-latest
timeout-minutes: 10
if: needs.check-artifacts.outputs.has-test-results == 'true'
steps:
- name: Download test results
uses: actions/download-artifact@v7
with:
name: test-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Publish test report
uses: dorny/test-reporter@v2
with:
artifact: test-results
name: JEST Tests
path: '*.xml'
reporter: jest-junit
eslint-annotate:
needs: check-artifacts
runs-on: ubuntu-latest
timeout-minutes: 10
if: needs.check-artifacts.outputs.has-eslint-results == 'true'
steps:
- name: Download ESLint results
uses: actions/download-artifact@v7
with:
name: eslint-results
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Annotate ESLint results
uses: ataylorme/eslint-annotate-action@v3
with:
report-json: eslint.results.json
fail-on-error: false
fail-on-warning: false
bundle-analysis:
needs: check-artifacts
runs-on: ubuntu-latest
timeout-minutes: 10
if: needs.check-artifacts.outputs.has-webpack-stats == 'true' && github.event.workflow_run.conclusion == 'success'
steps:
- name: Download webpack stats
uses: actions/download-artifact@v7
with:
name: webpack-stats
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to RelativeCI
uses: relative-ci/agent-action@v3
with:
key: ${{ secrets.RELATIVE_CI_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}
artifactName: webpack-stats
webpackStatsFile: ./webpack-stats.json