Skip to content

Commit eba1e71

Browse files
kevalmorabia97grzegorz-k-karch
authored andcommitted
fix: prevent gh-pages repo bloat from doc preview artifacts (#1309)
### What does this PR do? Type of change: Bug fix Fixes gh-pages branch bloat that grew from ~26 MB to ~441 MB in four weeks (nvbug 6099503). Three compounding causes were identified and addressed: 1. **Sphinx `.doctrees/` cache published to gh-pages** — `sphinx-build` was writing its build cache inside `build/html/` which was then uploaded verbatim. Accounts for ~3.3 GB uncompressed across history. 2. **`JamesIves/github-pages-deploy-action` appending a commit on every push** — main-site files accumulated forever with `single-commit: false` (default). 3. **PR preview deploying on every `synchronize` event for all PRs** — `rossjrw/pr-preview-action` re-deployed the full site for every push to any PR regardless of whether docs changed (e.g. PR #1128 triggered 64 preview deploys × ~11 MB each). Changes: - Pass `-d /tmp/doctrees` to `sphinx-build` so `.doctrees/` is never written into `build/html/` - Add `paths: [docs/**, modelopt/**]` filter to `pull_request` trigger so the docs workflow only runs on PRs that touch docs or source code - Set `single-commit: true` on the deploy action so main-site pushes squash into one commit - Deduplicate docs build: `deploy-preview` now downloads the artifact from `build-docs` instead of running a second `sphinx-build` - Set `retention-days: 1` on the artifact since it is only needed for the duration of the workflow run The one-time cleanup (force-push squashed orphan to gh-pages) was already applied separately — repo is now ~59 MB for a full clone vs ~441 MB before. ### Usage N/A — CI/workflow change only. ### Testing - Workflow logic reviewed manually. - The one-time cleanup was verified: `git rev-list --objects --disk-usage origin/gh-pages` now reports ~28 MB; full clone is ~59 MB. ### Before your PR is "*Ready for review*" - Is this change backward compatible?: ✅ - If you copied code from any other sources or added a new PIP dependency, did you follow guidance in `CONTRIBUTING.md`: N/A - Did you write any new necessary tests?: N/A - Did you update [Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?: N/A ### Additional Information nvbug 6099503 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Optimized documentation build and deployment workflow in CI/CD pipeline. * Improved pull request documentation preview handling with faster build timeouts and refined artifact management. * Enhanced GitHub Pages deployment configuration for better consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Keval Morabia <28916987+kevalmorabia97@users.noreply.github.com> Signed-off-by: Grzegorz Karch <gkarch@nvidia.com>
1 parent 19d4102 commit eba1e71

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

.github/workflows/pages.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,55 @@ permissions:
2323

2424
jobs:
2525
build-docs:
26+
if: github.event.action != 'closed'
2627
runs-on: ubuntu-latest
27-
timeout-minutes: 30
28+
timeout-minutes: 10
2829
steps:
2930
- uses: actions/checkout@v6
3031
- uses: ./.github/actions/ubuntu-setup
3132
- name: Build docs
3233
run: pip install nox uv && nox -s docs
3334
- name: Upload docs artifact
34-
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
3535
uses: actions/upload-artifact@v4
3636
with:
3737
name: docs-html
3838
path: docs/build/html
39+
retention-days: 1
40+
41+
changes:
42+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
43+
runs-on: ubuntu-latest
44+
outputs:
45+
docs: ${{ steps.filter.outputs.docs }}
46+
steps:
47+
- uses: dorny/paths-filter@v3
48+
id: filter
49+
with:
50+
filters: |
51+
docs:
52+
- 'docs/**'
53+
- 'modelopt/**'
54+
- '.github/workflows/pages.yml'
3955
4056
deploy-preview:
41-
if: github.event_name == 'pull_request'
57+
if: |
58+
always() &&
59+
github.event_name == 'pull_request' &&
60+
(github.event.action == 'closed' || needs.changes.outputs.docs == 'true')
61+
needs: [build-docs, changes]
4262
runs-on: ubuntu-latest
43-
timeout-minutes: 30
63+
timeout-minutes: 10
4464
# Per-PR concurrency without cancel-in-progress so 'closed' cleanup always runs
4565
concurrency:
4666
group: pr-preview-${{ github.event.pull_request.number }}
4767
steps:
4868
- uses: actions/checkout@v6
49-
- uses: ./.github/actions/ubuntu-setup
50-
- name: Build docs
69+
- name: Download docs artifact
5170
if: github.event.action != 'closed'
52-
run: pip install nox uv && nox -s docs
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: docs-html
74+
path: docs/build/html
5375
- name: Deploy / remove PR preview
5476
uses: rossjrw/pr-preview-action@v1
5577
with:
@@ -70,5 +92,6 @@ jobs:
7092
uses: JamesIves/github-pages-deploy-action@v4
7193
with:
7294
folder: docs/build/html
95+
single-commit: true
7396
# Preserve PR preview subdirectories deployed by the deploy-preview job
7497
clean-exclude: pr-preview

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def docs(session):
164164
with session.chdir("docs"):
165165
session.run(
166166
"sphinx-build",
167+
"-d",
168+
"/tmp/doctrees",
167169
"source",
168170
"build/html",
169171
"--fail-on-warning",

0 commit comments

Comments
 (0)