Skip to content

Bump pytest from 8.4.1 to 9.0.0 #61

Bump pytest from 8.4.1 to 9.0.0

Bump pytest from 8.4.1 to 9.0.0 #61

Workflow file for this run

name: Parallel (dir)
on:
push:
schedule:
- cron: "0 0 1 * *" # Midnight every month (UTC)
workflow_dispatch:
jobs:
collect:
name: Collect
runs-on: ubuntu-latest
outputs:
directories: "${{ steps.build.outputs.TEST_DIRS }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: pip
- name: Show python version
run: python --version && pip --version
- name: Install python dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --requirement requirements.txt
- name: Collect tests
run: |
pytest --collect-only --quiet | tee collected.tmp
echo '::group::Delete the last two lines'
sed -e '$d' collected.tmp | sed -e '$d' | tee collected.txt
echo '::endgroup::'
- name: Build test matrix
id: build
shell: python
run: |
from os import environ
from pathlib import Path
# For each test, get the file's parent directory. Use a set to avoid duplication.
with open("collected.txt", encoding="utf-8") as lines:
test_dirs = sorted({str(Path(line.partition("::")[0]).parent) for line in lines})
print(f"::notice ::Directories: {test_dirs}")
with open(environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
print(f"TEST_DIRS={test_dirs}", file=f)
test:
name: Test
runs-on: ubuntu-latest
needs: collect
strategy:
matrix:
directory: ${{ fromJSON(needs.collect.outputs.directories) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: pip
- name: Show python version
run: python --version && pip --version
- name: Install python dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --requirement requirements.txt
- name: Set pytest norecursedirs
# Prevent the test runner from recursing into subdirectories. This
# avoids duplicate test runs if there are nested test directories.
run: |
echo 'norecursedirs = "*"' >> pyproject.toml
echo '::notice ::Enabled pytest norecursedirs.'
- name: Run test
# Quote the matrix argument because the path may contain spaces.
run: pytest '${{ matrix.directory }}'