Skip to content

Commit d91d765

Browse files
committed
Merge branch '0.x' into markpeek-description-escape
# Conflicts: # sphinxext/opengraph/_description_parser.py # tests/test_options.py
2 parents e99c587 + cf768c8 commit d91d765

File tree

62 files changed

+1915
-1195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1915
-1195
lines changed

.github/workflows/builddoc.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Render documentation
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
env:
16+
FORCE_COLOR: "1"
17+
UV_SYSTEM_PYTHON: "1" # make uv do global installs
18+
19+
jobs:
20+
docs:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3"
31+
- name: Install uv
32+
uses: astral-sh/setup-uv@v5
33+
with:
34+
version: latest
35+
enable-cache: false
36+
- name: Install dependencies
37+
run: uv pip install . --group docs
38+
- name: Render the documentation
39+
run: >
40+
python -m sphinx
41+
build -M html
42+
./docs
43+
./docs/build
44+
--jobs=auto
45+
--show-traceback
46+
--fail-on-warning
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Create release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
env:
17+
FORCE_COLOR: "1"
18+
UV_SYSTEM_PYTHON: "1" # make uv do global installs
19+
20+
jobs:
21+
publish-pypi:
22+
runs-on: ubuntu-latest
23+
name: PyPI Release
24+
environment: release
25+
if: github.repository_owner == 'sphinx-doc'
26+
permissions:
27+
attestations: write # for actions/attest
28+
id-token: write # for actions/attest & PyPI trusted publishing
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
persist-credentials: false
33+
- name: Set up Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: "3"
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
39+
with:
40+
version: latest
41+
enable-cache: false
42+
43+
- name: Install build dependencies (pypa/build, twine)
44+
run: uv pip install --group package
45+
46+
- name: Build distribution
47+
run: python -m build
48+
49+
- name: Check distribution
50+
run: twine check dist/*
51+
52+
- name: Create Sigstore attestations for built distributions
53+
uses: actions/attest@v1
54+
id: attest
55+
with:
56+
subject-path: "dist/*"
57+
predicate-type: "https://docs.pypi.org/attestations/publish/v1"
58+
predicate: "null"
59+
show-summary: "true"
60+
61+
- name: Convert attestations to PEP 740
62+
run: >
63+
python utils/convert_attestations.py
64+
"$BUNDLE_PATH"
65+
"$SIGNER_IDENTITY"
66+
env:
67+
BUNDLE_PATH: "${{ steps.attest.outputs.bundle-path }}"
68+
# workflow_ref example: sphinx-doc/sphinxext-opengraph/.github/workflows/create-release.yml@refs/heads/master
69+
# this forms the "signer identity" for the attestations
70+
SIGNER_IDENTITY: "https://github.com/${{ github.workflow_ref }}"
71+
72+
- name: Inspect PEP 740 attestations
73+
run: pypi-attestations inspect dist/*.publish.attestation
74+
75+
- name: Prepare attestation bundles for uploading
76+
run: |
77+
mkdir -p /tmp/attestation-bundles
78+
cp "$BUNDLE_PATH" /tmp/attestation-bundles/
79+
cp dist/*.publish.attestation /tmp/attestation-bundles/
80+
env:
81+
BUNDLE_PATH: "${{ steps.attest.outputs.bundle-path }}"
82+
83+
- name: Upload attestation bundles
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: attestation-bundles
87+
path: /tmp/attestation-bundles/
88+
89+
- name: Upload to PyPI
90+
env:
91+
TWINE_NON_INTERACTIVE: "true"
92+
run: |
93+
twine upload dist/* --attestations --verbose
94+
95+
github-release:
96+
runs-on: ubuntu-latest
97+
name: GitHub release
98+
environment: release
99+
if: github.repository_owner == 'sphinx-doc'
100+
permissions:
101+
contents: write # for softprops/action-gh-release to create GitHub release
102+
steps:
103+
- uses: actions/checkout@v4
104+
with:
105+
persist-credentials: false
106+
- name: Get release version
107+
id: get_version
108+
uses: actions/github-script@v7
109+
with:
110+
script: core.setOutput('version', context.ref.replace("refs/tags/v", ""))
111+
112+
- name: Create GitHub release
113+
uses: softprops/action-gh-release@v2
114+
if: startsWith(github.ref, 'refs/tags/')
115+
with:
116+
name: "sphinxext-opengraph ${{ steps.get_version.outputs.version }}"
117+
body: ""

.github/workflows/lint.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
env:
16+
FORCE_COLOR: "1"
17+
UV_SYSTEM_PYTHON: "1" # make uv do global installs
18+
19+
jobs:
20+
ruff:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
28+
- name: Install Ruff
29+
uses: astral-sh/ruff-action@v3
30+
with:
31+
args: --version
32+
33+
- name: Lint with Ruff
34+
run: ruff check --output-format=github
35+
36+
- name: Format with Ruff
37+
run: ruff format --diff
38+
39+
twine:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
with:
45+
persist-credentials: false
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: "3"
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v5
52+
with:
53+
version: latest
54+
enable-cache: false
55+
- name: Install dependencies
56+
run: uv pip install --group package
57+
- name: Lint with twine
58+
run: |
59+
python -m build .
60+
twine check dist/*

.github/workflows/lock.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Lock old threads
2+
3+
on:
4+
schedule:
5+
# Run at midnight daily
6+
- cron: "0 0 * * *"
7+
workflow_dispatch:
8+
9+
permissions: {}
10+
11+
jobs:
12+
action:
13+
runs-on: ubuntu-latest
14+
if: github.repository_owner == 'sphinx-doc'
15+
permissions:
16+
# to lock issues and PRs
17+
issues: write
18+
pull-requests: write
19+
steps:
20+
- uses: actions/github-script@v7
21+
with:
22+
retries: 3
23+
# language=JavaScript
24+
script: |
25+
const _FOUR_WEEKS_MILLISECONDS = 28 * 24 * 60 * 60 * 1000;
26+
const _FOUR_WEEKS_DATE = new Date(Date.now() - _FOUR_WEEKS_MILLISECONDS);
27+
const FOUR_WEEKS_AGO = `${_FOUR_WEEKS_DATE.toISOString().substring(0, 10)}T00:00:00Z`;
28+
const OWNER = context.repo.owner;
29+
const REPO = context.repo.repo;
30+
31+
try {
32+
for (const thread_type of ["issue", "pr"]) {
33+
core.debug(`Finding ${thread_type}s to lock`);
34+
const query = thread_type === "issue"
35+
? `repo:${OWNER}/${REPO} updated:<${FOUR_WEEKS_AGO} is:closed is:unlocked is:issue`
36+
: `repo:${OWNER}/${REPO} updated:<${FOUR_WEEKS_AGO} is:closed is:unlocked is:pr`;
37+
core.debug(`Using query '${query}'`);
38+
// https://octokit.github.io/rest.js/v21/#search-issues-and-pull-requests
39+
const {data: {items: results}} = await github.rest.search.issuesAndPullRequests({
40+
q: query,
41+
order: "desc",
42+
sort: "updated",
43+
per_page: 100,
44+
});
45+
for (const item of results) {
46+
if (item.locked) continue;
47+
const thread_num = item.number;
48+
core.debug(`Locking #${thread_num} (${thread_type})`);
49+
// https://octokit.github.io/rest.js/v21/#issues-lock
50+
await github.rest.issues.lock({
51+
owner: OWNER,
52+
repo: REPO,
53+
issue_number: thread_num,
54+
lock_reason: "resolved",
55+
});
56+
}
57+
}
58+
} catch (err) {
59+
core.setFailed(err.message);
60+
}

.github/workflows/test.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
paths:
6+
- ".github/workflows/test.yml"
7+
- "sphinxext/**"
8+
- "tests/**"
9+
pull_request:
10+
paths:
11+
- ".github/workflows/test.yml"
12+
- "sphinxext/**"
13+
- "tests/**"
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
20+
cancel-in-progress: true
21+
22+
env:
23+
FORCE_COLOR: "1"
24+
PYTHONDEVMODE: "1" # -X dev
25+
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
26+
UV_SYSTEM_PYTHON: "1" # make uv do global installs
27+
28+
jobs:
29+
test:
30+
runs-on: ${{ matrix.os }}
31+
name: ${{ matrix.os }} (Python ${{ matrix.python }}; Sphinx ${{ matrix.sphinx-version }})
32+
timeout-minutes: 15
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
os:
37+
- "ubuntu-latest"
38+
python:
39+
- "3.9"
40+
- "3.10"
41+
- "3.11"
42+
- "3.12"
43+
- "3.13"
44+
- "3.13t"
45+
sphinx-version:
46+
- "6"
47+
- "7"
48+
- "8"
49+
exclude:
50+
- python: "3.9"
51+
sphinx-version: "8"
52+
include:
53+
- python: "3.13"
54+
sphinx-version: "8"
55+
os: "windows-latest"
56+
- python: "3.13"
57+
sphinx-version: "8"
58+
os: "macos-latest"
59+
60+
steps:
61+
- uses: actions/checkout@v4
62+
with:
63+
persist-credentials: false
64+
- name: Set up Python ${{ matrix.python }}
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: ${{ matrix.python }}
68+
- name: Check Python version
69+
run: python --version --version
70+
- name: Export UV_PYTHON
71+
run: echo "UV_PYTHON=$(which python)" >> $GITHUB_ENV
72+
- name: Install uv
73+
uses: astral-sh/setup-uv@v5
74+
with:
75+
version: latest
76+
enable-cache: false
77+
- name: Install dependencies
78+
run: uv pip install . --group test
79+
- name: Install Sphinx ${{ matrix.sphinx-version }}
80+
run: uv pip install --upgrade "Sphinx~=${{ matrix.sphinx-version }}.0"
81+
- name: Test with pytest
82+
run: python -m pytest -vv
83+
env:
84+
PYTHONWARNINGS: "error,ignore::DeprecationWarning:sphinx.builders.gettext" # treat all warnings as errors
85+
- name: Install social-cards extra
86+
run: uv pip install .[social-cards]
87+
- name: Test with pytest (social-cards)
88+
run: python -m pytest -vv
89+
env:
90+
PYTHONWARNINGS: "error,ignore::EncodingWarning:matplotlib.font_manager,ignore::DeprecationWarning:sphinx.builders.gettext" # treat all warnings as errors

0 commit comments

Comments
 (0)