-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In addition, enhance mypy job configuration to support running it locally via `act`. Fixes #9997
- Loading branch information
1 parent
56f9e4c
commit 9a3f95e
Showing
6 changed files
with
676 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,15 @@ jobs: | |
with: | ||
keyword: "[skip-ci]" | ||
|
||
detect-act: | ||
name: Detect 'act' runner | ||
runs-on: ubuntu-latest | ||
outputs: | ||
running: ${{ steps.detect-act.outputs.running }} | ||
steps: | ||
- id: detect-act | ||
run: echo "running=${{ env.ACT || 'false' }}" >> "$GITHUB_OUTPUT" | ||
|
||
doctest: | ||
name: Doctests | ||
runs-on: "ubuntu-latest" | ||
|
@@ -81,15 +90,23 @@ jobs: | |
python -m pytest --doctest-modules xarray --ignore xarray/tests -Werror | ||
mypy: | ||
name: Mypy | ||
strategy: | ||
matrix: | ||
include: | ||
- python-version: "3.10" | ||
codecov-flags: mypy-min | ||
- python-version: "3.12" | ||
codecov-flags: mypy | ||
name: Mypy ${{ matrix.python-version }} | ||
runs-on: "ubuntu-latest" | ||
needs: detect-ci-trigger | ||
needs: [detect-ci-trigger, detect-act] | ||
if: always() && (needs.detect-ci-trigger.outputs.triggered == 'true' || needs.detect-act.outputs.running == 'true') | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
env: | ||
CONDA_ENV_FILE: ci/requirements/environment.yml | ||
PYTHON_VERSION: "3.12" | ||
PYTHON_VERSION: ${{ matrix.python-version }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -116,68 +133,23 @@ jobs: | |
python xarray/util/print_versions.py | ||
- name: Install mypy | ||
run: | | ||
python -m pip install mypy | ||
python -m pip install mypy pytest-mypy-plugins | ||
- name: Run mypy | ||
run: | | ||
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report | ||
- name: Upload mypy coverage to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
files: mypy_report/cobertura.xml | ||
flags: mypy | ||
env_vars: PYTHON_VERSION | ||
name: codecov-umbrella | ||
fail_ci_if_error: false | ||
|
||
mypy-min: | ||
name: Mypy 3.10 | ||
runs-on: "ubuntu-latest" | ||
needs: detect-ci-trigger | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
env: | ||
CONDA_ENV_FILE: ci/requirements/environment.yml | ||
PYTHON_VERSION: "3.10" | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history for all branches and tags. | ||
|
||
- name: set environment variables | ||
- name: Run mypy tests | ||
# Run pytest with mypy plugin even if mypy analysis in previous step fails. | ||
if: ${{ always() }} | ||
run: | | ||
echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
- name: Setup micromamba | ||
uses: mamba-org/setup-micromamba@v2 | ||
with: | ||
environment-file: ${{env.CONDA_ENV_FILE}} | ||
environment-name: xarray-tests | ||
create-args: >- | ||
python=${{env.PYTHON_VERSION}} | ||
cache-environment: true | ||
cache-environment-key: "${{runner.os}}-${{runner.arch}}-py${{env.PYTHON_VERSION}}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}" | ||
- name: Install xarray | ||
run: | | ||
python -m pip install --no-deps -e . | ||
- name: Version info | ||
run: | | ||
python xarray/util/print_versions.py | ||
- name: Install mypy | ||
run: | | ||
python -m pip install mypy | ||
- name: Run mypy | ||
run: | | ||
python -m mypy --install-types --non-interactive --cobertura-xml-report mypy_report | ||
python -m pytest -v --mypy-only-local-stub --mypy-pyproject-toml-file=pyproject.toml xarray/**/test_*.yml | ||
- name: Upload mypy coverage to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
files: mypy_report/cobertura.xml | ||
flags: mypy-min | ||
flags: ${{ matrix.codecov-flags }} | ||
env_vars: PYTHON_VERSION | ||
name: codecov-umbrella | ||
fail_ci_if_error: false | ||
|
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
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
Oops, something went wrong.