Skip to content

Commit cba0938

Browse files
hugovkTheTripleV
andauthored
Test multiple Sphinx and OS versions (#70)
* 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>
1 parent be9a41d commit cba0938

File tree

6 files changed

+95
-44
lines changed

6 files changed

+95
-44
lines changed

.github/workflows/workflow.yml

Lines changed: 80 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,112 @@
11
name: Test and Deploy
22
on:
33
pull_request:
4-
branches:
5-
- main
6-
push:
74
branches:
85
- main
6+
push:
97
create:
108
tags:
119
- '*'
1210
jobs:
1311
check:
1412
runs-on: ubuntu-latest
1513
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-python@v2
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v4
1816
with:
19-
python-version: 3.8
17+
python-version: '3.x'
18+
cache: pip
19+
cache-dependency-path: .github/workflows/workflow.yml
2020
- name: Black
2121
run: |
2222
pip install black
2323
black --check --exclude /docs --diff .
2424
25-
test-extension:
25+
build-wheel:
2626
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Set up Python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: "3.7"
33+
cache: pip
34+
cache-dependency-path: |
35+
.github/workflows/workflow.yml
36+
dev-requirements.txt
37+
- name: Install dependencies
38+
run: |
39+
set -xe
40+
python -VV
41+
python -m site
42+
python -m pip install --upgrade pip setuptools wheel
43+
python -m pip install -r dev-requirements.txt
44+
- name: Install package
45+
run: |
46+
python -m pip install .
47+
- name: Build wheel
48+
run: |
49+
python -m pip install build
50+
python -m build
51+
- name: Upload wheel as artifact
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: my-wheel
55+
path: dist/*.whl
56+
57+
test:
58+
needs: build-wheel
59+
runs-on: ${{ matrix.os }}
2760
strategy:
61+
fail-fast: false
2862
matrix:
29-
python-version: ['3.6', '3.7', '3.8', '3.9', 'pypy3']
63+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11-dev', 'pypy3.8']
64+
sphinx-version: ['>=4,<5', '>=5,<6', '>=6a0,<7']
65+
os: [windows-latest, macos-latest, ubuntu-latest]
66+
exclude:
67+
# Sphinx 6 supports 3.8+
68+
- { python-version: '3.7', sphinx-version: '>=6a0,<7' }
3069
steps:
31-
- uses: actions/checkout@v2
32-
- name: Setup Python
33-
uses: actions/setup-python@v2
70+
- uses: actions/checkout@v3
71+
- name: Set up Python ${{ matrix.python-version }}
72+
uses: actions/setup-python@v4
3473
with:
3574
python-version: ${{ matrix.python-version }}
75+
cache: pip
76+
cache-dependency-path: |
77+
.github/workflows/workflow.yml
78+
dev-requirements.txt
3679
- name: Install dependencies
3780
run: |
38-
set -xe
3981
python -VV
4082
python -m site
4183
python -m pip install --upgrade pip setuptools wheel
4284
python -m pip install -r dev-requirements.txt
43-
- name: Install Package
85+
python -m pip install "sphinx${{ matrix.sphinx-version }}"
86+
- name: Download wheel artifact
87+
uses: actions/download-artifact@v3
88+
with:
89+
name: my-wheel
90+
path: dist
91+
- name: Install downloaded wheel
4492
run: |
45-
python -m pip install .
46-
- name: Run Tests for ${{ matrix.python-version }}
93+
python -m pip install dist/sphinxext_opengraph-main-py3-none-any.whl
94+
- name: Run tests for ${{ matrix.python-version }}
4795
run: |
4896
python -m pytest -vv
4997
5098
build-docs:
5199
runs-on: ubuntu-latest
52100
steps:
53-
- uses: actions/checkout@v2
101+
- uses: actions/checkout@v3
54102
with:
55103
fetch-depth: 0
56104
- name: Setup Python
57-
uses: actions/setup-python@v2
105+
uses: actions/setup-python@v4
106+
with:
107+
python-version: '3.x'
108+
cache: pip
109+
cache-dependency-path: docs/requirements.txt
58110
- name: Install dependencies
59111
run: |
60112
pip install -r docs/requirements.txt
@@ -66,23 +118,22 @@ jobs:
66118
pypi-release:
67119
needs: test-extension
68120
runs-on: ubuntu-latest
69-
if: contains(github.ref, 'refs/tags/') && github.repository_owner == 'wpilibsuite'
121+
if: contains(github.ref, 'refs/tags/') && github.repository_owner == 'wpilibsuite'
70122
steps:
71-
- uses: actions/checkout@v2
123+
- uses: actions/checkout@v3
72124
with:
73125
fetch-depth: 0
74126
- name: Set up Python
75-
uses: actions/setup-python@v2
127+
uses: actions/setup-python@v4
76128
with:
77-
python-version: '3.7'
78-
- name: Install Dependencies
79-
run: |
80-
python -m pip install --upgrade pip
81-
pip install -r ./dev-requirements.txt
82-
- name: Build PyPI Wheel
83-
run: |
84-
python setup.py sdist
85-
python setup.py bdist_wheel
129+
python-version: '3.x'
130+
cache: pip
131+
cache-dependency-path: dev-requirements.txt
132+
- name: Download wheel artifact
133+
uses: actions/download-artifact@v3
134+
with:
135+
name: my-wheel
136+
path: dist
86137
- name: Publish a Python distribution to PyPI
87138
uses: pypa/gh-action-pypi-publish@master
88139
with:

dev-requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sphinx
2-
wheel==0.34.2
3-
pytest==5.4.3
4-
beautifulsoup4==4.9.1
5-
setuptools==47.3.1
2+
wheel==0.37.1
3+
pytest==7.1.3
4+
beautifulsoup4==4.11.1
5+
setuptools==65.4.1

docs/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
myst-parser==0.15.2
2-
furo==2021.11.12.1
3-
sphinx==4.2.0
1+
myst-parser==0.18.1
2+
furo==2022.9.29
3+
sphinx==5.2.3
44
./

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
try:
88
ret = subprocess.run(
99
"git describe --tags --abbrev=0",
10-
stdout=subprocess.PIPE,
11-
stderr=subprocess.PIPE,
10+
capture_output=True,
1211
check=True,
1312
shell=True,
1413
)
1514
version = ret.stdout.decode("utf-8").strip()
1615
except:
1716
version = "main"
1817

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

2221
setuptools.setup(
@@ -29,7 +28,7 @@
2928
long_description_content_type="text/markdown",
3029
url="https://github.com/wpilibsuite/sphinxext-opengraph",
3130
license="LICENSE.md",
32-
install_requires=["sphinx>=2.0"],
31+
install_requires=["sphinx>=4.0"],
3332
packages=["sphinxext/opengraph"],
3433
classifiers=[
3534
"Development Status :: 5 - Production/Stable",
@@ -40,16 +39,17 @@
4039
"License :: OSI Approved :: BSD License",
4140
"Natural Language :: English",
4241
"Operating System :: OS Independent",
43-
"Programming Language :: Python :: 3.6",
4442
"Programming Language :: Python :: 3.7",
4543
"Programming Language :: Python :: 3.8",
4644
"Programming Language :: Python :: 3.9",
45+
"Programming Language :: Python :: 3.10",
46+
"Programming Language :: Python :: 3.11",
4747
"Programming Language :: Python",
4848
"Topic :: Documentation :: Sphinx",
4949
"Topic :: Documentation",
5050
"Topic :: Software Development :: Documentation",
5151
"Topic :: Text Processing",
5252
"Topic :: Utilities",
5353
],
54-
python_requires=">=3.6",
54+
python_requires=">=3.7",
5555
)

sphinxext/opengraph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_tags(
7272
parse_result = urlparse(config["html_baseurl"])
7373

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

7777
# Grab root url from canonical url
7878
config["ogp_site_url"] = urlunparse(

tests/test_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

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

1010

1111
def get_tag_content(tags, tag_type):

0 commit comments

Comments
 (0)