Skip to content

Coverage

Coverage #15

Workflow file for this run

# This file was generated from bswck/skeleton@0.0.2rc-112-ga5e885b.
# Instead of changing this particular file, you might want to alter the template:
# https://github.com/bswck/skeleton/tree/0.0.2rc-112-ga5e885b/project/.github/workflows/%23%25%20if%20tests%20and%20public%20%25%23coverage.yml%23%25%20endif%20%25%23.jinja
# IMPORTANT!
# Pinned versions of actions and Poetry are managed in a different repository.
# Do not submit PRs to this file unless for this repo specifically.
# To change this workflow globally, submit a PR to https://github.com/bswck/skeleton.
name: "Upload Coverage"
on:
workflow_run:
workflows: ["Tests"]
types: ["completed"]
permissions:
actions: "read"
statuses: "write"
jobs:
combine:
if: "${{github.event.workflow_run.conclusion == 'success'}}"
runs-on: "ubuntu-latest"
steps:
- name: Print github context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: "Install Poetry"
run: "pipx install poetry==1.7.1"
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
cache: "poetry"
- name: "Install the project"
run: "poetry install --only=dev,dev-skeleton"
- run: "gh run download ${{github.event.workflow_run.id}} --dir .covfiles/"
env:
GH_TOKEN: "${{github.token}}"
- run: "poetry run coverage combine --append .covfiles/*"
- run: >
poetry run coverage html
--fail-under=0
--directory=.covhtml/
--show-contexts
--title "mempip coverage for ${{github.sha}}"
- name: "Upload coverage data file"
uses: "actions/upload-artifact@v4"
with:
name: "coverage"
path: ".coverage"
- name: "Upload coverage HTML report"
uses: "actions/upload-artifact@v4"
with:
name: "coverage-html"
path: ".covhtml/"
codecov:
needs: "combine"
if: "${{github.event.workflow_run.event == 'pull_request'}}"
runs-on: "ubuntu-latest"
environment: "Upload Coverage"
steps:
- uses: "actions/checkout@v4"
- uses: "actions/download-artifact@v4"
with:
name: "coverage"
merge-multiple: true
- name: "Upload coverage reports to Codecov"
uses: "codecov/codecov-action@HEAD"
env:
CODECOV_TOKEN: "${{secrets.CODECOV_TOKEN}}"
smokeshow:
needs: "combine"
if: "${{github.event.workflow_run.head_branch == 'main'}}"
runs-on: "ubuntu-latest"
environment: "Upload Coverage"
steps:
- uses: "actions/checkout@v4"
- name: "Install Poetry"
run: "pipx install poetry==1.7.1"
- uses: "actions/setup-python@v5"
with:
cache: "poetry"
- name: "Install the project"
run: "poetry install --only=dev,dev-skeleton"
- name: "Download coverage reports"
uses: "actions/download-artifact@v4"
with:
name: "coverage-html"
path: ".covhtml/"
merge-multiple: true
- run: "poetry run smokeshow upload .covhtml/"
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: "Coverage {coverage-percentage}"
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 90
SMOKESHOW_GITHUB_CONTEXT: "coverage"
SMOKESHOW_GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
SMOKESHOW_GITHUB_PR_HEAD_SHA: "${{github.event.workflow_run.head_sha}}"
SMOKESHOW_AUTH_KEY: "${{secrets.SMOKESHOW_AUTH_KEY}}"