Add attentions and apply minor fixes #7
This file contains hidden or 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
# Conda w/ GitHub Actions | |
# https://autobencoder.com/2020-08-24-conda-actions/ | |
name: Conda Test | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ '*' ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
# https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
# Cache to save build time | |
# https://github.com/marketplace/actions/setup-miniconda#caching | |
- name: Cache conda | |
uses: actions/cache@v2 | |
env: | |
# Increase this value to reset cache if etc/example-environment.yml has not changed | |
CACHE_NUMBER: 0 | |
with: | |
path: ~/conda_pkgs_dir | |
key: | |
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ | |
hashFiles('environment.yml') }} | |
- uses: conda-incubator/setup-miniconda@v2 | |
with: | |
activate-environment: anaconda-client-env | |
channel-priority: strict | |
environment-file: environment.yml | |
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly | |
# setup a Miniconda variant without specifying a environment file | |
- name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: anaconda-client-env | |
use-mamba: true | |
- name: Install Extra Python dependencies | |
run: | | |
conda activate anaconda-client-env | |
mamba install --name anaconda-client-env pytest | |
- name: Set Python Path | |
run: conda env config vars set PYTHONPATH=$(pwd):$(pwd)/src | |
# refresh the cache every 24 hours to avoid inconsistencies of package versions | |
- name: Get Date | |
id: get-date | |
run: echo "::set-output name=today::$(/bin/date -u '+%Y%m%d')" | |
shell: bash | |
- name: Cache Conda env | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.CONDA }}/envs | |
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ steps.get-date.outputs.today }}-${{ hashFiles('environment.yml') }}-${{ env.CACHE_NUMBER }} | |
env: | |
# Increase this value to reset cache if etc/example-environment.yml has not changed | |
CACHE_NUMBER: 0 | |
id: cache | |
# Finally, update the environment based on the environment file if the cache does not exist. | |
- name: Update environment | |
run: | | |
mamba env update -n anaconda-client-env -f environment.yml | |
mamba install --name anaconda-client-env pytest | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Test with pytest | |
run: | | |
conda activate anaconda-client-env | |
python -m pytest tests/ |