Skip to content

Commit

Permalink
Publish code coverage on CodeClimate
Browse files Browse the repository at this point in the history
  • Loading branch information
arichr committed Mar 2, 2024
1 parent 2107553 commit 8afc293
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 13 deletions.
55 changes: 43 additions & 12 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ jobs:
with:
python-version: "3.10"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
run: poetry install --with=ci --without=docs --no-interaction --no-root

test:
runs-on: ubuntu-latest
Expand All @@ -58,15 +59,45 @@ jobs:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Testing
- name: Linting
run: |
source .venv/bin/activate
pytest
ruff check . --output-format=full
- name: Linting
coverage:
runs-on: ubuntu-latest
needs: test
concurrency:
group: "coverage"
cancel-in-progress: true
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}

steps:
- uses: actions/checkout@v3
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}

- name: Testing
run: |
source .venv/bin/activate
ruff check . --output-format=full
MODULE_DIR=$(dirname "$(ls */__init__.py)")
coverage run --source "$MODULE_DIR" -m pytest
coverage report --skip-covered --fail-under=80
coverage xml --ignore-errors
- name: Publish code coverage
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageLocations: coverage.xml:coverage.py

build:
runs-on: ubuntu-latest
needs: test
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ node_modules/
dist/
venv/

# Code coverage
.coverage
coverage.xml

# Build artifacts
site/
build/
Expand Down
66 changes: 65 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ mkdocs-material = "^9.5.12"
mkdocstrings = {extras = ["python"], version = "^0.24.1"}
mkdocs-git-authors-plugin = "^0.7.2"

[tool.poetry.group.ci.dependencies]
coverage = "^7.4.3"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 8afc293

Please sign in to comment.