Skip to content

Commit

Permalink
Patch the baseline test new-year race condition. Fix getnikola#3723.
Browse files Browse the repository at this point in the history
  • Loading branch information
aknrdureegaesr committed Jan 1, 2024
1 parent 8689cf3 commit 1108438
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
tmp/
cache/
output/
baseline/
nikola-baseline-build/
/tags
v3.*.zip.*

# GitHub token
.pypt/gh-token
Expand Down
37 changes: 35 additions & 2 deletions scripts/baseline.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash

set -e -o pipefail -x

PYVER=$(scripts/getpyver.py short)
if [[ "$1" == "check" ]]; then
echo -e "\033[36m>> Downloading baseline for $PYVER...\033[0m"
Expand All @@ -19,8 +22,38 @@ rm "pages/creating-a-theme.rst" "pages/extending.rst" "pages/internals.rst" "pag
LC_ALL='en_US.UTF-8' PYTHONHASHSEED=0 nikola build --invariant
if [[ "$1" == "check" ]]; then
echo -e "\033[36m>> Testing baseline...\033[0m"
diff -ubwr ../baseline output
if [[ $? == 0 ]]; then
python3 -c '
# In-place edit of copyright notes to adjust the copyright year.
import time
YEAR = str(time.gmtime().tm_year)
for edit_me in [
"../baseline/rss.xml",
"../baseline/index.html",
"../baseline/galleries/index.html",
"../baseline/galleries/demo/index.html",
"../baseline/listings/index.html",
"../baseline/listings/hello.py.html",
"../baseline/listings/__pycache__/index.html",
"../baseline/pages/about-nikola/index.html",
"../baseline/pages/bootstrap-demo/index.html",
"../baseline/pages/dr-nikolas-vendetta/index.html",
"../baseline/pages/listings-demo/index.html",
"../baseline/pages/quickref/index.html",
"../baseline/pages/quickstart/index.html",
"../baseline/posts/welcome-to-nikola/index.html",
]:
with open(edit_me, "rt+") as rssf:
rss = rssf.read()
copyright_prelude = "Contents © "
copyright_prelude_position = rss.find(copyright_prelude)
if -1 == copyright_prelude_position:
raise RuntimeError(f"Could not find copyright note in {edit_me}")
copyright_position = copyright_prelude_position + len(copyright_prelude)
new_rss = rss[:copyright_position] + YEAR + rss[copyright_position+4:]
rssf.seek(0, 0)
rssf.write(new_rss)
'
if diff -ubwr ../baseline output; then
echo -e "\033[32;1m>> Baseline test successful\033[0m"
else
CODE=$?
Expand Down

0 comments on commit 1108438

Please sign in to comment.