STY: manual fixes for newly flagged violations of UP031 #8459
Workflow file for this run
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: Build and Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
env: | |
HOMEBREW_NO_AUTO_UPDATE: 1 | |
jobs: | |
build: | |
name: "${{ matrix.tests-type }} tests: py${{ matrix.python-version }} on ${{ matrix.os }} (${{ matrix.test-runner }})" | |
strategy: | |
# run all tests even if e.g. image tests fail early | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
python-version: ['3.13'] | |
dependencies: [full] | |
tests-type: [unit] | |
test-runner: [pytest] | |
venv-loc: [bin] | |
include: | |
- os: windows-latest | |
python-version: '3.13' | |
dependencies: full | |
tests-type: unit | |
test-runner: pytest | |
venv-loc: Scripts | |
- os: ubuntu-20.04 | |
python-version: '3.10.3' | |
dependencies: minimal | |
tests-type: unit | |
test-runner: pytest | |
venv-loc: bin | |
- os: ubuntu-latest | |
# this job is necessary for non-answer, 'yield' based tests | |
# because pytest doesn't support such tests | |
python-version: '3.10' | |
dependencies: full | |
tests-type: unit | |
test-runner: nose | |
venv-loc: bin | |
- os: ubuntu-latest | |
# answer tests use 'yield', so they require nose | |
# they are also attached to a specific, occasionally updated, Python version | |
# but it does *not* have to match the current minimal supported version | |
python-version: '3.10' | |
dependencies: full | |
tests-type: answer | |
test-runner: nose | |
venv-loc: bin | |
- os: ubuntu-latest | |
# minimal tests with latest Python and no optional dependencies | |
python-version: '3.x' | |
dependencies: '' | |
tests-type: unit | |
test-runner: pytest | |
venv-loc: bin | |
runs-on: ${{ matrix.os }} | |
concurrency: | |
# auto-cancel any in-progress job *on the same branch* | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.tests-type }}-py${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.test-runner }} | |
cancel-in-progress: true | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Checkout repo (bare) | |
if: matrix.tests-type != 'answer' | |
uses: actions/checkout@v4 | |
- name: Checkout repo (with submodules) | |
if: matrix.tests-type == 'answer' | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install dependencies and yt | |
shell: bash | |
env: | |
dependencies: ${{ matrix.dependencies }} | |
run: | | |
python -m venv .venv | |
source .venv/${{matrix.venv-loc}}/activate | |
source ./tests/ci_install.sh | |
- name: Install and patch nosetest | |
if: matrix.test-runner == 'nose' | |
run: | | |
source .venv/${{matrix.venv-loc}}/activate | |
python -m pip install -r nose_requirements.txt | |
find .venv/lib/python${{matrix.python-version}}/site-packages/nose -name '*.py' \ | |
-exec sed -i -e s/collections.Callable/collections.abc.Callable/g '{}' ';' | |
- name: Show final env | |
run: | | |
source .venv/${{matrix.venv-loc}}/activate | |
python -m pip list | |
- name: Run Unit Tests (pytest) | |
if: matrix.test-runner == 'pytest' | |
run: | | |
source .venv/${{matrix.venv-loc}}/activate | |
pytest --color=yes | |
- name: Run Tests (nose) | |
if: matrix.test-runner == 'nose' | |
run: | | |
source .venv/${{matrix.venv-loc}}/activate | |
cat nose_ignores.txt | xargs python -m nose -c nose_unit.cfg --traverse-namespace | |
image-tests: | |
name: Image tests | |
runs-on: ubuntu-latest | |
concurrency: | |
# auto-cancel any in-progress job *on the same branch* | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Checkout repo (with submodules) | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install dependencies and yt | |
shell: bash | |
env: | |
dependencies: 'cartopy' | |
run: | | |
source ./tests/ci_install.sh | |
- run: python -m pip list | |
- name: Run Image Tests | |
run: | | |
pytest --color=yes --mpl -m mpl_image_compare \ | |
--mpl-generate-summary=html \ | |
--mpl-results-path=pytest_mpl_results \ | |
--mpl-baseline-path=tests/pytest_mpl_baseline \ | |
-rxXs # show extra info on xfailed, xpassed, and skipped tests | |
- name: Generate new image baseline | |
if: failure() | |
run: | | |
pytest --color=yes --mpl -m mpl_image_compare \ | |
--mpl-generate-path=pytest_mpl_new_baseline \ | |
--last-failed | |
# always attempt to upload artifacts, even | |
# (and especially) in case of failure. | |
- name: Upload pytest-mpl report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: yt_pytest_mpl_results | |
path: pytest_mpl_results/* | |
- name: Upload pytest-mpl baseline | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: yt_pytest_mpl_new_baseline | |
path: pytest_mpl_new_baseline/* | |
if-no-files-found: ignore |