Update GitHub Actions workflows

This commit is contained in:
Adam Turner
2023-02-15 02:10:09 +00:00
parent bb9821b968
commit ff852bc7c3
10 changed files with 200 additions and 142 deletions

View File

@@ -20,9 +20,17 @@ jobs:
with:
python-version: 3
- name: Install dependencies
run: |
run: |
sudo apt update
sudo apt install -y graphviz
pip install -U tox
- name: Run Tox
run: tox -e docs
python -m pip install --upgrade pip
python -m pip install .[docs]
- name: Render the documentation
run: >
python
-X dev
-X warn_default_encoding
-m sphinx
-M html ./doc ./build/sphinx
-W
--keep-going

View File

@@ -5,6 +5,9 @@ on: [push]
permissions:
contents: read
env:
FORCE_COLOR: "1"
jobs:
coverage:
runs-on: ubuntu-latest
@@ -24,11 +27,16 @@ jobs:
run: sudo apt-get install graphviz
- name: Install dependencies
run: python -m pip install -U pip tox pytest-cov
run: |
python -m pip install --upgrade pip
python -m pip install .[test] pytest-cov
- name: Run Tox
run: tox -e py -- -vv
- name: Test with pytest
run: python -m pytest -vv
env:
PYTHONDEVMODE: "1" # -X dev
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
PYTHONWARNINGS: "always" # -W always
PYTEST_ADDOPTS: "--cov ./ --cov-append --cov-config pyproject.toml"
VIRTUALENV_SYSTEM_SITE_PACKAGES: "1"

View File

@@ -16,7 +16,7 @@ jobs:
container:
image: ghcr.io/sphinx-doc/sphinx-ci
env:
DO_EPUBCHECK: 1
DO_EPUBCHECK: "1"
steps:
- name: Alias python3 to python
run: ln -s /usr/bin/python3 /usr/bin/python
@@ -24,6 +24,15 @@ jobs:
- name: Check Python version
run: python --version
- name: Install dependencies
run: pip install -U pip tox
- name: Run Tox
run: tox -e py -- -vv
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Test with pytest
run: >
python
-X dev
-X warn_default_encoding
-m pytest
-vv
--color yes
--durations 25

View File

@@ -10,27 +10,9 @@ concurrency:
cancel-in-progress: true
env:
FORCE_COLOR: 1
FORCE_COLOR: "1"
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tool: [docslint, flake8, isort, mypy, twine]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: python -m pip install -U tox pip
- name: Run Tox
run: tox -e ${{ matrix.tool }}
ruff:
runs-on: ubuntu-latest
@@ -41,8 +23,97 @@ jobs:
with:
python-version: 3
- name: Install dependencies
run: |
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade ruff
- name: Lint with Ruff
run: ruff . --diff --format github
run: ruff . --diff --format github
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade "flake8>=3.5.0" "flake8-simplify"
- name: Lint with flake8
run: flake8 .
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade isort
- name: Lint with isort
run: isort --check-only --diff .
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade "mypy>=0.990" docutils-stubs types-requests
- name: Type check with mypy
run: mypy sphinx/
docs-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade sphinx-lint
- name: Lint documentation with sphinx-lint
run: >
sphinx-lint
--enable line-too-long
--max-line-length 85
CHANGES
CONTRIBUTING.rst
README.rst
doc/
twine:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade twine build
- name: Lint with twine
run: |
python -m build .
twine check dist/*

View File

@@ -1,8 +1,8 @@
name: 'Lock old threads'
name: Lock old threads
on:
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"
permissions:
issues: write
@@ -16,5 +16,5 @@ jobs:
- uses: dessant/lock-threads@v3
with:
github-token: ${{ github.token }}
issue-inactive-days: '30'
pr-inactive-days: '30'
issue-inactive-days: "30"
pr-inactive-days: "30"

View File

@@ -9,10 +9,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
FORCE_COLOR: "1"
PYTHONDEVMODE: "1" # -X dev
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
PYTHONWARNINGS: "always" # -W always
jobs:
ubuntu:
runs-on: ubuntu-latest
name: Python ${{ matrix.python }} (${{ matrix.docutils }})
name: Python ${{ matrix.python }} (Docutils ${{ matrix.docutils }})
strategy:
fail-fast: false
matrix:
@@ -23,9 +29,8 @@ jobs:
- "3.11"
- "3.12-dev"
docutils:
- "du18"
- "du19"
- "du-latest"
- "0.18"
- "0.19"
steps:
- uses: actions/checkout@v3
@@ -44,12 +49,18 @@ jobs:
- name: Install graphviz
run: sudo apt-get install graphviz
- name: Install dependencies
run: python -m pip install -U pip tox
- name: Run Tox
run: tox -e ${{ matrix.docutils }} -- -vv
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Install Docutils ${{ matrix.docutils }}
run: python -m pip install --upgrade "docutils==${{ matrix.docutils }}.*"
- name: Test with pytest
run: python -m pytest -vv --durations 25
windows:
runs-on: windows-2019
name: Windows
steps:
- uses: actions/checkout@v3
- name: Set up Python
@@ -57,6 +68,31 @@ jobs:
with:
python-version: 3
- name: Install dependencies
run: python -m pip install -U pip tox
- name: Run Tox
run: tox -e py -- -vv
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Test with pytest
run: python -m pytest -vv --durations 25
docutils-latest:
runs-on: ubuntu-latest
name: Docutils HEAD
steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3"
- name: Check Python version
run: python --version
- name: Install graphviz
run: sudo apt-get install graphviz
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Install Docutils' HEAD
run: python -m pip install git+https://repo.or.cz/docutils.git\#subdirectory=docutils
- name: Test with pytest
run: python -m pytest -vv

View File

@@ -13,7 +13,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
node-version: 16
node-version: "16"
steps:
- uses: actions/checkout@v3
@@ -24,6 +24,4 @@ jobs:
cache: "npm"
- run: npm install
- name: Run headless test
uses: GabrielBB/xvfb-action@v1
with:
run: npm test
run: xvfb-run -a npm test

View File

@@ -22,15 +22,15 @@ jobs:
with:
python-version: 3.9 # https://github.com/transifex/transifex-client/pull/330
- name: Install dependencies
run: pip install -U babel jinja2 transifex-client
run: pip install -U babel jinja2 transifex-client
- name: Install Sphinx
run: pip install .
run: pip install .
- name: Extract translations from source code
run: python utils/babel_runner.py extract
run: python utils/babel_runner.py extract
- name: Push translations to transifex.com
run: cd sphinx/locale && tx push -s --no-interactive --parallel
run: cd sphinx/locale && tx push -s --no-interactive --parallel
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
TX_TOKEN: "${{ secrets.TX_TOKEN }}"
pull:
permissions:
@@ -48,21 +48,21 @@ jobs:
with:
python-version: 3.9 # https://github.com/transifex/transifex-client/pull/330
- name: Install dependencies
run: pip install -U babel jinja2 transifex-client
run: pip install -U babel jinja2 transifex-client
- name: Install Sphinx
run: pip install .
run: pip install .
- name: Extract translations from source code
run: python utils/babel_runner.py extract
run: python utils/babel_runner.py extract
- name: Pull translations to transifex.com
run: cd sphinx/locale && tx pull -a -f --no-interactive --parallel
run: cd sphinx/locale && tx pull -a -f --no-interactive --parallel
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
TX_TOKEN: "${{ secrets.TX_TOKEN }}"
- name: Compile message catalogs
run: python utils/babel_runner.py compile
run: python utils/babel_runner.py compile
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
commit-message: 'Update message catalogs'
commit-message: "Update message catalogs"
branch: bot/pull-translations
title: Update message catalogs
labels: i18n

View File

@@ -154,10 +154,10 @@ Please follow these guidelines when writing code for Sphinx:
* Add appropriate unit tests.
Style and type checks can be run using ``tox``::
Style and type checks can be run as follows::
tox -e mypy
tox -e flake8
ruff .
mypy sphinx/
Unit tests
~~~~~~~~~~
@@ -252,13 +252,9 @@ documentation, as well as key aspects of a few different tools that we use.
Build the documentation
~~~~~~~~~~~~~~~~~~~~~~~
We use `the tox tool <https://tox.wiki/en/latest/>`__ to quickly build the
documentation. Tox is kind-of like a Makefile, but includes the ability to
install an isolated environment used to run each task.
To build the documentation, run the following command::
To build the documentation with ``tox``, run the following command::
tox -e docs
sphinx-build -M html ./doc ./build/sphinx -W --keep-going
This will parse the Sphinx documentation's source files and generate HTML for
you to preview in ``build/sphinx/html``.
@@ -267,7 +263,7 @@ You can also build a **live version of the documentation** that you can preview
in the browser. It will detect changes and reload the page any time you make
edits. To do so, run the following command::
tox -e docs-live
sphinx-autobuild ./doc ./build/sphinx/
Translations
~~~~~~~~~~~~

72
tox.ini
View File

@@ -1,6 +1,6 @@
[tox]
minversion = 2.4.0
envlist = docs,flake8,mypy,twine,py{38,39,310,311,312},du{18,19,-latest}
envlist = py{38,39,310,311,312}
isolated_build = True
[testenv]
@@ -18,12 +18,6 @@ passenv =
TERM
description =
py{38,39,310,311,312}: Run unit tests against {envname}.
du{18,19}: Run unit tests with the given version of docutils.
du-latest: Run unit tests with Docutils' HEAD
deps =
du18: docutils==0.18.*
du19: docutils==0.19.*
du-latest: git+https://repo.or.cz/docutils.git\#subdirectory=docutils
extras =
test
setenv =
@@ -32,48 +26,6 @@ setenv =
commands=
python -X dev -X warn_default_encoding -m pytest --durations 25 {posargs}
[testenv:flake8]
basepython = python3
description =
Run style checks.
whitelist_externals =
flake8
extras =
lint
commands =
flake8 {posargs}
[testenv:ruff]
basepython = python3
description =
Run style checks with ruff.
whitelist_externals =
ruff
extras =
lint
commands =
ruff {posargs}
[testenv:isort]
basepython = python3
description =
Run import sorting checks.
whitelist_externals =
isort
extras =
lint
commands =
isort --check-only --diff .
[testenv:mypy]
basepython = python3
description =
Run type checks.
extras =
lint
commands=
mypy sphinx/
[testenv:docs]
basepython = python3
description =
@@ -81,16 +33,7 @@ description =
extras =
docs
commands =
python -X dev -X warn_default_encoding -m sphinx -M html ./doc ./build/sphinx -W --keep-going
[testenv:docslint]
basepython = python3
description =
Lint documentation.
extras =
lint
commands =
sphinx-lint --enable line-too-long --max-line-length 85 CHANGES CONTRIBUTING.rst README.rst doc/
sphinx-build -M html ./doc ./build/sphinx -W --keep-going
[testenv:docs-live]
basepython = python3
@@ -103,17 +46,6 @@ deps =
commands =
sphinx-autobuild ./doc ./build/sphinx/
[testenv:twine]
basepython = python3
description =
Lint package.
deps =
twine
build
commands =
python -m build .
twine check dist/*
[testenv:bindep]
description =
Install binary dependencies.