Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add --force to always rebuild #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ To manually rebuild a branch, for example 3.11:
ssh docs.nyc1.psf.io
sudo su --shell=/bin/bash docsbuild
screen -DUR # Rejoin screen session if it exists, otherwise create a new one
/srv/docsbuild/venv/bin/python /srv/docsbuild/scripts/build_docs.py --branch 3.11
/srv/docsbuild/venv/bin/python /srv/docsbuild/scripts/build_docs.py --force --branch 3.11
```
17 changes: 13 additions & 4 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
"""Does the build we are running include HTML output?"""
return self.select_output != "no-html"

def run(self, http: urllib3.PoolManager) -> bool | None:
def run(self, http: urllib3.PoolManager, force_build: bool) -> bool | None:
"""Build and publish a Python doc, for a language, and a version."""
start_time = perf_counter()
start_timestamp = dt.datetime.now(tz=dt.UTC).replace(microsecond=0)
Expand All @@ -550,7 +550,7 @@
self.cpython_repo.switch(self.version.branch_or_tag)
if self.language.tag != "en":
self.clone_translation()
if trigger_reason := self.should_rebuild():
if trigger_reason := self.should_rebuild(force_build):
self.build_venv()
self.build()
self.copy_build_to_webroot(http)
Expand Down Expand Up @@ -806,7 +806,7 @@
"Publishing done (%s).", format_seconds(perf_counter() - start_time)
)

def should_rebuild(self):
def should_rebuild(self, force: bool):
state = self.load_state()
if not state:
logging.info("Should rebuild: no previous state found.")
Expand Down Expand Up @@ -834,6 +834,9 @@
cpython_sha,
)
return "Doc/ has changed"
if force:
logging.info("Should rebuild: forced.")
return "forced"

Check warning on line 839 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L838-L839

Added lines #L838 - L839 were not covered by tests
logging.info("Nothing changed, no rebuild needed.")
return False

Expand Down Expand Up @@ -956,6 +959,12 @@
help="Path where generated files will be copied.",
default=Path("/srv/docs.python.org"),
)
parser.add_argument(

Check warning on line 962 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L962

Added line #L962 was not covered by tests
"--force",
action="store_true",

Check warning on line 964 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L964

Added line #L964 was not covered by tests
help="Always build the chosen languages and versions, "
"regardless of existing state.",
)
parser.add_argument(
"--skip-cache-invalidation",
help="Skip Fastly cache invalidation.",
Expand Down Expand Up @@ -1074,7 +1083,7 @@
builder = DocBuilder(
version, versions, language, languages, cpython_repo, **vars(args)
)
built_successfully = builder.run(http)
built_successfully = builder.run(http, force_build=args.force)

Check warning on line 1086 in build_docs.py

View check run for this annotation

Codecov / codecov/patch

build_docs.py#L1086

Added line #L1086 was not covered by tests
if built_successfully:
build_succeeded.add((version.name, language.tag))
elif built_successfully is not None:
Expand Down