Skip to content

Commit

Permalink
Test multiple Sphinx and OS versions (#70)
Browse files Browse the repository at this point in the history
* Bump GitHub Actions

* Bump docs requirements to fix CI

* Fix invalid format of Python version for PyPy

* Bump dev dependencies

* Add support for Python 3.10 and 3.11

* Drop support for EOL Python 3.6

* Upgrade Python syntax with pyupgrade --py37-plus

* Allow testing feature branches to improve PR quality

* Test multiple Sphinx versions

* If one job fails, allow the others to continue

* Cache pip's downloads

* Build and upload wheel as artifact, then download and test wheel

* Sphinx 6 supports Python 3.8+

* Drop support for old Sphinx 2 and 3

* Test Windows, macOS as well as Ubuntu

* Test latest Sphinx 6 version

* Update .github/workflows/workflow.yml

Co-authored-by: Vasista Vovveti <vasistavovveti@gmail.com>
  • Loading branch information
hugovk and TheTripleV committed Oct 21, 2022
1 parent be9a41d commit cba0938
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 44 deletions.
109 changes: 80 additions & 29 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,112 @@
name: Test and Deploy
on:
pull_request:
branches:
- main
push:
branches:
- main
push:
create:
tags:
- '*'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.x'
cache: pip
cache-dependency-path: .github/workflows/workflow.yml
- name: Black
run: |
pip install black
black --check --exclude /docs --diff .
test-extension:
build-wheel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
cache: pip
cache-dependency-path: |
.github/workflows/workflow.yml
dev-requirements.txt
- name: Install dependencies
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r dev-requirements.txt
- name: Install package
run: |
python -m pip install .
- name: Build wheel
run: |
python -m pip install build
python -m build
- name: Upload wheel as artifact
uses: actions/upload-artifact@v3
with:
name: my-wheel
path: dist/*.whl

test:
needs: build-wheel
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', 'pypy3']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11-dev', 'pypy3.8']
sphinx-version: ['>=4,<5', '>=5,<6', '>=6a0,<7']
os: [windows-latest, macos-latest, ubuntu-latest]
exclude:
# Sphinx 6 supports 3.8+
- { python-version: '3.7', sphinx-version: '>=6a0,<7' }
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
.github/workflows/workflow.yml
dev-requirements.txt
- name: Install dependencies
run: |
set -xe
python -VV
python -m site
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r dev-requirements.txt
- name: Install Package
python -m pip install "sphinx${{ matrix.sphinx-version }}"
- name: Download wheel artifact
uses: actions/download-artifact@v3
with:
name: my-wheel
path: dist
- name: Install downloaded wheel
run: |
python -m pip install .
- name: Run Tests for ${{ matrix.python-version }}
python -m pip install dist/sphinxext_opengraph-main-py3-none-any.whl
- name: Run tests for ${{ matrix.python-version }}
run: |
python -m pytest -vv
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: pip
cache-dependency-path: docs/requirements.txt
- name: Install dependencies
run: |
pip install -r docs/requirements.txt
Expand All @@ -66,23 +118,22 @@ jobs:
pypi-release:
needs: test-extension
runs-on: ubuntu-latest
if: contains(github.ref, 'refs/tags/') && github.repository_owner == 'wpilibsuite'
if: contains(github.ref, 'refs/tags/') && github.repository_owner == 'wpilibsuite'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./dev-requirements.txt
- name: Build PyPI Wheel
run: |
python setup.py sdist
python setup.py bdist_wheel
python-version: '3.x'
cache: pip
cache-dependency-path: dev-requirements.txt
- name: Download wheel artifact
uses: actions/download-artifact@v3
with:
name: my-wheel
path: dist
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
Expand Down
8 changes: 4 additions & 4 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx
wheel==0.34.2
pytest==5.4.3
beautifulsoup4==4.9.1
setuptools==47.3.1
wheel==0.37.1
pytest==7.1.3
beautifulsoup4==4.11.1
setuptools==65.4.1
6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
myst-parser==0.15.2
furo==2021.11.12.1
sphinx==4.2.0
myst-parser==0.18.1
furo==2022.9.29
sphinx==5.2.3
./
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
try:
ret = subprocess.run(
"git describe --tags --abbrev=0",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
capture_output=True,
check=True,
shell=True,
)
version = ret.stdout.decode("utf-8").strip()
except:
version = "main"

with open("README.md", "r", encoding="utf-8") as readme:
with open("README.md", encoding="utf-8") as readme:
long_description = readme.read()

setuptools.setup(
Expand All @@ -29,7 +28,7 @@
long_description_content_type="text/markdown",
url="https://github.com/wpilibsuite/sphinxext-opengraph",
license="LICENSE.md",
install_requires=["sphinx>=2.0"],
install_requires=["sphinx>=4.0"],
packages=["sphinxext/opengraph"],
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand All @@ -40,16 +39,17 @@
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python",
"Topic :: Documentation :: Sphinx",
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
"Topic :: Text Processing",
"Topic :: Utilities",
],
python_requires=">=3.6",
python_requires=">=3.7",
)
2 changes: 1 addition & 1 deletion sphinxext/opengraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_tags(
parse_result = urlparse(config["html_baseurl"])

if config["html_baseurl"] is None:
raise EnvironmentError("ReadTheDocs did not provide a valid canonical URL!")
raise OSError("ReadTheDocs did not provide a valid canonical URL!")

# Grab root url from canonical url
config["ogp_site_url"] = urlunparse(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def get_tag(tags, tag_type):
return [tag for tag in tags if tag.get("property") == "og:{}".format(tag_type)][0]
return [tag for tag in tags if tag.get("property") == f"og:{tag_type}"][0]


def get_tag_content(tags, tag_type):
Expand Down

0 comments on commit cba0938

Please sign in to comment.