forked from getpelican/pelican
-
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.
- Loading branch information
Showing
2 changed files
with
83 additions
and
9 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 |
---|---|---|
|
@@ -14,13 +14,18 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
os: [ubuntu, macos, windows] | ||
python: ["3.10", "3.11", "3.12"] | ||
include: | ||
- os: ubuntu | ||
python: "3.8" | ||
- os: ubuntu | ||
python: "3.9" | ||
# TODO: implement windows | ||
# os: [ubuntu, macos, windows] | ||
os: [ubuntu] | ||
# TODO: put back 3.11, 3.12 | ||
# python: ["3.10", "3.11", "3.12"] | ||
python: ["3.10"] | ||
# TODO: put back 3.8, 3.9 | ||
# include: | ||
# - os: ubuntu | ||
# python: "3.8" | ||
# - os: ubuntu | ||
# python: "3.9" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -39,14 +44,47 @@ jobs: | |
pandoc-version: "2.9.2" | ||
- name: Install tox | ||
run: python -m pip install -U pip tox | ||
- name: Set up dependencies with invoke | ||
if: runner.os != 'Windows' | ||
run: | | ||
# our tasks.py wants a virtualenv | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
echo $VIRTUAL_ENV | ||
which python | ||
python -m pip install invoke | ||
python -m invoke setup | ||
- name: Info | ||
run: | | ||
echo "===== PYTHON =====" | ||
python --version | ||
echo "===== PANDOC =====" | ||
pandoc --version | head -2 | ||
- name: Run tests | ||
run: tox -e py${{ matrix.python }} | ||
- name: Run tests with coverage | ||
if: runner.os != 'Windows' | ||
run: | | ||
source .venv/bin/activate | ||
python -m coverage run pytest_all.py | ||
ls -l .coverage.* | ||
env: | ||
# control the filename to avoid issues with uploading | ||
# see also https://github.com/actions/upload-artifact/issues/478#issuecomment-2096976037 | ||
COVERAGE_FILE: .coverage.${{ matrix.os }}.${{ matrix.python }}.${{ github.event_name }} | ||
|
||
- name: Upload coverage data | ||
uses: "actions/upload-artifact@v4" | ||
with: | ||
name: coverage-data | ||
path: ".coverage.${{ matrix.os }}.${{ matrix.python }}.${{ github.event_name }}" | ||
if-no-files-found: error | ||
|
||
# see https://github.com/actions/upload-artifact/blob/main/merge/README.md#combining-all-artifacts-in-a-workflow-run | ||
merge: | ||
runs-on: ubuntu-latest | ||
needs: upload | ||
steps: | ||
- name: Merge Artifacts | ||
uses: actions/upload-artifact/merge@v4 | ||
|
||
lint: | ||
name: Lint | ||
|
@@ -66,6 +104,32 @@ jobs: | |
- name: Run pre-commit checks on all files | ||
uses: pre-commit/[email protected] | ||
|
||
coverage: | ||
runs-on: "ubuntu-latest" | ||
needs: merge | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
cache: "pip" | ||
cache-dependency-path: "**/requirements/*" | ||
|
||
- name: "Install Coverage.py" | ||
run: "python -m pip install --upgrade coverage[toml]" | ||
|
||
- name: "Download coverage data" | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage-data | ||
|
||
- name: "Combine & check coverage" | ||
run: | | ||
set -xe | ||
python -m coverage combine | ||
python -m coverage report --fail-under=74 | ||
build: | ||
name: Test build | ||
runs-on: ubuntu-latest | ||
|
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,10 @@ | ||
""" | ||
Discover and run all tests in the current directory and subdirectories. | ||
This is useful to run coverage on tests across environments. | ||
""" | ||
|
||
import pytest | ||
|
||
if __name__ == "__main__": | ||
pytest.main() |