From 6942e7c45f17afb5deed9485ebd8f7c4fedc01d3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 22 Mar 2025 12:04:00 +0100 Subject: [PATCH] GitHub Actions: Simplify tests using matrix.os --- .github/workflows/tests.yaml | 113 +++++------------------------------ 1 file changed, 16 insertions(+), 97 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index cb033ea9fc..2a8514616c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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: @@ -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/upload-artifact@v4.6.1 with: name: coverage-${{ matrix.python-version }} @@ -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/checkout@v4.2.2 - - name: Set up Python 3.12 + - name: Set up Python 3.13 id: python uses: actions/setup-python@v5.4.0 with: @@ -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: @@ -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: @@ -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/checkout@v4.2.2 - - name: Set up Python ${{ matrix.python-version }} - id: python - uses: actions/setup-python@v5.4.0 - 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/cache@v4.2.2 - 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/checkout@v4.2.2 - - name: Set up Python ${{ matrix.python-version }} - id: python - uses: actions/setup-python@v5.4.0 - 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/cache@v4.2.2 - 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/