Ship weekly scenarios with the weekly puzzle run; docs and skills
This commit is contained in:
parent
d8df1e37f6
commit
0ece48a79d
6 changed files with 42 additions and 20 deletions
17
.github/workflows/release.yml
vendored
17
.github/workflows/release.yml
vendored
|
|
@ -70,15 +70,17 @@ jobs:
|
|||
fi
|
||||
# Weekly puzzles are published on main between releases (weekly-puzzle.yml). Every deploy ships all of them,
|
||||
# so neither a release nor a weekly redeploy ever drops a week that is already out.
|
||||
- name: Weekly puzzles from main
|
||||
- name: Weekly puzzles and scenarios from main
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --no-tags --depth=1 origin main
|
||||
if git cat-file -e FETCH_HEAD:site/puzzles/weekly 2>/dev/null; then
|
||||
rm -rf site/puzzles/weekly
|
||||
git checkout FETCH_HEAD -- site/puzzles/weekly
|
||||
echo "Weekly puzzles: $(ls site/puzzles/weekly | grep -c '^[0-9].*\.json$')"
|
||||
fi
|
||||
for d in site/puzzles/weekly site/scenarios/weekly; do
|
||||
if git cat-file -e "FETCH_HEAD:$d" 2>/dev/null; then
|
||||
rm -rf "$d"
|
||||
git checkout FETCH_HEAD -- "$d"
|
||||
echo "$d: $(ls "$d" | grep -c '^[0-9].*\.json$')"
|
||||
fi
|
||||
done
|
||||
- run: npm ci
|
||||
# This release's prices may no longer fit a week already published: --check regenerates every week not over
|
||||
# yet whose budget no longer verifies (deterministically, so main's next weekly run commits the same files),
|
||||
|
|
@ -89,11 +91,12 @@ jobs:
|
|||
# A release from before the weekly puzzles ships the files without reading them: nothing to check.
|
||||
if [ ! -f scripts/weekly-puzzle.js ]; then echo "This release does not read weekly puzzles yet."; exit 0; fi
|
||||
node scripts/weekly-puzzle.js --check
|
||||
if [ -f scripts/weekly-scenario.js ]; then node scripts/weekly-scenario.js --check; fi
|
||||
- run: npm test
|
||||
if: ${{ !inputs.weekly }}
|
||||
- name: Test the weekly puzzles against this release
|
||||
if: ${{ inputs.weekly && hashFiles('scripts/weekly-puzzle.js') != '' }}
|
||||
run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js
|
||||
run: npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js $(ls tests/weekly-scenario.test.js 2>/dev/null)
|
||||
- name: Build site
|
||||
run: VERSION="${TAG#v}" REQUIRE_NOTES=1 npm run build
|
||||
- uses: actions/upload-pages-artifact@v5
|
||||
|
|
|
|||
20
.github/workflows/weekly-puzzle.yml
vendored
20
.github/workflows/weekly-puzzle.yml
vendored
|
|
@ -1,8 +1,8 @@
|
|||
name: Weekly puzzle
|
||||
|
||||
# Every Sunday morning: make this week's puzzle (scripts/weekly-puzzle.js), commit it to main as a data-only
|
||||
# change, and redeploy the live release with it. Puzzle weeks start Sunday 06:00 Berlin time; 03:37 UTC is
|
||||
# 04:37 in winter and 05:37 in summer, so the file is live before the week starts either way.
|
||||
# Every Sunday morning: make this week's puzzle (scripts/weekly-puzzle.js) and scenario (scripts/weekly-scenario.js),
|
||||
# commit them to main as a data-only change, and redeploy the live release with them, once. Weeks start Sunday
|
||||
# 06:00 Berlin time; 03:37 UTC is 04:37 in winter and 05:37 in summer, so the files are live before the week starts.
|
||||
#
|
||||
# No version bump, so no release: auto-release.yml only runs when package.json changes (and pushes made with
|
||||
# the workflow token start no workflows at all). The deploy itself is release.yml, still the only workflow
|
||||
|
|
@ -47,27 +47,29 @@ jobs:
|
|||
- run: npm ci
|
||||
# Weeks already out that main's prices no longer fit are regenerated first, so the new week's history is current.
|
||||
- name: Fit the published weeks to main
|
||||
run: node scripts/weekly-puzzle.js --check
|
||||
- name: Make the puzzle
|
||||
run: node scripts/weekly-puzzle.js --check && node scripts/weekly-scenario.js --check
|
||||
- name: Make the puzzle and the scenario
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -n "$KEY" ]; then
|
||||
[[ "$KEY" =~ ^[0-9]{4}-W[0-9]{2}$ ]] || { echo "::error::$KEY is not a week key"; exit 1; }
|
||||
node scripts/weekly-puzzle.js --key "$KEY"
|
||||
node scripts/weekly-scenario.js --key "$KEY"
|
||||
else
|
||||
node scripts/weekly-puzzle.js
|
||||
node scripts/weekly-scenario.js
|
||||
fi
|
||||
- name: Check every weekly puzzle
|
||||
run: node scripts/weekly-puzzle.js --check && npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js
|
||||
run: node scripts/weekly-puzzle.js --check && node scripts/weekly-scenario.js --check && npm test -- tests/weekly-puzzle.test.js tests/puzzles.test.js tests/weekly-scenario.test.js
|
||||
- name: Commit it to main
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git add site/puzzles/weekly
|
||||
git add site/puzzles/weekly site/scenarios/weekly
|
||||
# Data only: anything else changed means something is wrong.
|
||||
if git status --porcelain | grep -v ' site/puzzles/weekly/' | grep -q .; then git status --porcelain; echo "::error::unexpected changes"; exit 1; fi
|
||||
if git status --porcelain | grep -v -e ' site/puzzles/weekly/' -e ' site/scenarios/weekly/' | grep -q .; then git status --porcelain; echo "::error::unexpected changes"; exit 1; fi
|
||||
if git diff --cached --quiet; then echo "Nothing new to commit."; exit 0; fi
|
||||
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
||||
commit -m "Weekly puzzle $(git diff --cached --name-only | grep -o '[0-9]\{4\}-W[0-9]\{2\}' | sort -u | paste -sd ' ')"
|
||||
commit -m "Weekly puzzle and scenario $(git diff --cached --name-only | grep -o '[0-9]\{4\}-W[0-9]\{2\}' | sort -u | paste -sd ' ')"
|
||||
git push origin HEAD:main
|
||||
- name: Redeploy the live release with it
|
||||
if: github.event_name == 'schedule' || inputs.deploy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue