diff --git a/.eslintignore b/.eslintignore index 9e91e20a..8e3bd75b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,7 +2,6 @@ node_modules *.min.js **/lib/ public/ -coverage/ **/vendor/ docs/_build sphinx_wagtail_theme/static diff --git a/.github/actions/setup-firefox/action.yml b/.github/actions/setup-firefox/action.yml deleted file mode 100644 index 6241d119..00000000 --- a/.github/actions/setup-firefox/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -# Shamelessly copied from https://github.com/SeleniumHQ/selenium/blob/5d108f9a679634af0bbc387e7e3811bc1565912b/.github/actions/setup-firefox/action.yml -name: 'Setup Firefox and geckodriver' -runs: - using: 'composite' - steps: - - run: | - GECKODRIVER_URL=`curl -Ls -o /dev/null -w %{url_effective} https://github.com/mozilla/geckodriver/releases/latest` - GECKODRIVER_VERSION=`echo $GECKODRIVER_URL | sed 's#.*/##'` - export GECKODRIVER_DOWNLOAD="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-linux64.tar.gz" - curl -L -o geckodriver.tar.gz $GECKODRIVER_DOWNLOAD - gunzip -c geckodriver.tar.gz | tar xopf - - chmod +x geckodriver && sudo mv geckodriver /usr/local/bin - geckodriver --version - shell: bash diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index 7bdd9ddb..00000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: CI - -on: - push: - branches: - - main - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - id: nvm - run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" - - uses: actions/setup-node@v3 - with: - node-version: '${{ steps.nvm.outputs.NVMRC }}' - - run: npm install - - run: npm run build - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - run: pip install wheel - - run: python setup.py bdist_wheel - - uses: actions/upload-artifact@v1 - with: - name: bdist-wheel-package - path: dist - - uses: actions/upload-artifact@v1 - with: - name: static-files - path: sphinx_wagtail_theme/static/dist/ - - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - run: make setup - - run: make install-for-development - - run: make lint-minimal - - run: npm run lint - - run: make test - - visual-regression-tests: - runs-on: ubuntu-latest - env: - PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Setup Firefox and geckodriver - uses: ./.github/actions/setup-firefox - - run: make setup - - run: make install-for-development - - run: make frontend - - run: make docs - - name: Percy Test - run: make test-visual-regression - - sphinx-quickstart: - needs: [build] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v1 - with: - name: bdist-wheel-package - path: packages - - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - run: pip install sphinx - - run: pip install $(find packages -name "*.whl") - - name: Assert is importable, show version - run: python -c "import sphinx_wagtail_theme; print(sphinx_wagtail_theme.__version__)" - - run: | - html_theme=sphinx_wagtail_theme - sphinx-quickstart --project PROJECT --author AUTHOR --sep \ - --extensions ${html_theme} --no-use-make-mode --quiet - echo >> source/conf.py - echo 'extensions.append("'${html_theme}'")' >> source/conf.py - echo 'html_theme = "'${html_theme}'"' >> source/conf.py - cat source/conf.py - sphinx-build -b html -A version=test source build - - deploy: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v2 - with: - name: static-files - path: sphinx_wagtail_theme/static/dist/ - - run: grep -F -v 'dist' .gitignore > .gitignore.tmp && mv .gitignore.tmp .gitignore - - uses: JamesIves/github-pages-deploy-action@4.1.1 - with: - branch: gh-pages - folder: . - clean: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..2ab8a739 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +jobs: + qa: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + - run: npm ci + - run: make lint-frontend + - run: make frontend + - run: make install-python + - run: make lint-python + - run: make test + + visual-regression-tests: + needs: qa + runs-on: ubuntu-latest + env: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - uses: browser-actions/setup-firefox@v1 + - run: make install-python + - run: npm ci + # Check against the dist version of the frontend, as it would be appear when deployed + - run: make frontend-dist + - run: make docs + - name: Percy Test + run: make test-visual-regression diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..0e98c501 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,60 @@ +name: Publish to PyPI +on: + release: + # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release + types: [released] +jobs: + test: + uses: ./.github/workflows/ci.yml + + build: + needs: ['test'] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Install Node dependencies + run: | + npm ci + + - name: Compile JavaScript + run: | + make frontend-dist + + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install dependencies + run: make setup-python + + - name: Build package distributions + run: make build + + - uses: actions/upload-artifact@v4 + with: + path: ./dist + + # https://docs.pypi.org/trusted-publishers/using-a-publisher/ + pypi-publish: + needs: ['build'] + environment: 'publish' + + name: upload release to PyPI + runs-on: ubuntu-latest + permissions: + # Mandatory for trusted publishing + id-token: write + steps: + - uses: actions/download-artifact@v4 + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: artifact/ + print-hash: true diff --git a/.gitignore b/.gitignore index 08d3c024..98412e61 100644 --- a/.gitignore +++ b/.gitignore @@ -2,11 +2,6 @@ *.egg *.egg-info *.pyc -*.sass-cache -*GENERATED* -*NOT_VERSIONED* -.coverage -.eggs/ .idea .ruby-version .tox @@ -22,7 +17,7 @@ npm-debug.log /.vscode /build/* -!/build/.gitkeep +rtd-env/ venv/ env/ .env/ diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7c1559d5..9863b229 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,7 +10,7 @@ build: nodejs: '20' jobs: post_install: - - make setup-frontend + - make install-frontend pre_build: - make frontend diff --git a/CHANGELOG.md b/CHANGELOG.md index 5239e420..20040f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,11 @@ All notable changes to this project will be documented in this file. ### Added - Use new Wagtail logo variant for favicon and other logos (Osaf AliSayed) +- Set up GitHub Actions for publishing new releases using PyPI's trusted publishing (Storm Heg) ### Changed -- ... +- Clean up development and release instructions and format codebase with Black (Storm Heg) ### Removed diff --git a/Makefile b/Makefile index 730297d4..c5c9fc72 100644 --- a/Makefile +++ b/Makefile @@ -25,13 +25,13 @@ for target, help in hits: print("%-20s %s" % (target, help)) print(""" Start with the installation of Python and Node modules: - make setup + make install Compile frontend changes: make frontend -Build, import from package, test, render the repo docs and open in browser: - make install test-import docs +Build example docs and open in browser: + make docs serve """) endef export PRINT_HELP_PYSCRIPT @@ -44,70 +44,59 @@ help: @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) -.PHONY: build -build: clean build-project ## Build all, except frontend +.PHONY: install +install: install-python install-frontend ## Install all -.PHONY: build-project -build-project: clean-project ##- Build Sphinx extension - python setup.py sdist - python setup.py bdist_wheel - ls -l dist +.PHONY: install-frontend +install-frontend: ##- Install node modules + npm install -.PHONY: clean -clean: clean-project ## Clean all, except frontend +.PHONY: install-python +install-python: ##- Install Python modules + pip install -U pip + pip install -U -r requirements.txt + pip install -U -r requirements-dev.txt + +.PHONY: build +build: clean frontend-dist ##- Build Sphinx extension + python -m build + twine check dist/* + ls -l dist -.PHONY: clean-project -clean-project: clean-build clean-pyc clean-test clean-docs ## Remove all build, test, coverage and Python artifacts +.PHONY: clean +clean: ##- Remove all build, test and Python artifacts + # Build frontend files + rm -rf sphinx_wagtail_theme/static/dist -.PHONY: clean-build -clean-build: ##- Remove build artifacts + # Python build artifacts rm -rf build/ - mkdir -p build - touch build/.gitkeep rm -rf dist/ rm -rf .eggs/ find . -name '*.egg-info' -exec rm -rf {} + find . -name '*.egg' -exec rm -f {} + + # Clean build docs + rm -rf ./docs/_build + rm -rf ./rtd-venv -.PHONY: clean-frontend -clean-frontend: ## Clean frontend files - rm -rf sphinx_wagtail_theme/static/dist + # Python test artifacts + rm -rf .tox/ + rm -rf htmlcov/ + rm -rf .pytest_cache -clean-pyc: ##- Remove Python file artifacts + # Python artifacts find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + find . -name '*~' -exec rm -f {} + find . -name '__pycache__' -exec rm -rf {} + -.PHONY: clean-test -clean-test: ##- Remove test and coverage artifacts - rm -rf .tox/ - rm -f .coverage - rm -rf htmlcov/ - rm -rf .pytest_cache - - -.PHONY: clean-docs -clean-docs: ##- Remove previously built docs - rm -rf ./docs/_build - rm -rf ./rtd-venv - - -.PHONY: coverage -coverage: ##- Check code coverage quickly with default Python - coverage run --source sphinx_wagtail_theme -m pytest - coverage report -m - coverage html - $(BROWSER) htmlcov/index.html - .PHONY: docs -docs: ## Regenerate Sphinx HTML documentation +docs: ## Build Sphinx HTML documentation $(MAKE) -C docs clean $(MAKE) -C docs html @@ -122,6 +111,7 @@ rtd-docs: ## Build the docs like Readthedocs does. ./rtd-venv/bin/python -m sphinx -T -E -b html -d ./docs/_build/doctrees -D language=en ./docs ./docs/_build/html rm -rf "./rtd-venv" + .PHONY: serve serve: ## Serve docs at http://localhost:8000 python -m http.server --directory ./docs/_build/html @@ -132,90 +122,59 @@ frontend: ## Compile frontend files npm run frontend -.PHONY: install -install: clean build uninstall ## Build Sphinx extension and install from package - find dist -name "*.whl" -print0 | xargs -0 pip install --upgrade +.PHONY: frontend-dist +frontend-dist: ##- Build frontend files for distribution + npm run build -.PHONY: install-for-development ifd -ifd: install-for-development -install-for-development: clean uninstall ## Clean, uninstall and pip install -e for development (alias ifd) - pip install -r requirements-dev.txt - pip install -e . +.PHONY: watch +watch: + npm run watch -.PHONY: lint -lint: ## Check Python style - flake8 *.py - flake8 sphinx_wagtail_theme - flake8 tests +.PHONY: watchdocs +watchdocs: docs ##- Redo 'docs' and watch for changes (=make sd) + pip install watchdog + watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . -.PHONY: lint-minimal lm -lm: lint-minimal -lint-minimal: ## Check Python style for minimal standards (alias lm) - flake8 *.py --count --select=E9,F63,F7,F82 --show-source --statistics - echo - flake8 sphinx_wagtail_theme --count --select=E9,F63,F7,F82 --show-source --statistics - echo - flake8 tests --count --select=E9,F63,F7,F82 --show-source --statistics - echo - flake8 *.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - echo - flake8 sphinx_wagtail_theme --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - echo - flake8 tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - echo +.PHONY: lint +lint: lint-python lint-frontend ##- Run all linters -.PHONY: release -release: dist ##- Clean, build and upload a release - echo TO BE DONE: twine upload dist/* +.PHONY: lint-python +lint-python: + black --check sphinx_wagtail_theme docs/ tests/ + flake8 *.py + flake8 sphinx_wagtail_theme + flake8 tests -.PHONY: servedocs sd -sd: servedocs -servedocs: docs ##- Redo 'docs' and watch for changes (=make sd) - watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . +.PHONY: lint-frontend +lint-frontend: + npm run lint -.PHONY: setup -setup: setup-python setup-frontend ## Setup all +.PHONY: format +format: format-python format-frontend ##- Run all formatters -.PHONY: setup-frontend -setup-frontend: ##- Setup node modules - npm install +.PHONY: format-python +format-python: + black sphinx_wagtail_theme docs/ tests/ -.PHONY: setup-python -setup-python: ##- Setup Python modules - pip install -U pip - pip install -U -r requirements.txt +.PHONY: format-frontend +format-frontend: + npm run format .PHONY: test -test: ## Run Python tests quickly with pytest +test: pytest - if [ -d dist ]; then find dist -name *.whl -exec twine check {} +; fi - - -.PHONY: test-tox -test-tox: ##- Run tests on every Python version with tox - tox -.PHONY: test-import -test-import: ## Verify the extension is install and can be imported - python3 -c "import sphinx_wagtail_theme as m; print(m.__version__)" - python3 -c "import sphinx_wagtail_theme as m, pprint; pprint.pprint(m.__version_full__)" - .PHONY: test-visual-regression test-visual-regression: ## Run visual regression tests ./node_modules/.bin/percy exec -- python tests/test_visual_regression.py -.PHONY: uninstall ui -ui: uninstall -uninstall: ##- Uninstall the extension - pip uninstall -y sphinx-wagtail-theme - diff --git a/README.md b/README.md index 4dcbb686..abcd8553 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# [Sphinx Wagtail theme](https://sphinx-wagtail-theme.vercel.app/) +# [Sphinx Wagtail theme](https://sphinx-wagtail-theme.readthedocs.io/) [![CI status](https://github.com/wagtail/sphinx_wagtail_theme/workflows/CI/badge.svg)](https://github.com/wagtail/sphinx_wagtail_theme/actions?query=workflow%3ACI) [![PyPI version](https://badge.fury.io/py/sphinx-wagtail-theme.svg)](https://badge.fury.io/py/sphinx-wagtail-theme) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) @@ -40,31 +40,15 @@ html_theme = 'sphinx_wagtail_theme' ### Release process -Checklist: +This section is for maintainer reference. -- [ ] `CONTRIBUTORS.md` is updated -- [ ] `CHANGELOG.md` is updated -- [ ] `setup.cfg` is updated (see `version`) -- [ ] Everything is committed, clean checkout -- [ ] `~/.pypirc` has a username and password (token) -- [ ] Add a git tag at the release commit with the format `X.Y.Z` -- [ ] Create a GitHub release against that tag with the title format `vX.Y.Z` - -With an active virtual environment: - -```sh -python -m pip install --upgrade -r requirements.txt -make clean -make clean-frontend -npm ci -npm run build -prerelease -git tag -a N.N.N -m "N.N.N" -git push origin N.N.N -python -m build -python -m twine upload --repository pypi dist/* -postrelease -``` +1. Check all relevant changes since the last release are documented in `CHANGELOG.md` +2. Check if there are any new contributors and add them to `CONTRIBUTORS.md` +3. Update the version number in `setup.cfg`. The version number should follow [Semantic Versioning](https://semver.org/). +4. Commit and push the changes +5. Create and push a new tag with the version number, prefixed with `v`. For example, `v1.2.3` +6. In the GitHub repository, create a new release against the tag you just pushed. +7. Once the release is created, the CI will automatically publish the new version to PyPI. ## Credits diff --git a/build/.gitkeep b/build/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/conf.py b/docs/conf.py index 55e1a055..830a305e 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,23 +3,23 @@ import sphinx_wagtail_theme -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath("..")) extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.viewcode', - 'sphinx_wagtail_theme', - 'myst_parser', - 'sphinx_copybutton', + "sphinx.ext.autodoc", + "sphinx.ext.viewcode", + "sphinx_wagtail_theme", + "myst_parser", + "sphinx_copybutton", ] -templates_path = ['_templates'] +templates_path = ["_templates"] source_suffix = { - '.rst': 'restructuredtext', - '.txt': 'markdown', - '.md': 'markdown', + ".rst": "restructuredtext", + ".txt": "markdown", + ".md": "markdown", } -master_doc = 'index' -project = 'Sphinx Wagtail theme' +master_doc = "index" +project = "Sphinx Wagtail theme" copyright = "2022, Wagtail contributors" author = "Wagtail" # The short X.Y version. @@ -27,41 +27,53 @@ # The full version, including alpha/beta/rc tags. release = sphinx_wagtail_theme.__version__ language = "en" -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'requirements.txt'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "requirements.txt"] # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False -today_fmt = '%Y-%m-%d %H:%M' +today_fmt = "%Y-%m-%d %H:%M" # -- Options for HTML output ------------------------------------------- -html_theme = 'sphinx_wagtail_theme' +html_theme = "sphinx_wagtail_theme" html_static_path = [] -html_favicon = 'favicon.ico' +html_favicon = "favicon.ico" # -- Options for HTMLHelp output --------------------------------------- -htmlhelp_basename = 'sphinx_wagtail_themedoc' +htmlhelp_basename = "sphinx_wagtail_themedoc" # -- Options for LaTeX output ------------------------------------------ latex_elements = {} latex_documents = [ - (master_doc, 'sphinx_wagtail_theme.tex', - 'Sphinx Wagtail theme documentation', - 'Martin Bless', 'manual'), + ( + master_doc, + "sphinx_wagtail_theme.tex", + "Sphinx Wagtail theme documentation", + "Martin Bless", + "manual", + ), ] # -- Options for manual page output ------------------------------------ man_pages = [ - (master_doc, 'sphinx_wagtail_theme', - 'Sphinx Wagtail theme documentation', - [author], 1) + ( + master_doc, + "sphinx_wagtail_theme", + "Sphinx Wagtail theme documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ---------------------------------------- texinfo_documents = [ - (master_doc, 'sphinx_wagtail_theme', - 'Sphinx Wagtail theme documentation', - author, - 'sphinx_wagtail_theme', - 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "sphinx_wagtail_theme", + "Sphinx Wagtail theme documentation", + author, + "sphinx_wagtail_theme", + "One line description of project.", + "Miscellaneous", + ), ] -github_doc_root = 'https://github.com/wagtail/sphinx_wagtail_theme/tree/main/docs' +github_doc_root = "https://github.com/wagtail/sphinx_wagtail_theme/tree/main/docs" + def setup(app): pass diff --git a/docs/development.rst b/docs/development.rst index 01b3bdd5..1abc7948 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -7,7 +7,7 @@ Development =========== -For local development you need a system with Node v18.x, Python3, and Git. +For local development you need a system with Node v20.x, Python3, and Git. It is strongly recommended to use a Python virtual environment (`venv`_). The build process derives the version from repository data, so it's necessary to clone the repository and not just download a single snapshot. @@ -29,7 +29,7 @@ Install requirements and fulfill Python and Node demands (repeatable) .. code-block:: text - make setup + make install When doing frontend development compile your changes at any time @@ -37,18 +37,6 @@ When doing frontend development compile your changes at any time make frontend -Build and install the package - -.. code-block:: text - - make install - -Build and install the package for development - -.. code-block:: text - - make install-for-development - Don't forget to update the docs. Render the documentation .. code-block:: text @@ -61,31 +49,18 @@ Serve build docs locally make serve -Check the Python code. The CI workflow requires ``lint-minimal`` to succeed +Check the Python code and CSS/JS against the styleguide. .. code-block:: shell - # for local use make lint - # used in the workflow - make lint-minimal - Run Python unit tests .. code-block:: text make test -Rebuild and install from Python wheel package - -.. code-block:: shell - - make install - - # then verify the module can be imported and used - make test-import - To find out whether the created wheel package passes the `twine check` test and can be uploaded to PyPi run @@ -106,7 +81,7 @@ rather than using the shortcuts in the Makefile. Assume the commands below are all run in PowerShell. These instructions will also work on Mac or Linux without make installed as well. -First, be sure to install Python 3, and Node 18. +First, be sure to install Python 3, and Node 20. `fnm `_ is really useful for managing multiple versions of Node on Windows. diff --git a/requirements-dev.txt b/requirements-dev.txt index c8518430..adbf0f1b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,11 +5,8 @@ build docutils flake8 +black>=24,<=25 percy-selenium -pip pytest selenium -setuptools twine -wheel -zest.releaser diff --git a/setup.cfg b/setup.cfg index 59fb68bd..09e98b15 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,10 +30,6 @@ python_requires = >=3.8 include_package_data = True -[bdist_wheel] -universal = 1 - - [flake8] exclude = .*,docs,node_modules,CVS,__pycache__,*.egg,*GENERATED* max-line-length = 127 diff --git a/sphinx_wagtail_theme/__init__.py b/sphinx_wagtail_theme/__init__.py index 1b2319bf..5e21ca8b 100644 --- a/sphinx_wagtail_theme/__init__.py +++ b/sphinx_wagtail_theme/__init__.py @@ -33,14 +33,14 @@ def update_context(app, pagename, templatename, context, doctree): `page.html`. """ - context['theme_version'] = __version__ - return app.builder.env.metadata.get(pagename, {}).get('template') + context["theme_version"] = __version__ + return app.builder.env.metadata.get(pagename, {}).get("template") def setup(app): """Setup functionality called by Sphinx""" - app.connect('html-page-context', update_context) - if hasattr(app, 'add_html_theme'): + app.connect("html-page-context", update_context) + if hasattr(app, "add_html_theme"): theme_path = os.path.abspath(os.path.dirname(__file__)) app.add_html_theme("sphinx_wagtail_theme", theme_path) # unconfirmed: just assuming that parallel_write_safe is ok diff --git a/tests/test_visual_regression.py b/tests/test_visual_regression.py index 8bca245f..24b17a79 100644 --- a/tests/test_visual_regression.py +++ b/tests/test_visual_regression.py @@ -4,7 +4,7 @@ import percy from selenium import webdriver -from selenium.webdriver.firefox import options as firefox_options +from selenium.webdriver.firefox.options import Options as FirefoxOptions BASE_DIR = pathlib.Path(__file__).parent.parent.resolve() @@ -25,7 +25,7 @@ def main(): exit(1) handler_class = DocsHTTPRequestHandler - server_address = ('127.0.0.1', 8000) + server_address = ("127.0.0.1", 8000) httpd = server.HTTPServer(server_address, handler_class) @@ -33,8 +33,8 @@ def main(): server_thread.start() print("Server thread running. Starting client requests...") - options = firefox_options.Options() - options.headless = True + options = FirefoxOptions() + options.add_argument("--headless") driver = webdriver.Firefox(options=options) def take_snapshot(url, title):