Skip to content

Commit

Permalink
Merge pull request #10 from VCTLabs/ci-coverage
Browse files Browse the repository at this point in the history
coverage take 2, use clean fork
  • Loading branch information
bakert authored Nov 24, 2021
2 parents e71b777 + f59653b commit 0b05298
Showing 1 changed file with 43 additions and 12 deletions.
55 changes: 43 additions & 12 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
# internal coverage PR comment and badge v0.0.2
# internal coverage PR comment and badge v0.0.3
# needs separate jobs for coverage checkout/run and PR coverage report comment
# badge and comment job logic should be tuned for personal vs org use
# (see badge job comments below)
name: Coverage

on:
workflow_dispatch:
pull_request:
pull_request_target:
types:
- opened
- synchronize
- reopened
push:
branches:
- master

## This workflow needs the `pull-request` permissions to work
## Refs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions
permissions:
pull-requests: write
contents: read

jobs:
pre_ci:
name: Prepare CI environment
Expand All @@ -22,8 +33,8 @@ jobs:
- name: Checkout Project
uses: actions/checkout@v2
with:
# We need to fetch with a depth of 2 for pull_request so we can do HEAD^2
fetch-depth: 2
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Environment
run: |
Expand All @@ -34,7 +45,7 @@ jobs:
env:
COMMIT_PUSH: ${{ github.event.head_commit.message }}
run: |
COMMIT_MESSAGE="${COMMIT_PUSH:-$(git log --format=%B -n 1 HEAD^2)}"
COMMIT_MESSAGE="${COMMIT_PUSH:-$(git log --format=%B -n 1 HEAD)}"
echo "::set-output name=commit_message::${COMMIT_MESSAGE}"
- name: Extract branch name
Expand Down Expand Up @@ -130,7 +141,9 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}


- uses: actions/setup-python@v2
with:
Expand All @@ -143,7 +156,7 @@ jobs:
- name: Generate coverage and fix pkg name
run: |
tox
tox -e py39-linux
- name: Code Coverage Summary Report (Text & Value)
uses: irongut/CodeCoverageSummary@v1.0.5
Expand All @@ -168,13 +181,30 @@ jobs:
format: 'markdown'
output: 'both'

- name: Upload coverage results for comment
uses: actions/upload-artifact@v2
with:
name: pr-coverage
path: code-coverage-results.md
retention-days: 1

comment_cov_report:
name: Comment on PR with coverage summary report
runs-on: ubuntu-20.04
needs: [cov_data, base]

steps:
# artifact downloaded to directory: (upload)name/file
- uses: actions/download-artifact@v2

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2.1.1
uses: marocchino/sticky-pull-request-comment@v2.2.0
if: ${{ github.event_name == 'pull_request' }}
with:
header: coverage
recreate: true
path: code-coverage-results.md
path: pr-coverage/code-coverage-results.md
hide_and_recreate: true
hide_classify: "OUTDATED"

test:
name: Coverage check
Expand Down Expand Up @@ -258,12 +288,13 @@ jobs:
fi
- name: Comment PR with test coverage delta
uses: marocchino/sticky-pull-request-comment@v2.1.1
uses: marocchino/sticky-pull-request-comment@v2.2.0
if: env.HAVE_BASE_COVERAGE == 'true'
with:
header: delta
recreate: true
path: coverage-delta.md
hide_and_recreate: true
hide_classify: "OUTDATED"

badge:
# Only generate and publish if these conditions are met:
Expand Down

0 comments on commit 0b05298

Please sign in to comment.