fix CI and lint #409
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: TestCode | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'pyproject.toml' | |
- '**.py' | |
- '.github/workflows/runtests.yml' | |
env: | |
# used to manually trigger cache reset. Just increment if needed. | |
CACHE_NUMBER: 1 | |
# Cancel previous runs when this one starts. | |
concurrency: | |
group: TestCode-${{ github.event.pull_request.number || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
# Runs the tests on combinations of the supported python/os matrix. | |
test_code: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
# only run if CI isn't turned off | |
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci') | |
env: | |
# set path of test environment for caching | |
prefix: ${{ startsWith(matrix.os, 'ubuntu') && '/usr/share/miniconda3/envs/dascore' | |
|| startsWith(matrix.os, 'macos') && '/Users/runner/miniconda3/envs/dascore' | |
|| startsWith(matrix.os, 'windows') && 'C:\Miniconda3\envs\dascore' }} | |
# set individual cache key (only the start of it) | |
cache_key: ${{ matrix.os }}-py${{ matrix.python-version }} | |
# set conda environment file with dependencies | |
env_file: ".github/test_conda_env.yml" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # need this so tags are pulled and versions work | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
micromamba-version: '2.0.2-2' # versions: https://github.com/mamba-org/micromamba-releases | |
environment-file: '.github/test_conda_env.yml' | |
init-shell: >- | |
bash | |
powershell | |
cache-environment: true | |
post-cleanup: 'all' | |
# Not sure why this is needed but it appears to be the case | |
- name: fix env | |
shell: bash -l {0} | |
run: | | |
micromamba shell init --shell bash --root-prefix=~/micromamba | |
eval "$(micromamba shell hook --shell bash)" | |
micromamba activate test | |
- name: install obsplus | |
shell: bash -l {0} | |
run: | | |
python -m pip install -e .[test] | |
# Print out the package info for current environment | |
- name: print package info | |
shell: bash -el {0} | |
run: | | |
micromamba info | |
micromamba list | |
- name: download test data | |
shell: bash -l {0} | |
run: | | |
if [ ! -d ~/opsdata ]; then | |
git clone https://github.com/d-chambers/opsdata_test | |
mv opsdata_test ~/opsdata | |
fi | |
# Runs test suite and calculates coverage | |
- name: run test suite | |
shell: bash -l {0} | |
run: | | |
pytest -s --cov obsplus --cov-append --cov-report=xml | |
# Runs examples in docstrings | |
- name: test docstrings | |
shell: bash -l {0} | |
run: | | |
pytest src --doctest-modules | |
# Runs the documentation notebooks | |
- name: test notebook docs | |
shell: bash -l {0} | |
run: | | |
pytest docs --nbval | |
# upload coverage | |
- name: upload coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
name: PR_tests | |
fail_ci_if_error: false | |
# This is a very useful step for debugging, it allows you to ssh into the CI | |
# machine (https://github.com/marketplace/actions/debugging-with-tmate). | |
# Make sure to open the log before the job starts else you cant see the tmate | |
# url. See https://github.com/mxschmitt/action-tmate/issues/1. | |
# Also, the CI machine will close on a non-zero exit code (annoying). This can | |
# be overcome by coalescing the null command like so: | |
# $ some-command-that-can-fail || : | |
# | |
#- name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 |