Skip to content

Merge pull request #80 from lycosystem/release-1.0.1 #71

Merge pull request #80 from lycosystem/release-1.0.1

Merge pull request #80 from lycosystem/release-1.0.1 #71

Workflow file for this run

name: tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
tests:
name: Run tests & report coverage
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[tests]
# Below, we first run pytest in the `tests/` folder. Because we use a `src`
# layout, this will fail if the package is not installed correctly.
- name: Test package is installable
run: pytest --cov=lyscripts --cov-config=pyproject.toml tests
env:
COVERAGE_FILE: .coverage.is_installable
# Now, we execute all doctests in the `src` tree. This will NOT run with
# the installed code, but it doesn't matter, because we already know it is
# installable from the step above.
- name: Run doctests
if: success() || failure() # run these even if previous step fails
run: pytest --cov=lyscripts --cov-config=pyproject.toml --doctest-modules src
env:
COVERAGE_FILE: .coverage.doctests
GITHUB_TOKEN: ${{ secrets.LYCOSYSTEM_READALL }}
# Lastly, we collect all files that start with `.coverage` into one file and
# create a report either as a comment on the PR or in a separate branch if its
# a commit to the main branch. From that branch we can put badges and coverage
# reports into e.g. our main README.md
- name: Add coverage comment
if: success() || failure() # run these even if previous step fails
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MERGE_COVERAGE_FILES: true