|
| 1 | +name: Slow Hypothesis CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "main" |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - "main" |
| 9 | + types: [opened, reopened, synchronize, labeled] |
| 10 | + workflow_dispatch: # allows you to trigger manually |
| 11 | + |
| 12 | +jobs: |
| 13 | + detect-ci-trigger: |
| 14 | + name: detect ci trigger |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: | |
| 17 | + github.repository == 'pydata/xarray' |
| 18 | + && (github.event_name == 'push' || github.event_name == 'pull_request') |
| 19 | + outputs: |
| 20 | + triggered: ${{ steps.detect-trigger.outputs.trigger-found }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 2 |
| 25 | + - uses: xarray-contrib/ci-trigger@v1 |
| 26 | + id: detect-trigger |
| 27 | + with: |
| 28 | + keyword: "[skip-ci]" |
| 29 | + |
| 30 | + hypothesis: |
| 31 | + name: Slow Hypothesis Tests |
| 32 | + runs-on: "ubuntu-latest" |
| 33 | + needs: detect-ci-trigger |
| 34 | + if: | |
| 35 | + always() |
| 36 | + && ( |
| 37 | + (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') |
| 38 | + || needs.detect-ci-trigger.outputs.triggered == 'true' |
| 39 | + || contains( github.event.pull_request.labels.*.name, 'run-slow-hypothesis') |
| 40 | + ) |
| 41 | + defaults: |
| 42 | + run: |
| 43 | + shell: bash -l {0} |
| 44 | + |
| 45 | + env: |
| 46 | + CONDA_ENV_FILE: ci/requirements/environment.yml |
| 47 | + PYTHON_VERSION: "3.12" |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + with: |
| 52 | + fetch-depth: 0 # Fetch all history for all branches and tags. |
| 53 | + |
| 54 | + - name: set environment variables |
| 55 | + run: | |
| 56 | + echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 57 | +
|
| 58 | + - name: Setup micromamba |
| 59 | + uses: mamba-org/setup-micromamba@v1 |
| 60 | + with: |
| 61 | + environment-file: ${{env.CONDA_ENV_FILE}} |
| 62 | + environment-name: xarray-tests |
| 63 | + create-args: >- |
| 64 | + python=${{env.PYTHON_VERSION}} |
| 65 | + conda |
| 66 | + cache-environment: true |
| 67 | + cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}" |
| 68 | + |
| 69 | + - name: Install xarray |
| 70 | + run: | |
| 71 | + python -m pip install --no-deps -e . |
| 72 | + - name: Version info |
| 73 | + run: | |
| 74 | + conda info -a |
| 75 | + conda list |
| 76 | + python xarray/util/print_versions.py |
| 77 | + - name: Restore cached hypothesis directory |
| 78 | + uses: actions/cache@v4 |
| 79 | + with: |
| 80 | + path: .hypothesis/ |
| 81 | + key: cache-hypothesis |
| 82 | + enableCrossOsArchive: true |
| 83 | + save-always: true |
| 84 | + - name: Run slow Hypothesis tests |
| 85 | + if: success() |
| 86 | + id: status |
| 87 | + run: | |
| 88 | + python -m pytest --hypothesis-show-statistics --run-slow-hypothesis properties/*.py \ |
| 89 | + --report-log output-${{ matrix.python-version }}-log.jsonl |
| 90 | + - name: Generate and publish the report |
| 91 | + if: | |
| 92 | + failure() |
| 93 | + && steps.status.outcome == 'failure' |
| 94 | + && github.event_name == 'schedule' |
| 95 | + && github.repository_owner == 'pydata' |
| 96 | + uses: xarray-contrib/issue-from-pytest-log@v1 |
| 97 | + with: |
| 98 | + log-path: output-${{ matrix.python-version }}-log.jsonl |
| 99 | + issue-title: "Nightly Hypothesis tests failed" |
| 100 | + issue-label: "topic-hypothesis" |
0 commit comments