Skip to content

Commit

Permalink
ci: Add privileged workflows to display coverage reports in PRs from …
Browse files Browse the repository at this point in the history
…fork
  • Loading branch information
thomass-dev committed Dec 26, 2024
1 parent 469d1e5 commit 74f7894
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/pr-display-backend-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# THIS
# IS
# DOCUMENTATION
# TRIGGERED WORKFLOW

name: display backend coverage in PR

on:
workflow_run:
workflows: [backend]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
acquire-pr-number:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
PR_NUMBER: ${{ steps.acquire-pr-number.outputs.number }}
permissions:
contents: read
steps:
- id: acquire-pr-number
run: gh pr view --repo "${REPOSITORY}" "${BRANCH}" --json 'number' --jq '"number=\(.number)"' >> "${GITHUB_OUTPUT}"
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
BRANCH: |-
${{
(github.event.workflow_run.head_repository.fork == true)
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
|| github.event.workflow_run.head_branch
}}
display-backend-coverage:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
needs: [acquire-pr-number]
permissions:
pull-requests: write
steps:
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: backend-coverage
path: coverage/
- name: Display coverage reports
uses: MishaKav/pytest-coverage-comment@main
with:
issue-number: ${{ needs.acquire-pr-number.outputs.PR_NUMBER }}
pytest-coverage-path: coverage/coverage.txt
junitxml-path: coverage/coverage.xml
title: backend coverage report
56 changes: 56 additions & 0 deletions .github/workflows/pr-display-frontend-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# THIS
# IS
# DOCUMENTATION
# TRIGGERED WORKFLOW

name: display frontend coverage in PR

on:
workflow_run:
workflows: [frontend]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
acquire-pr-number:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
outputs:
PR_NUMBER: ${{ steps.acquire-pr-number.outputs.number }}
permissions:
contents: read
steps:
- id: acquire-pr-number
run: gh pr view --repo "${REPOSITORY}" "${BRANCH}" --json 'number' --jq '"number=\(.number)"' >> "${GITHUB_OUTPUT}"
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
BRANCH: |-
${{
(github.event.workflow_run.head_repository.fork == true)
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch)
|| github.event.workflow_run.head_branch
}}
display-frontend-coverage:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
needs: [acquire-pr-number]
permissions:
pull-requests: write
steps:
- name: Download coverage reports
uses: actions/download-artifact@v4
with:
name: frontend-coverage
path: coverage/
- name: Display coverage reports
uses: davelosert/vitest-coverage-report-action@v2
with:
pr-number: ${{ needs.acquire-pr-number.outputs.PR_NUMBER }}
name: frontend coverage report

0 comments on commit 74f7894

Please sign in to comment.