Add test recommended in #81 #697
Workflow file for this run
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: CI | |
on: | |
push: | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
os: [windows-latest, macOS-latest, ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install oldest-supported-numpy==2023.10.25 | |
# --ignore-requires-python ensures docs deps don't break install on early python versions | |
if [ -f requirements.txt ]; then pip install --ignore-requires-python -r requirements.txt; fi | |
pip install -e . | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Test with pytest | |
run: | | |
python -m pytest | |
coverage: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.11"] | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# - name: Setup LCOV | |
# uses: hrishikesh-kadam/setup-lcov@v1 | |
- name: Install dependencies | |
run: | | |
sudo apt update -yy | |
sudo apt install -yy lcov | |
python -m pip install --upgrade pip | |
pip install wheel | |
pip install oldest-supported-numpy==2023.10.25 | |
# --ignore-requires-python ensures docs deps don't break install on early python versions | |
if [ -f requirements.txt ]; then pip install --ignore-requires-python -r requirements.txt; fi | |
rm -rf Empirical/.git | |
- name: Build phylotrackpy | |
run: | | |
make coverage | |
- name: Test with pytest | |
run: | | |
python -m pytest --cov=. --cov-report=lcov | |
lcov --output-file coverage.cpp --capture --directory . | |
lcov --output-file coverage.cpp --extract coverage.cpp "*" | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
files: "coverage.cpp, coverage.lcov, Empirical/include/emp/Evolve/Systematics.hpp" | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
needs: [] | |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Build wheels | |
uses: pypa/[email protected] | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
needs: [] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Build sdist | |
run: pipx run build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-sdist | |
path: dist/*.tar.gz | |
# Regression test borrowed from https://github.com/mmore500/hstrat/blob/ba7b19d0f0561303b6bf789d5024a323aa5993fc/.github/workflows/ci.yaml#L201 | |
packaging-sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Build sdist | |
run: | | |
python3 -m venv env | |
source env/bin/activate | |
python3 -m pip install -r requirements.txt | |
python3 setup.py sdist | |
tree dist | |
deactivate | |
- name: Upgrade pip | |
run: python3 -m pip install pip --upgrade | |
- name: Install from sdist | |
run: python3 -m pip install dist/*.tar.gz | |
- name: Test install | |
run: | | |
find . -type f -name '*.py' -exec rm {} \; | |
python3 -c "import phylotrackpy; print(phylotrackpy.__version__)" | |
upload_pypi: | |
needs: [build_wheels, build_sdist, test] | |
runs-on: ubuntu-latest | |
environment: pypi | |
permissions: | |
id-token: write | |
# upload to PyPI on every tag starting with 'v' | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
# alternatively, to publish when a GitHub Release is created, use the following rule: | |
# if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
# unpacks default artifact into dist/ | |
# if `name: artifact` is omitted, the action will create extra parent dir | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
paper: | |
runs-on: ubuntu-latest | |
name: Paper Draft | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build draft PDF | |
uses: openjournals/openjournals-draft-action@master | |
with: | |
journal: joss | |
# This should be the path to the paper within your repo. | |
paper-path: joss/paper.md | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: paper | |
# This is the output path where Pandoc will write the compiled | |
# PDF. Note, this should be the same directory as the input | |
# paper.md | |
path: joss/paper.pdf |