Move almost everything to pyproject.toml #29
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: Tests | |
on: | |
push: | |
branches: "*" | |
paths-ignore: | |
- 'docs/**' | |
pull_request: | |
branches: master | |
paths-ignore: | |
- 'docs/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
PYTEST_ADDOPTS: "--color=yes" | |
# This is a pretty complicated workflow. The reason it is this way is that it | |
# has been optimized to go fast fast. The specific optimizations are | |
# | |
# ## Environment building and caching ("prepare-env" job) | |
# | |
# This step builds and caches the test environments using conda. | |
# If there is no cache, building each environment takes 3-4 minutes. | |
# If there is a cache this step should take about 40 seconds. | |
# (The time needed to install conda and check the cache.) | |
# | |
# The cache key is as follows: | |
# ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles( env.env_file ) }}-${{ env.CACHE_NUMBER }} | |
# | |
# A key parameter env.CACHE_NUMBER. This is a number that is set based on the current date: | |
# CACHE_NUMBER=`expr $(date +'%j') / 3` | |
# This is designed such that the cached environment will be reused for maximum 3 days. | |
# After 3 days, the CACHE_NUMBER will increment, forcing a new environment to be built. | |
# This cadence was chosen as a balance between making the tests go fast | |
# (avoiding rebuilding environments every run), and using a fresh, recent environment. | |
# | |
# The test environment is cached in /usr/share/miniconda3/envs/pangeo-forge-recipes | |
# | |
# ## Running the tests ("run-tests" job) | |
# | |
# This step does not even attempt to build environments. It just loads them from the cache. | |
# Then it adds the following path to $PATH | |
# /usr/share/miniconda3/envs/pangeo-forge-recipes/bin | |
# | |
# We use pytest marks to parallelize execution across the different executors. | |
# These marks are configured in tests/conftest.py | |
jobs: | |
prepare-env: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.8, 3.9] | |
dependencies: ["releases-only", "upstream-dev"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: π Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: x64 | |
- name: π Setup Miniconda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: pangeo-forge-recipes | |
use-mamba: true | |
- name: π― Set cache number | |
id: cache-number | |
# cache will last 3 days by default | |
run: echo CACHE_NUMBER=`expr $(date +'%j') / 3` >> $GITHUB_ENV | |
- name: π― Set environment file | |
id: env-file | |
run: echo "env_file=ci/py${{ matrix.python-version }}.yml" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: π Cache environment | |
with: | |
path: /usr/share/miniconda3/envs/pangeo-forge-recipes | |
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles( env.env_file ) }}-${{ matrix.dependencies }}-${{ env.CACHE_NUMBER }} | |
id: conda-cache | |
- name: π« Maybe Update environment | |
if: steps.conda-cache.outputs.cache-hit != 'true' | |
run: mamba env update -n pangeo-forge-recipes -f ${{ env.env_file }} | |
- name: π§βπ» Maybe update to upstream dev versions | |
if: matrix.dependencies == 'upstream-dev' | |
run: mamba env update -n pangeo-forge-recipes -f ci/upstream-dev.yml | |
- name: π List conda env | |
run: | | |
conda info | |
conda list | |
run-tests: | |
needs: prepare-env | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.8, 3.9] | |
dependencies: ["releases-only", "upstream-dev"] | |
pytest-mark: ["no_executor", "executor_function", "executor_generator", | |
"executor_dask", "executor_prefect", "executor_prefect_dask", | |
"executor_prefect_wrapper", "executor_beam"] | |
exclude: | |
- dependencies: "upstream-dev" | |
pytest-mark: "executor_function" | |
- dependencies: "upstream-dev" | |
pytest-mark: "executor_generator" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: π― Set cache number | |
id: cache-number | |
# cache will last 3 days by default | |
run: echo CACHE_NUMBER=`expr $(date +'%j') / 3` >> $GITHUB_ENV | |
- name: π― Set environment file | |
id: env-file | |
run: echo "env_file=ci/py${{ matrix.python-version }}.yml" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: π Loaded Cached environment | |
with: | |
path: /usr/share/miniconda3/envs/pangeo-forge-recipes | |
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ hashFiles( env.env_file ) }}-${{ matrix.dependencies }}-${{ env.CACHE_NUMBER }} | |
id: conda-cache | |
- name: π€Ώ Bail out if no cache hit | |
if: steps.conda-cache.outputs.cache-hit != 'true' | |
run: false | |
- name: π― Set path to include conda python | |
run: echo "/usr/share/miniconda3/envs/pangeo-forge-recipes/bin" >> $GITHUB_PATH | |
- name: π Install pangeo-forge-recipes package | |
run: | | |
python -m pip install --no-deps -e . | |
- name: πββοΈ Run Tests | |
run: | | |
pytest tests -v -m ${{ matrix.pytest-mark }} \ | |
--cov=pangeo_forge_recipes --cov-config .coveragerc \ | |
--cov-report term-missing \ | |
--cov-report xml \ | |
--durations=10 --durations-min=1.0 | |
- name: π¦ Run Codecov | |
uses: codecov/[email protected] | |
with: | |
file: ./coverage.xml | |
env_vars: OS,PYTHON | |
name: codecov-umbrella | |
fail_ci_if_error: false |