Python scaffolding for traits #2866
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
| name: tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| tests: | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-24.04, macos-latest, windows-latest] | |
| python: ["3.10", "3.12"] | |
| env: | |
| CONDA_ENV_NAME: stdpopsim | |
| OS: ${{ matrix.os }} | |
| PYTHON: ${{ matrix.python }} | |
| steps: | |
| - name: cancel previous runs | |
| uses: styfle/cancel-workflow-action@0.12.1 | |
| with: | |
| access_token: ${{ github.token }} | |
| - name: checkout | |
| uses: actions/checkout@v4.2.2 | |
| - name: Cache conda and dependencies | |
| id: cache | |
| uses: actions/cache@v4.2.0 | |
| env: | |
| # Increase this to reset the cache if the key hasn't changed. | |
| CACHE_NUM: 0 | |
| with: | |
| path: ${{ env.CONDA }}/envs | |
| key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.python}}-conda-${{ env.CACHE_NUM }}-${{ hashFiles('requirements/CI/*') }} | |
| - name: Install Conda | |
| uses: conda-incubator/setup-miniconda@v3.1.0 | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| with: | |
| activate-environment: anaconda-client-env | |
| python-version: ${{ matrix.python }} | |
| channels: conda-forge | |
| channel-priority: strict | |
| auto-update-conda: true | |
| - name: Fix windows .profile | |
| if: steps.cache.outputs.cache-hit != 'true' && matrix.os == 'windows-latest' | |
| run: | | |
| cp ~/.bash_profile ~/.profile | |
| - name: Install conda deps | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| shell: bash -l {0} #We need a login shell to get conda | |
| run: | | |
| conda install --yes --file=requirements/CI/conda.txt | |
| - name: Install pip deps | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| shell: bash -l {0} | |
| run: | | |
| pip install -r requirements/CI/requirements.txt | |
| - name: run test suite | |
| run: | | |
| source ~/.profile | |
| conda activate anaconda-client-env | |
| python -m pytest \ | |
| -n 0 \ | |
| -v \ | |
| --cov=stdpopsim \ | |
| --cov-branch \ | |
| --cov-report=term-missing \ | |
| --cov-report=xml \ | |
| tests | |
| - name: upload coverage report to codecov | |
| uses: codecov/codecov-action@v5.1.1 | |
| with: | |
| fail_ci_if_error: true | |
| env_vars: OS,PYTHON | |
| # Use upload token to avoid upload failures. | |
| # https://github.com/codecov/codecov-action/issues/837 | |
| token: 8ae76ade-9d0e-4a2d-b9ef-1180235be07f |