Skip to content

Commit

Permalink
⬆️ Update for Sphinx 7
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Nov 6, 2023
1 parent 2a97e95 commit 575c62b
Show file tree
Hide file tree
Showing 23 changed files with 1,112 additions and 899 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,14 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install/Update build dependencies
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install --upgrade setuptools
python -m pip install --upgrade pip
- name: Install Poetry
run: |
curl -sL https://install.python-poetry.org | python -
- name: Update Pip
run: poetry run pip install -U pip setuptools
- name: Install Nox Dependencies
run: |
python -m pip install poetry nox nox-poetry pyparsing==3.0.4
python -m pip install -e .[test,benchmark,docs]
- name: Run Benchmark for time
run: nox --non-interactive --session benchmark_time -- --full-trace
run: pytest --benchmark-json output.json -k _time tests/benchmarks

- name: Download previous benchmark data
uses: actions/cache@v3
with:
Expand All @@ -53,13 +47,16 @@ jobs:
gh-pages-branch: "benchmarks"
benchmark-data-dir-path: "docs/bench"
alert-comment-cc-users: '@danwos'
- name: Run memory benchmark
run: nox --non-interactive --session benchmark_memory

- name: Run Benchmark for memory
run: pytest --benchmark-json output.json -k _time tests/benchmarks
- name: Create memory flamegraph
run: memray flamegraph -o mem_out.html mem_out.bin
- name: Publish memory flamegraph
run: |
git checkout benchmarks
cp mem_out.html docs/memory.html
git add docs/memory.html
git -c "user.name=Sphinx-Needs CI" -c "[email protected]" commit -m "memory.html update"
- name: Push changes
run: git push origin benchmarks
run: git push origin benchmarks
66 changes: 29 additions & 37 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,70 +1,62 @@
name: CI
on: [pull_request]
jobs:

lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: pre-commit/[email protected]

tests:
name: "py${{ matrix.python-version }} sp${{ matrix.sphinx-version }} do${{ matrix.docutils-version }} ${{ matrix.os }}"
name: "py${{ matrix.python-version }} sphinx~=${{ matrix.sphinx-version }} ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Set on "false" to get the results of ALL builds
matrix:
os: ["ubuntu-latest"]
# 3.9.8 seems to be broken with type_ast
# https://www.mail-archive.com/[email protected]/msg1829077.html
python-version: ["3.8", "3.10"]
sphinx-version: ['5.2.1', '4.5.0']
docutils-version: ['0.19', '0.15']
exclude:
- sphinx-version: "4.5.0"
docutils-version: "0.19"
python-version: ["3.8", "3.11"]
sphinx-version: ["5.0", "6.0", "7.0"]
include:
# Check only newest setups for win server
- os: "windows-latest"
python-version: "3.8"
sphinx-version: "4.5.0"
docutils-version: "0.15"
sphinx-version: "5.0"
steps:
- uses: actions/checkout@v4
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Nox Dependencies
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install poetry nox nox-poetry pyparsing==3.0.4
- name: Install other dependencies
python -m pip install sphinx~=${{ matrix.sphinx-version }} -e .[test]
python -m pip freeze
- name: Run pytest
run: |
python -m pip install setuptools
- name: Final package list
run: |
pip freeze
- name: Run Tests on Windows
run: nox --non-interactive --session "tests-${{ matrix.python-version }}(sphinx='${{ matrix.sphinx-version }}', docutils='${{ matrix.docutils-version }}')" -- --full-trace
if: runner.os == 'Windows'

- name: Run Tests on Linux
run: nox --non-interactive --session "tests-${{ matrix.python-version }}(sphinx='${{ matrix.sphinx-version }}', docutils='${{ matrix.docutils-version }}')" -- --full-trace
if: runner.os == 'Linux'
python -m pytest -v --ignore=tests/benchmarks -m "not jstest" tests
lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: pre-commit/[email protected]

check:
check:

# This job does nothing and is only used for the branch protection
# see https://github.com/marketplace/actions/alls-green#why

if: always()

needs:
- lint
- tests

runs-on: ubuntu-latest

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Nox Dependencies
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install Dependencies
run: |
python -m pip install poetry nox nox-poetry pyparsing==3.0.4
- name: Run LinkCheck
run: nox --non-interactive --session linkcheck -- --full-trace
python -m pip install -e .[docs]
- name: Run linkcheck
run: sphinx-build -b linkcheck . _build
working-directory: docs
7 changes: 2 additions & 5 deletions .github/workflows/js_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
- name: Install package
run: |
pip install -r docs/requirements.txt
- name: Install Sphinx-Needs from master
run: |
pip install -e .
pip install -e .[docs]
- name: Install Node dependencies
run: npm install cypress
- name: Build Docs
Expand Down
1 change: 0 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ sphinx:

python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
Expand Down
10 changes: 0 additions & 10 deletions docs/requirements.txt

This file was deleted.

82 changes: 21 additions & 61 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,94 +6,47 @@
# This list can contain more versions as used by the github workflows to support
# custom local tests

PYTHON_VERSIONS = ["3.8", "3.10"]
SPHINX_VERSIONS = ["5.2.1", "4.5.0"]
DOCUTILS_VERSIONS = ["0.19", "0.17", "0.16", "0.15"]
PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
SPHINX_VERSIONS = ["5.0", "6.0", "7.2"]


TEST_DEPENDENCIES = [
"pytest",
"pytest-xdist",
"pytest-xprocess",
"syrupy",
"responses",
"lxml",
"pyparsing!=3.0.4",
"requests-mock",
]

# Some pytest-extension do not work well with pytest-benchmark, so we create our
# own list for benchmarking
BENCHMARK_DEPENDENCIES = [e for e in TEST_DEPENDENCIES if e not in ['"pytest-xdist"']]
BENCHMARK_DEPENDENCIES.append("py")
BENCHMARK_DEPENDENCIES.append("memray")
BENCHMARK_DEPENDENCIES.append("pytest-benchmark")


def is_supported(python: str, sphinx: str, docutils: str) -> bool:
return not (sphinx in ["4.5.0"] and docutils in ["0.19", "0.18"])


def run_tests(session, sphinx, docutils):
session.install(".")
session.install(*TEST_DEPENDENCIES)
session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
session.run("pip", "install", f"sphinx=={sphinx}", silent=True)
session.run("pip", "install", f"docutils=={docutils}", silent=True)
@session(python=PYTHON_VERSIONS)
@nox.parametrize("sphinx", SPHINX_VERSIONS)
def tests(session, sphinx):
session.install(".[test]")
session.run("pip", "install", f"sphinx~={sphinx}", silent=True)
session.run("echo", "TEST FINAL PACKAGE LIST")
session.run("pip", "freeze")
session.run("make", "test", external=True)


@session(python=PYTHON_VERSIONS)
@nox.parametrize("docutils", DOCUTILS_VERSIONS) # order is important, last options needs to be given first ...
@nox.parametrize("sphinx", SPHINX_VERSIONS) # ... by GH workflow
def tests(session, sphinx, docutils):
if is_supported(session.python, sphinx, docutils):
run_tests(session, sphinx, docutils)
else:
session.skip("unsupported combination")


@session(python="3.10")
def linkcheck(session):
session.install(".")
# LinkCheck can handle rate limits since Sphinx 3.4, which is needed as
# our doc has too many links to GitHub.
session.run("pip", "install", "sphinx==3.5.4", silent=True)

session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
session.run("make", "docs-linkcheck", external=True)
posargs = session.posargs or ["tests"]
session.run("pytest", "--ignore", "tests/benchmarks", *posargs, external=True)


@session(python="3.10")
def benchmark_time(session):
session.install(".")
session.install(*BENCHMARK_DEPENDENCIES)
session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
session.install(".[test,benchmark,docs]")
session.run(
"pytest",
"tests/benchmarks",
"-k",
"_time",
"--benchmark-json",
"output.json",
*session.posargs,
external=True,
)


@session(python="3.10")
def benchmark_memory(session):
session.install(".")
session.install(*BENCHMARK_DEPENDENCIES)
session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
session.install(".[test,benchmark,docs]")
session.run(
"pytest",
"tests/benchmarks",
"-k",
"_memory",
"--benchmark-json",
"output.json",
*session.posargs,
external=True,
)
session.run("memray", "flamegraph", "-o", "mem_out.html", "mem_out.bin")
Expand All @@ -103,4 +56,11 @@ def benchmark_memory(session):
def pre_commit(session):
session.run_always("poetry", "install", external=True)
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", external=True)
session.run("pre-commit", "run", "--all-files", *session.posargs, external=True)


@session(python="3.10")
def linkcheck(session):
session.install(".[docs]")
with session.chdir("docs"):
session.run("sphinx-build", "-b", "linkcheck", ".", "_build", *session.posargs, external=True)
Loading

0 comments on commit 575c62b

Please sign in to comment.