Unittest #1168
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: Unittest | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: '0 2 * * 1' # every Monday at 2:00am | |
env: | |
CACHE_NUMBER: 0 # increase to reset cache manually | |
jobs: | |
build-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Setup Mambaforge | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
activate-environment: ceasiompy | |
use-mamba: true | |
- name: Set cache date # With that, cache will be updated every day | |
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
path: /usr/share/miniconda3/envs/ceasiompy | |
key: ubuntu-latest-conda-${{ env.DATE }}-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} | |
id: cache | |
- name: Update environment | |
run: mamba env update -n ceasiompy -f environment.yml | |
if: steps.cache.outputs.cache-hit != 'true' | |
- name: Install ceasiompy with pip | |
shell: bash -l {0} | |
run: pip install -e . | |
- name: Run unit tests | |
shell: bash -l {0} | |
run: pytest -v ./ceasiompy --cov=ceasiompy/ --cov-report xml:coverage.xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3.1.0 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ./coverage.xml | |
flags: unittests | |
fail_ci_if_error: true | |
verbose: true |