-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Combine GitHub actions test runs into a single ci file Setting the groundwork to add a coverage report to Cladetime. We'll want to run integration tests and unit tests at the same time to get a full report of test coverage, so do that (but not on every push). * Add test coverage check and report The coverage job will fail if if code coverage is >= 80% * Add status badge for the CI workflow This doesn't give us an actual coverage percentage, but a successful workflow run does mean that coverage is at or above the stated minimum (in this case 80%, to match Hubverse standards). * Rename run-code-checks to ci This is a common pattern I've seen when looking at other python projects (and also, the workflow does more than run tests now) * Also run CI workflow on merge to main branch * Fix typo
- Loading branch information
Showing
4 changed files
with
100 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
FORCE_COLOR: "1" | ||
PIP_DISABLE_PIP_VERSION_CHECK: "1" | ||
PIP_NO_PYTHON_VERSION_WARNING: "1" | ||
|
||
jobs: | ||
run-checks: | ||
name: Run linter and tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 🐍 | ||
uses: actions/setup-python@v5 | ||
with: | ||
cache: pip | ||
|
||
- name: Install dependencies 📦️ | ||
run: | | ||
pip install --upgrade pip | ||
pip install -r requirements/requirements-dev.txt | ||
pip install -e . | ||
- name: Lint 🧹 | ||
run: ruff check | ||
|
||
- name: Run tests 🧪 | ||
run: | | ||
pip install --upgrade pip | ||
pip install -r requirements/requirements-dev.txt | ||
pip install -e . | ||
coverage run -m pytest | ||
- name: Upload coverage data 📤 | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: coverage | ||
path: .coverage | ||
include-hidden-files: true | ||
if-no-files-found: ignore | ||
|
||
coverage: | ||
# https://hynek.me/articles/ditch-codecov-python/ | ||
name: Generate coverage report | ||
runs-on: ubuntu-latest | ||
needs: run-checks | ||
if: always() | ||
|
||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Set up Python 🐍 | ||
uses: actions/setup-python@v5 | ||
with: | ||
cache: pip | ||
|
||
- name: Install uv 🌟 | ||
uses: astral-sh/setup-uv@v5 | ||
with: | ||
version: ">=0.0.1" | ||
|
||
- name: Download coverage data 📥 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage | ||
merge-multiple: true | ||
|
||
- name: Generate coverage report 📊 | ||
run: | | ||
uv tool install coverage | ||
coverage html --skip-covered --skip-empty | ||
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | ||
# Generate report again, this time with a fail-under threshold | ||
coverage report --fail-under=80 | ||
- name: Upload HTML report if coverage check fails | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: html-cov-report | ||
path: htmlcov | ||
if: ${{ failure() }} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters