Speed up setup of jobs in GitHub Actions (#12769)

This commit is contained in:
Adam Turner
2024-08-12 00:01:36 +01:00
committed by GitHub
parent 0bfaadf6c9
commit 0c67623ae8
3 changed files with 107 additions and 48 deletions

View File

@@ -14,6 +14,7 @@ concurrency:
env: env:
FORCE_COLOR: "1" FORCE_COLOR: "1"
UV_SYSTEM_PYTHON: "1" # make uv do global installs
jobs: jobs:
build: build:
@@ -27,10 +28,14 @@ jobs:
python-version: "3" python-version: "3"
- name: Install graphviz - name: Install graphviz
run: sudo apt-get install graphviz run: sudo apt-get install graphviz
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install .[docs]
python -m pip install --upgrade pip
python -m pip install .[docs]
- name: Render the documentation - name: Render the documentation
run: > run: >
sphinx-build sphinx-build

View File

@@ -14,6 +14,7 @@ concurrency:
env: env:
FORCE_COLOR: "1" FORCE_COLOR: "1"
UV_SYSTEM_PYTHON: "1" # make uv do global installs
jobs: jobs:
# If you update any of these commands, don't forget to update the equivalent # If you update any of these commands, don't forget to update the equivalent
@@ -23,17 +24,13 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3"
- name: Install pip
run: python -m pip install --upgrade pip
- name: Install Ruff - name: Install Ruff
run: | run: >
ruff_version=$(awk -F'[="]' '/\[project\.optional-dependencies\]/ {p=1} /ruff/ {if (p) print $4}' pyproject.toml) RUFF_VERSION=$(awk -F'[="]' '/\[project\.optional-dependencies\]/ {p=1} /ruff/ {if (p) print $4}' pyproject.toml)
python -m pip install "ruff==${ruff_version}" curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/ruff/${RUFF_VERSION}/install.sh"
| sh
- name: Lint with Ruff - name: Lint with Ruff
run: ruff check . --output-format github run: ruff check . --output-format github
@@ -50,10 +47,14 @@ jobs:
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3" python-version: "3"
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install --upgrade "flake8>=6.0"
python -m pip install --upgrade pip
python -m pip install --upgrade "flake8>=6.0"
- name: Lint with flake8 - name: Lint with flake8
run: flake8 . run: flake8 .
@@ -66,10 +67,14 @@ jobs:
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3" python-version: "3"
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install ".[lint,test]"
python -m pip install --upgrade pip
python -m pip install ".[lint,test]"
- name: Type check with mypy - name: Type check with mypy
run: mypy run: mypy
@@ -82,10 +87,14 @@ jobs:
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3" python-version: "3"
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install --upgrade sphinx-lint
python -m pip install --upgrade pip
python -m pip install --upgrade sphinx-lint
- name: Lint documentation with sphinx-lint - name: Lint documentation with sphinx-lint
run: make doclinter run: make doclinter
@@ -98,10 +107,14 @@ jobs:
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3" python-version: "3"
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install --upgrade twine build
python -m pip install --upgrade pip
python -m pip install --upgrade twine build
- name: Lint with twine - name: Lint with twine
run: | run: |
python -m build . python -m build .

View File

@@ -36,7 +36,6 @@ jobs:
- "3.10" - "3.10"
- "3.11" - "3.11"
- "3.12" - "3.12"
- "3.13-dev"
docutils: docutils:
- "0.20" - "0.20"
- "0.21" - "0.21"
@@ -49,12 +48,43 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }} - name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5 uses: actions/setup-python@v5
if: "!endsWith(matrix.python, '-dev')"
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: Check Python version
run: python --version --version
- name: Install graphviz
run: sudo apt-get install graphviz
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies
run: uv pip install .[test]
- name: Install Docutils ${{ matrix.docutils }}
run: uv pip install --upgrade "docutils~=${{ matrix.docutils }}.0"
- name: Test with pytest
run: python -m pytest -vv --durations 25
env:
PYTHONWARNINGS: "error" # treat all warnings as errors
deadsnakes:
runs-on: ubuntu-latest
name: Python ${{ matrix.python }} (Docutils ${{ matrix.docutils }})
strategy:
fail-fast: false
matrix:
python:
- "3.13-dev"
docutils:
- "0.20"
- "0.21"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python }} (deadsnakes) - name: Set up Python ${{ matrix.python }} (deadsnakes)
uses: deadsnakes/action@v3.1.0 uses: deadsnakes/action@v3.1.0
if: "endsWith(matrix.python, '-dev')"
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: Check Python version - name: Check Python version
@@ -84,10 +114,12 @@ jobs:
python-version: "3" python-version: "3"
- name: Check Python version - name: Check Python version
run: python --version --version run: python --version --version
- name: Install uv
run: >
Invoke-WebRequest -Uri "https://astral.sh/uv/install.ps1"
| Invoke-Expression
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install .[test]
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Test with pytest - name: Test with pytest
run: python -m pytest -vv --durations 25 run: python -m pytest -vv --durations 25
env: env:
@@ -112,12 +144,16 @@ jobs:
run: python --version --version run: python --version --version
- name: Install graphviz - name: Install graphviz
run: sudo apt-get install graphviz run: sudo apt-get install graphviz
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install .[test]
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Install Docutils' HEAD - name: Install Docutils' HEAD
run: python -m pip install git+https://repo.or.cz/docutils.git\#subdirectory=docutils run: uv pip install "docutils @ git+https://repo.or.cz/docutils.git#subdirectory=docutils"
- name: Test with pytest - name: Test with pytest
run: python -m pytest -vv run: python -m pytest -vv
env: env:
@@ -141,12 +177,9 @@ jobs:
run: sudo apt-get install graphviz run: sudo apt-get install graphviz
- name: Install uv - name: Install uv
run: > run: >
curl curl --no-progress-meter --location --fail
--location
--fail
--proto '=https' --tlsv1.2 --proto '=https' --tlsv1.2
--silent --show-error "https://astral.sh/uv/install.sh"
https://astral.sh/uv/install.sh
| sh | sh
- name: Install dependencies - name: Install dependencies
run: | run: |
@@ -171,10 +204,14 @@ jobs:
python-version: "3" python-version: "3"
- name: Check Python version - name: Check Python version
run: python --version --version run: python --version --version
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install .[test]
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Test with pytest - name: Test with pytest
run: python -m pytest -vv --durations 25 run: python -m pytest -vv --durations 25
env: env:
@@ -196,10 +233,14 @@ jobs:
run: python --version --version run: python --version --version
- name: Install graphviz - name: Install graphviz
run: sudo apt-get install graphviz run: sudo apt-get install graphviz
- name: Install uv
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
"https://astral.sh/uv/install.sh"
| sh
- name: Install dependencies - name: Install dependencies
run: | run: uv pip install .[test] pytest-cov
python -m pip install --upgrade pip
python -m pip install .[test] pytest-cov
- name: Test with pytest - name: Test with pytest
run: python -m pytest -vv --cov . --cov-append --cov-config pyproject.toml run: python -m pytest -vv --cov . --cov-append --cov-config pyproject.toml
env: env: