Unit Tests #804
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
name: Unit Tests | |
# Not running coverage on this workflow, unit tests only | |
on: | |
pull_request: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
schedule: | |
- cron: 0 7 * * 1 # 7 A.M. mon | |
concurrency: | |
group: pytest-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
tests: | |
name: ${{ matrix.toxenv }} | |
runs-on: ubuntu-latest | |
if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))" | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: Python 3.12 with devdeps and online catalogs | |
python: '3.12-dev' | |
toxenv: py312-test-devdeps-online | |
- name: Python 3.8 with old deps (online) | |
python: '3.8' | |
toxenv: py38-test-olddeps-online | |
- name: Python 3.8 with lts deps (online) | |
python: '3.8' | |
toxenv: py38-test-ltsdeps-online | |
- name: Python 3.9 with stable deps | |
python: '3.9' | |
toxenv: py39-test-stabledeps | |
- name: Python 3.10 with stable deps (online) | |
python: '3.10' | |
toxenv: py310-test-stabledeps-online | |
- name: Python 3.11 with stable deps (online) | |
python: '3.11' | |
toxenv: py311-test-stabledeps-online | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
cache: pip | |
cache-dependency-path: '**/pyproject.toml' | |
- name: Install base dependencies | |
run: | | |
python -m pip install --upgrade --quiet pip setuptools tox | |
python -c "import sys; print(f'Python {sys.version}')" | |
python -c "import pip; print(f'pip {pip.__version__}')" | |
python -c "import setuptools; print(f'setuptools {setuptools.__version__}')" | |
python -c "import tox; print(f'tox {tox.__version__}')" | |
- name: Install graphviz dependency | |
if: "endsWith(matrix.toxenv, 'build_docs')" | |
run: sudo apt-get -y install graphviz | |
- name: Cache tox environments | |
uses: actions/cache@v3 | |
with: | |
path: .tox | |
# setup.cfg and pyproject.toml have versioning info that would | |
# impact the tox environment. | |
key: ${{ github.ref }}-${{ matrix.toxenv }}-tox-${{ hashFiles('pyproject.toml') }} | |
- name: Cache astropy cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.astropy | |
# setup.cfg and pyproject.toml have versioning info that would | |
# impact the tox environment. | |
key: ${{ github.ref }}-${{ matrix.toxenv }}-astropycache | |
- name: Run tests | |
run: tox -v -e ${{ matrix.toxenv }} | |
coverage: | |
name: "Conda/Coverage/Astrometry.net" | |
runs-on: ubuntu-latest | |
if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get Date | |
id: get-date | |
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Cache conda | |
uses: actions/cache@v3 | |
with: | |
path: ~/conda_pkgs_dir | |
key: | |
${{ runner.os }}-${{ runner.arch }}-conda-${{ hashFiles('pyproject.toml') }} | |
- name: Cache env | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.CONDA }}/envs | |
key: | |
${{ github.ref }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.get-date.outputs.today }}-conda-envs-${{ hashFiles('pyproject.toml') }} | |
- uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: astropop | |
use-mamba: true | |
mamba-version: "*" | |
channels: conda-forge,defaults | |
python-version: "3.11" | |
- name: Cache astropy cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.astropy | |
# setup.cfg and pyproject.toml have versioning info that would | |
# impact the tox environment. | |
key: ${{ github.ref }}-conda-astropy | |
- name: Install dependencies | |
shell: bash -l {0} | |
run: | | |
mamba install -y -q pytest astrometry \ | |
astropy scipy numpy matplotlib \ | |
scikit-image scikit-learn \ | |
sep astroquery astroscrappy | |
pip install coveralls .[test] | |
- name: Install astropop | |
shell: bash -l {0} | |
run: pip install -U .[all] | |
- name: Print versions | |
shell: bash -l {0} | |
run: | | |
conda info | |
conda list | |
- name: Run Pytest and generate coverage | |
shell: bash -l {0} | |
run: | | |
pytest --pyargs ./tests ./docs --remote-data --cov astropop --cov-config=./pyproject.toml | |
coverage xml -o ./coverage.xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
- name: Upload coverage to Coveralls | |
shell: bash -l {0} | |
if: github.event_name != 'pull_request' | |
env: | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: coveralls | |
build_docs: | |
name: Documentation Building | |
runs-on: ubuntu-latest | |
if: "!(contains(github.event.head_commit.message, '[skip ci]') || contains(github.event.head_commit.message, '[ci skip]'))" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
cache: 'pip' | |
cache-dependency-path: '**/setup.cfg' | |
- name: Install base dependencies | |
shell: bash -l {0} | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install tox | |
python -m pip install pandoc | |
- name: Install apt-get dependency | |
shell: bash -l {0} | |
run: sudo apt-get -y install graphviz pandoc | |
- name: Print package versions | |
shell: bash -l {0} | |
run: pip list | |
- name: Cache tox environments | |
uses: actions/cache@v3 | |
with: | |
path: .tox | |
# setup.cfg and pyproject.toml have versioning info that would | |
# impact the tox environment. | |
key: build_docs-astropy-${{ hashFiles('pyproject.toml', 'setup.cfg') }} | |
- name: Run tests | |
shell: bash -l {0} | |
run: tox -v -e build_docs |