Skip to content

Tests

Tests #277

Workflow file for this run

# GitHub Actions workflow for photometry's continuous integration.
name: Tests
on:
push:
branches: [master, devel]
tags: 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [master, devel]
schedule:
- cron: '0 6 1 * *' # once a month in the morning
# Change default shell to bash for all OS:
defaults:
run:
shell: bash
# Avoid random build errors caused by the use of "sklearn" instead of "scikit-learn"
# in dependenices (e.g. k2sc).
# https://github.com/scikit-learn/sklearn-pypi-package
env:
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: True
jobs:
# Use the `flake8` tool to check for syntax errors
flake8:
name: Flake8
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
grep "^numpy" requirements.txt | xargs -I {} pip install "{}"
pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
# For some reason we have to specifically ignore G001 as well
flake8 --select=E9,F63,F7,F82 --ignore=G001 --show-source
# exit-zero treats all errors as warnings.
flake8 --exit-zero
# Run unit tests on Linux, OSX and Windows
pytest:
needs: flake8
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
exclude:
- os: windows-latest
python-version: '3.10'
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: false
- name: Setup ffmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
id: setup-ffmpeg
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
grep "^numpy" requirements.txt | xargs -I {} pip install "{}"
pip install -r requirements.txt
- name: Setup MPI
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y openmpi-bin libopenmpi-dev
pip install mpi4py
- name: Download cache
run: coverage run run_download_cache.py -q --testing
- name: Testing
run: pytest --cov --cov-append --cov-report xml --cov-report term
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
files: coverage.xml
env_vars: OS,PYTHON
# Use sphinx to build the documentation
docs:
name: Build documentation
needs: flake8
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
lfs: false
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
grep "^numpy" requirements.txt | xargs -I {} pip install "{}"
pip install -r requirements.txt
pip install -r docs/requirements-docs.txt
- name: Build Sphinx documentation
run: |
sphinx-build -a -W --no-color -b html -d docs/_build/doctrees docs docs/_build/html
#- name: Sphinx coverage
# run: |
# sphinx-build -a -W --no-color -b coverage -d docs/_build/doctrees docs docs/_build/coverage
# Release tagged commits to:
release:
name: Create release
if: startsWith( github.ref, 'refs/tags/v' )
needs: [pytest, docs]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: false
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v3
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
grep "^numpy" requirements.txt | xargs -I {} pip install "{}"
pip install -r requirements.txt
- name: Update VERSION file
run: python -c "from photometry import version; version.update_release_version();"
- name: Set env
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/v}
- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v3.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Version ${{ steps.vars.outputs.tag }}
body: |
Version ${{ steps.vars.outputs.tag }}
Changelog
---------
${{ steps.changelog.outputs.changelog }}
draft: true