Skip to content

Commit

Permalink
Add coverage comment workflow action
Browse files Browse the repository at this point in the history
  • Loading branch information
annshress committed Sep 8, 2023
1 parent 6a41fbb commit 17d9737
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 24 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[run]
source = em_workflows
relative_files = true
omit =
# Omit test code
test/*,
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Post coverage comment

on:
workflow_run:
workflows: ["main"]
types:
- completed

jobs:
comment:
name: Run tests & display coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
# Gives the action the necessary permissions for looking up the
# workflow that launched this workflow, and download the related
# artifact that contains the comment to be published
actions: read
steps:

- name: Post comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
49 changes: 26 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
jobs:
docs:
runs-on: ubuntu-latest
name: Docs
needs: test
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -52,6 +53,15 @@ jobs:

test:
runs-on: ubuntu-latest
name: Check coverage
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
strategy:
matrix:
python-version: ["3.8"]
Expand Down Expand Up @@ -79,30 +89,9 @@ jobs:
- name: Git LFS Pull
run: |
git lfs pull
# - name: IMOD Container Build
# id: docker-build-imod
# env:
# DOCKERFILE_PATH: utils/imod/
# run: |
# docker build -t imod $DOCKERFILE_PATH
# - name: IMOD Container Test
# run: |
# docker run imod dm2mrc -h
# - name: Graphicsmagick Container Build
# id: docker-build-graphicsmagick
# env:
# DOCKERFILE_PATH: utils/graphicsmagick/
# run: |
# docker build -t graphicsmagick $DOCKERFILE_PATH
# - name: Graphicsmagick Container Test
# run: |
# docker run graphicsmagick gm -version
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt -y update && sudo apt -y install libgl-dev graphicsmagick libblosc1
IMOD=imod_4.11.24_RHEL7-64_CUDA10.1.sh
export IMOD_DIR=/usr/local/IMOD
export PATH=$IMOD_DIR/bin:$PATH
Expand All @@ -114,7 +103,6 @@ jobs:
wget https://github.com/glencoesoftware/bioformats2raw/releases/download/v${BIO2R_V}/${BIO2R_Z} && sudo unzip ${BIO2R_Z} -d ${BIO2R_DIR} && rm -f ${BIO2R_Z}
python -m pip install --upgrade pip
pip install -e . -r requirements.txt
sudo apt -y update && sudo apt -y install libgl-dev graphicsmagick libblosc1
- name: Test Coverage
continue-on-error: true
Expand All @@ -127,3 +115,18 @@ jobs:
- name: Coverage Badge
uses: tj-actions/coverage-badge-py@v2

- name: Coverage comment
id: coverage_comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}

- name: Store Pull Request comment to be posted
uses: actions/upload-artifact@v3
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt
6 changes: 5 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ env =
HEDWIG_ENV=dev
USER=test

addopts = --strict-markers
addopts =
--cov-report term-missing --cov-branch --cov-report xml --cov-report term
--cov=em_workflows -vv
--strict-markers -rfE

markers =
slow: mark test as long-running
localdata: test data not always available

0 comments on commit 17d9737

Please sign in to comment.