Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions: Simplify tests using matrix.os #10299

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 16 additions & 97 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ concurrency:
cancel-in-progress: true

jobs:
tests-linux:
name: run / ${{ matrix.python-version }} / Linux
runs-on: ubuntu-latest
tests:
name: run / ${{ matrix.python-version }} / ${{ matrix.os }}
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: macos-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "pypy-3.9"
- os: ubuntu-latest
python-version: "pypy-3.10"
runs-on: ${{ matrix.os }}
outputs:
python-key: ${{ steps.generate-python-key.outputs.key }}
steps:
Expand Down Expand Up @@ -76,6 +84,7 @@ jobs:
pip list | grep 'astroid\|pylint'
python -m pytest -vv --minimal-messages-config tests/test_functional.py
- name: Upload coverage artifact
if: runner.os == 'Linux'
uses: actions/[email protected]
with:
name: coverage-${{ matrix.python-version }}
Expand All @@ -86,11 +95,11 @@ jobs:
name: process / coverage
runs-on: ubuntu-latest
timeout-minutes: 5
needs: tests-linux
needs: tests
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Set up Python 3.12
- name: Set up Python 3.13
id: python
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -122,7 +131,7 @@ jobs:
name: run benchmark / ${{ matrix.python-version }} / Linux
runs-on: ubuntu-latest
timeout-minutes: 10
needs: tests-linux
needs: tests
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -173,7 +182,7 @@ jobs:
name: run / ${{ matrix.python-version }} / Windows
runs-on: windows-latest
timeout-minutes: 25
needs: tests-linux
needs: tests
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -217,93 +226,3 @@ jobs:
. venv\\Scripts\\activate
pip list | grep 'astroid\|pylint'
python -m pytest --durations=10 --benchmark-disable tests/

tests-macos:
name: run / ${{ matrix.python-version }} / macOS
runs-on: macos-latest
timeout-minutes: 25
needs: tests-linux
strategy:
fail-fast: false
matrix:
# We only run on the oldest supported version on Mac
python-version: ["3.9"]
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
echo "key=venv-${{ env.CACHE_VERSION }}-${{
hashFiles('pyproject.toml', 'requirements_test_min.txt')
}}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/[email protected]
with:
path: venv
key: >-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
steps.generate-python-key.outputs.key }}
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install --upgrade --requirement requirements_test_min.txt
- name: Run pytest
run: |
. venv/bin/activate
pip list | grep 'astroid\|pylint'
python -m pytest --durations=10 --benchmark-disable tests/

tests-pypy:
name: run / ${{ matrix.python-version }} / Linux
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
python-version: ["pypy-3.9", "pypy-3.10"]
steps:
- name: Check out code from GitHub
uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Generate partial Python venv restore key
id: generate-python-key
run: >-
echo "key=venv-${{ env.CACHE_VERSION }}-${{
hashFiles('pyproject.toml', 'requirements_test_min.txt')
}}" >> $GITHUB_OUTPUT
- name: Restore Python virtual environment
id: cache-venv
uses: actions/[email protected]
with:
path: venv
key: >-
${{ runner.os }}-${{ matrix.python-version }}-${{
steps.generate-python-key.outputs.key }}
- name: Create Python virtual environment
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv venv
. venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
pip install --upgrade --requirement requirements_test_min.txt
- name: Run pytest
run: |
. venv/bin/activate
pip list | grep 'astroid\|pylint'
python -m pytest --durations=10 --benchmark-disable tests/