fix_229 #593
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
# Run full test suite using conda env and all optional deps. | |
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: | |
timeout-minutes: 25 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
python-version: ['3.10', '3.11'] | |
# 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: "environment.yml" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get year week | |
id: date | |
run: echo "date=$(date +'%Y:%U')" >> $GITHUB_STATE | |
- name: setup conda env | |
uses: conda-incubator/[email protected] | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: dascore | |
use-mamba: true | |
python-version: ${{ matrix.python-version }} | |
- name: Cache conda env | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.prefix }} | |
key: ${{ env.cache_key }}-hash${{ hashFiles(env.env_file) }}-${{ steps.date.outputs.date }}-${{ env.CACHE_NUMBER }} | |
id: cache | |
- name: Update environment | |
run: mamba env update -n test -f ${{ env.env_file }} | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: install dascore | |
shell: bash -l {0} | |
run: | | |
python -m pip install -e .[test,all] | |
- name: set data cache path | |
shell: bash -l {0} | |
run: | | |
echo "DATA_CACHE_PATH=$(python -c "import pooch; print(pooch.os_cache('dascore'))")" >> $GITHUB_ENV | |
- name: cache test data | |
uses: actions/cache@v3 | |
with: | |
enableCrossOsArchive: true | |
path: ${{ env.DATA_CACHE_PATH }} | |
key: DATA_${{ env.CACHE_NUMBER }} | |
- name: print package info | |
shell: bash -l {0} | |
run: | | |
conda info -a | |
conda list | |
# Runs test suite and calculates coverage | |
- name: run test suite | |
shell: bash -l {0} | |
run: | | |
pytest -s --cov dascore --cov-append --cov-report=xml | |
# Runs examples in docstrings | |
- name: test docstrings | |
shell: bash -l {0} | |
run: | | |
pytest dascore --doctest-modules | |
# 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). | |
# | |
#- name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 |