Full test suite #647
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: Full test suite | |
| on: | |
| push: | |
| pull_request: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| # Add concurrency to prevent redundant workflow runs | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| # Explicitly define permissions (principle of least privilege) | |
| permissions: | |
| contents: read | |
| # Add additional permissions only as needed | |
| checks: write # For test results | |
| pull-requests: write # For PR comments | |
| jobs: | |
| run_tests: | |
| runs-on: ${{ matrix.os }} | |
| if: | | |
| !contains(github.event.head_commit.message, '+ONLYDOCS') && | |
| !contains(github.event.head_commit.message, '+NOFULLTEST') | |
| strategy: | |
| matrix: | |
| python-version: ['3.11', '3.12'] | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| label: linux-64 | |
| prefix: /usr/share/miniconda3/envs/test | |
| - os: macos-latest | |
| label: osx-64 | |
| prefix: /Users/runner/miniconda3/envs/test | |
| - os: windows-latest | |
| label: win-64 | |
| prefix: C:\Miniconda3\envs\test | |
| steps: | |
| - uses: actions/checkout@v5 | |
| # Modern approach for output variables - use GITHUB_OUTPUT file | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - uses: conda-incubator/setup-miniconda@v3.2.0 | |
| with: | |
| activate-environment: test${{ matrix.python-version }} | |
| python-version: ${{ matrix.python-version }} | |
| conda-remove-defaults: true | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ${{ matrix.prefix }}${{ matrix.python-version }} | |
| key: ${{ matrix.label }}-conda-py${{ matrix.python-version }}-${{ hashFiles('.github/environment.yml') }}-${{ steps.date.outputs.date }}-${{ env.CACHE_NUMBER }} | |
| # Add restore-keys for fallback caching strategy | |
| restore-keys: | | |
| ${{ matrix.label }}-conda-py${{ matrix.python-version }}-${{ hashFiles('.github/environment.yml') }}- | |
| ${{ matrix.label }}-conda-py${{ matrix.python-version }}- | |
| env: | |
| # Increase this value to reset cache if etc/example-environment.yml has not changed | |
| CACHE_NUMBER: 1 | |
| id: cache | |
| - name: Update environment | |
| run: conda env update -n test${{ matrix.python-version }} -f .github/environment.yml | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| - name: Print package info | |
| shell: bash -l {0} | |
| run: | | |
| conda info -a | |
| conda list | |
| - name: Install MSNoise | |
| shell: bash -l {0} | |
| run: | | |
| pip install -e . | |
| - name: Test suite | |
| shell: bash -l {0} | |
| run: | | |
| pytest -s --cov msnoise msnoise/test/tests.py --cov-report=xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| three_component_tests: | |
| needs: run_tests # Add dependency to create clear execution flow | |
| runs-on: ubuntu-latest | |
| if: | | |
| !contains(github.event.head_commit.message, '+ONLYDOCS') && | |
| !contains(github.event.head_commit.message, '+NOFULLTEST') | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: conda-incubator/setup-miniconda@v3.2.0 | |
| with: | |
| activate-environment: test3.12 | |
| python-version: '3.12' | |
| conda-remove-defaults: true | |
| - name: Install MSNoise | |
| shell: bash -l {0} | |
| run: | | |
| conda env update -n test3.12 -f .github/environment.yml | |
| pip install -e . | |
| - name: Test 3C data | |
| shell: bash -l {0} | |
| run: | | |
| pytest -s --cov msnoise msnoise/test/tests-threecomponent.py --cov-report=xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |