Skip to content

Commit bb4447b

Browse files
committed
docs: Run doc tests only on release workflow.
1 parent 9966b68 commit bb4447b

4 files changed

Lines changed: 14 additions & 22 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
run: pip install -e .[test]
3232

3333
- name: Run tests
34-
run: pytest --ignore=tests/test_docs_publishing.py -k "not example"
34+
run: pytest tests --ignore-glob='tests/test_docs_*.py' -k "not example"
35+
env:
36+
API_KEY: ${{ secrets.API_KEY }}
37+
38+
- name: Run example tests
39+
if: matrix.python-version == '3.14'
40+
run: pytest tests/example_search_*_test.py
3541
env:
3642
API_KEY: ${{ secrets.API_KEY }}

‎.github/workflows/docs.yml‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches: [master]
66
tags: ['v**']
7-
pull_request:
8-
branches: [master]
97
workflow_dispatch:
108

119
permissions:
@@ -15,9 +13,7 @@ jobs:
1513
live-examples:
1614
name: Live documentation examples
1715
if: >-
18-
github.actor != 'dependabot[bot]' &&
19-
(github.event_name != 'pull_request' ||
20-
github.event.pull_request.head.repo.full_name == github.repository)
16+
github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')
2117
runs-on: ubuntu-latest
2218
timeout-minutes: 30
2319
steps:
@@ -51,9 +47,6 @@ jobs:
5147
build:
5248
name: Build Sphinx documentation
5349
needs: [live-examples]
54-
if: >-
55-
always() && !cancelled() &&
56-
(needs.live-examples.result == 'success' || needs.live-examples.result == 'skipped')
5750
runs-on: ubuntu-latest
5851
steps:
5952
- uses: actions/checkout@v6
@@ -77,11 +70,6 @@ jobs:
7770
.venv/bin/python -m pytest tests/test_docs_examples.py
7871
tests/test_docs_example_runner.py -k 'not live' -q
7972
80-
- name: Explain unavailable live checks
81-
if: needs.live-examples.result == 'skipped'
82-
run: >-
83-
echo '::notice::Live docs checks need API_KEY and do not run on fork or Dependabot PRs. Run the reviewed revision with a key before merging.'
84-
8573
- name: Build HTML documentation
8674
run: .venv/bin/sphinx-build -M html docs docs/_build -W --keep-going
8775

‎.readthedocs.yaml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ build:
77
jobs:
88
pre_build:
99
- python -m scripts.check_docs_revision
10-
- python -m pytest tests/test_docs_examples.py tests/test_docs_example_runner.py -k 'not live' -q
1110
post_build:
1211
- python -m scripts.check_docs_revision
1312

@@ -26,4 +25,3 @@ python:
2625
path: .
2726
extras:
2827
- docs
29-
- test

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ In PowerShell, use `$env:API_KEY = $env:SERPAPI_KEY`. Keep real keys out of sour
5252
To match the test selection in the SDK CI workflow:
5353

5454
```sh
55-
python -m pytest --ignore=tests/test_docs_publishing.py -k 'not example' -q
55+
python -m pytest tests --ignore-glob='tests/test_docs_*.py' -k 'not example' -q
5656
```
5757

5858
This includes live account, location, search, and pagination checks. To run every discovered test, including the standalone engine examples and documentation examples:
@@ -61,7 +61,7 @@ This includes live account, location, search, and pagination checks. To run ever
6161
python -m pytest -q
6262
```
6363

64-
Both commands make real SerpApi requests. The full suite can use more searches than a test run limited to the files you changed.
64+
Both commands make real SerpApi requests. The full suite can use more searches than a test run limited to the files you changed. PR CI also runs the standalone engine examples on Python 3.14. Documentation tests run only in the package and documentation release workflows, on `master` or release tags.
6565

6666
### Testing documentation examples
6767

@@ -146,25 +146,25 @@ The files are written to `dist/`. Documentation sources, this guide, and the log
146146

147147
## Documentation publishing
148148

149-
The [documentation workflow](.github/workflows/docs.yml) runs the live examples before building HTML and EPUB on pull requests from this repository, pushes to `master`, and release tags. Fork and Dependabot PRs run the checks that need no key and build the docs; their live job is shown as skipped because GitHub does not provide the secret. Run the reviewed revision with a key before merging those PRs.
149+
The [documentation workflow](.github/workflows/docs.yml) runs the live examples before building HTML and EPUB on pushes to `master`, release tags, and manual runs on either ref. It does not run on pull requests.
150150

151151
After the live examples and documentation build pass, the same workflow publishes to Read the Docs for `master` and `v*` release tags. PR runs never publish. The publishing job uses the `docs` GitHub environment and its `RTD_API_TOKEN` secret. The SerpApi key stays in GitHub as the existing `API_KEY` repository or organization secret.
152152

153153
The workflow syncs RTD versions, activates the requested version if needed, and waits for the build to finish. `latest` tracks `master`. A release tag has its own version and also updates `stable` when RTD identifies it as the highest stable release. RTD still builds the site from the repository using [.readthedocs.yaml](.readthedocs.yaml); it does not receive the HTML artifact from GitHub. Documentation publishing runs independently of the PyPI release workflow.
154154

155-
Before requesting a build, the workflow creates a temporary RTD environment variable named `DOCS_CI_REVISION`. It contains the tested commit, the permitted versions, and an expiration time. RTD checks this record against its checkout before and after the Sphinx build. A missing, expired, or different revision stops publication. RTD runs only offline tests and needs no SerpApi key. The workflow removes the temporary record after publishing, including when a build fails. Publishing jobs run one at a time so they cannot overwrite each other's revision record.
155+
Before requesting a build, the workflow creates a temporary RTD environment variable named `DOCS_CI_REVISION`. It contains the tested commit, the permitted versions, and an expiration time. RTD checks this record against its checkout before and after the Sphinx build. A missing, expired, or different revision stops publication. RTD needs no SerpApi key. The workflow removes the temporary record after publishing, including when a build fails. Publishing jobs run one at a time so they cannot overwrite each other's revision record.
156156

157157
### Maintainer setup
158158

159159
Maintainers can configure the existing RTD project and GitHub environment with these steps:
160160

161161
1. In RTD **Settings**, set **Connected repository** to **No connected repository** and keep **Repository URL** set to `https://github.com/serpapi/serpapi-python.git`. Set **Default branch** to `master` and the configuration file path to `.readthedocs.yaml`. The public repository URL lets RTD clone the source without receiving GitHub push events through the GitHub App.
162162
2. Under RTD **Integrations**, remove incoming GitHub webhook integrations for this project. If an older RTD webhook is also listed in the GitHub repository's **Settings > Webhooks**, disable or remove that webhook. Do not remove integrations for other projects.
163-
3. Under RTD **Automation Rules**, remove rules that activate new versions or change the default version. The workflow handles release activation. Under **Settings > Pull request builds**, turn off **Build pull requests for this project**. GitHub Actions still checks PRs and saves the built HTML as a workflow artifact.
163+
3. Under RTD **Automation Rules**, remove rules that activate new versions or change the default version. The workflow handles release activation. Under **Settings > Pull request builds**, turn off **Build pull requests for this project**. GitHub Actions runs the existing SDK and engine example tests on PRs.
164164
4. Under RTD **Environment Variables**, remove `API_KEY` or `SERPAPI_KEY` if you added either for docs tests. Do not add the RTD API token here. The workflow manages `DOCS_CI_REVISION` automatically.
165165
5. Keep `latest` active in **Versions** and use it as the default documentation version during this migration. Existing release tags contain their original docs and build configuration. After the first release containing these changes builds successfully, you can choose `stable` as the default version.
166166
6. Create an RTD API token in your [RTD profile settings](https://app.readthedocs.org/accounts/tokens/), using an account that maintains the `serpapi-python` project. In GitHub, open the repository's **Settings > Environments**, create an environment named `docs`, and add an environment secret named `RTD_API_TOKEN` with that value. Under **Deployment branches and tags**, select **Selected branches and tags** and add a Branch rule for `master` and a Tag rule for `v*`. Leave required reviewers and wait timers disabled if publishing should run without a manual approval.
167-
7. Merge the changes to `master`. In GitHub **Actions > Documentation**, follow **Live documentation examples**, **Build Sphinx documentation**, and **Publish Read the Docs**. The publishing log links to the RTD build. To retry publishing, run the Documentation workflow on `master` or the intended release tag. A manual run on another branch checks the docs but does not publish.
167+
7. Merge the changes to `master`. In GitHub **Actions > Documentation**, follow **Live documentation examples**, **Build Sphinx documentation**, and **Publish Read the Docs**. The publishing log links to the RTD build. To retry publishing, run the Documentation workflow on `master` or the intended release tag. A manual run on another branch skips the documentation jobs.
168168

169169
Use GitHub Actions to request builds after this setup. A manual RTD build has no CI revision record and will fail the revision check. If a branch or tag moves between testing and the RTD checkout, rerun the workflow for its current commit. Pushing a `v*` tag also starts the PyPI release workflow, so use an actual package release to test release documentation.
170170

0 commit comments

Comments
 (0)