Nightly: trusted reviewers pick the pull requests with /nightly

Ludovic's decision (2026-10-27, from kacpherek's proposal under #2779): the
Nightly is where contributors test pull requests before the gate.
kacpherek, rdbtCVS and levzzz5154 (.github/nightly-reviewers.txt) and
Ludovic pick them with `/nightly 2640 2642`, `add`, `remove`, `clear`,
`status` or `dry-run` in any issue or pull request.

- nightly-command.yml (issue_comment, main's copy): checks who asked, saves
  the set on nightly-state, starts `nightly build`, answers "🤖 Nightly: …".
  It never checks out or merges a pull request.
- nightly-build.yml: `pick` builds main + the set (newest heads and merged or
  closed ones dropped at the scheduled run), pushes it as
  nightly/build-<date>-<n>, records it in builds.jsonl; build, sign and
  publish are unchanged; `answer` tells the thread how it ended.
- Notes say a Nightly can include pull requests not reviewed yet, picked by
  trusted reviewers, and list each with its author and who picked it.
- docs/release-flow.md: who can pick, how, how Ludovic removes or pauses them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-27 16:11:14 +01:00
parent 0ff1df58a2
commit 79eddec09c
5 changed files with 313 additions and 28 deletions
+7
View File
@@ -0,0 +1,7 @@
# Trusted reviewers: they pick the pull requests the Nightly holds with `/nightly 2640 2642` in any issue or pull
# request (docs/release-flow.md "Nightly channel", tools/ci/nightly_set.py). Ludovic is always allowed and isn't
# listed. One GitHub login per line, with who added it and when. Removing a line revokes that login at once.
# A line with only `paused` stops every reviewer's `/nightly` (Ludovic's still work).
kacpherek # added by Ludovic, 2026-10-27
rdbtCVS # added by Ludovic, 2026-10-27
levzzz5154 # added by Ludovic, 2026-10-27
+65 -6
View File
@@ -1,13 +1,20 @@
name: nightly build
# The opt-in Nightly channel (docs/release-flow.md "Nightly"; Ludovic, 2026-10-27). Once a night it builds the newest
# union branch on origin (union/<agent>-<name>: main plus pull requests the contribution gate proved together), or
# main when no union is newer, and publishes it as the `nightly` pre-release. Launchers install it only for players
# who turn Nightly on. The previous nightly stays a week as nightly-<date>.
run-name: nightly build${{ inputs.request && format(' (request {0})', inputs.request) || '' }}
# The opt-in Nightly channel (docs/release-flow.md "Nightly"; Ludovic, 2026-10-27). Once a night, and when a trusted
# reviewer asks (`/nightly 2640 2642`, nightly-command.yml), it builds main plus the pull requests the reviewers
# picked, merged in order (tools/ci/nightly_set.py). With none picked, it builds the newest union branch on origin
# (union/<agent>-<name>: main plus pull requests the contribution gate proved together), or main when no union is
# newer. It publishes the result as the `nightly` pre-release. Launchers install it only for players who turn Nightly
# on. The previous nightly stays a week as nightly-<date>.
#
# Why the signing key never meets the union's code:
# Why the signing key never meets the pull requests' code:
# - `pick` merges the picked heads onto main with `git merge-tree --write-tree`: git objects only, no working tree,
# so none of their files reaches the disk and no hook, filter or script of theirs runs. It refuses any pull
# request that changes a path CODEOWNERS gives to Ludovic (this folder, tools/ci/, the signing and update code),
# pushes the merge as nightly/build-<date>-<n> and saves the set on the nightly-state branch.
# - This file, game-build.yml and every script below run from main's copy: a schedule runs the default branch, and
# `uses: ./…` takes the caller's commit. The union's own .github/ is never read.
# - `build` (game-build.yml) checks out and compiles the union with no secrets: its token reads contents only and
# - `build` (game-build.yml) checks out and compiles the merge (or the union) with no secrets: its token reads contents only and
# isn't kept in the checkout; the macOS programs are signed ad hoc (Developer ID needs the runner's keychain,
# which stays locked for nightlies).
# - `sign` is the only job with RELEASE_SIGNING_KEY. It checks out nothing but main's tools/ci/sign_release.sh, which
@@ -31,18 +38,37 @@ on:
description: Build and sign with a throwaway key, publish nothing
type: boolean
default: false
issue:
description: The issue or pull request whose `/nightly` comment asked for this build (answered there)
type: string
default: ''
request:
description: The command's id, in the run's name so it can link the run
type: string
default: ''
prs:
description: A dry run's own set, `2640@<head> 2642@<head>` (the saved set stays)
type: string
default: ''
permissions:
contents: read
concurrency:
# One build at a time. A newer request replaces one still waiting: it builds the set as it is by then, so no pick
# is lost.
group: nightly-build
cancel-in-progress: false
jobs:
pick:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write # nightly/build-<date>-<n> and the nightly-state branch (main is protected)
issues: write # says in the thread when the picked pull requests conflict
pull-requests: write
outputs:
build: ${{ steps.pick.outputs.build }}
sha: ${{ steps.pick.outputs.sha }}
short: ${{ steps.pick.outputs.short }}
source: ${{ steps.pick.outputs.source }}
date: ${{ steps.pick.outputs.date }}
version: ${{ steps.pick.outputs.version }}
@@ -60,6 +86,9 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
FORCE: ${{ (inputs.force || steps.mode.outputs.dry_run == 'true') && 'yes' || '' }}
DRY_RUN: ${{ steps.mode.outputs.dry_run }}
NIGHTLY_ISSUE: ${{ inputs.issue }}
NIGHTLY_PRS: ${{ inputs.prs }}
run: |
python3 tools/ci/nightly.py pick ${FORCE:+--force} | tee -a "$GITHUB_STEP_SUMMARY"
{ echo; cat nightly-notes.md; } >> "$GITHUB_STEP_SUMMARY"
@@ -164,3 +193,33 @@ jobs:
run: |
echo "Would publish nightly at ${{ needs.pick.outputs.sha }} (${{ needs.pick.outputs.source }})"
ls -l dist
answer:
# Tells the thread that asked for this build how it ended. A conflict `pick` already explained there.
needs: [pick, build, sign, publish]
if: always() && inputs.issue != '' && needs.pick.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: write
pull-requests: write
steps:
- env:
GH_TOKEN: ${{ github.token }}
ISSUE: ${{ inputs.issue }}
BUILD: ${{ needs.pick.outputs.build }}
PUBLISHED: ${{ needs.publish.result }}
DRY_RUN: ${{ needs.pick.outputs.dry_run }}
NAME: Nightly ${{ needs.pick.outputs.date }} · ${{ needs.pick.outputs.short }}
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
if [[ "$BUILD" != true ]]; then
text="nothing new: the published Nightly is already this build."
elif [[ "$PUBLISHED" == success && "$DRY_RUN" == true ]]; then
text="the dry run built and signed $NAME; nothing was published. $RUN"
elif [[ "$PUBLISHED" == success ]]; then
text="published $NAME: https://github.com/$GITHUB_REPOSITORY/releases/tag/nightly. Launchers with Nightly on install it at their next start."
else
text="the build failed, nothing was published: $RUN"
fi
gh api "repos/$GITHUB_REPOSITORY/issues/$ISSUE/comments" -f body="🤖 Nightly: $text"
+46
View File
@@ -0,0 +1,46 @@
name: nightly command
# `/nightly …` comments: the trusted reviewers in .github/nightly-reviewers.txt (and Ludovic) pick the pull requests
# the Nightly holds (docs/release-flow.md "Nightly channel", tools/ci/nightly_set.py). This job only checks who asked,
# saves the set on the nightly-state branch, starts `nightly build` and answers in the thread.
#
# Why no pull request's code runs here, though the token can write:
# - `issue_comment` always runs this file from main, whoever comments and wherever; a pull request's own copy of it
# is never read.
# - It checks out main and runs main's nightly_set.py. The comment's text and author reach it as env vars, never in
# a shell line.
# - It never checks out, fetches or merges a pull request: it reads their file lists through the API. The merge
# happens in nightly-build.yml's `pick`, with git objects only; their code runs in its `build`, without secrets.
on:
issue_comment:
types: [created]
permissions:
contents: read
jobs:
command:
# Every other comment skips here, before a runner starts.
if: startsWith(github.event.comment.body, '/nightly') && github.event.comment.user.type != 'Bot'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write # the nightly-state branch (main is protected)
actions: write # starts `nightly build`
issues: write # answers in the thread
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: main
persist-credentials: false
sparse-checkout: |
.github/CODEOWNERS
.github/nightly-reviewers.txt
tools/ci/nightly_set.py
sparse-checkout-cone-mode: false
- name: Run the command
env:
GH_TOKEN: ${{ github.token }}
BODY: ${{ github.event.comment.body }}
AUTHOR: ${{ github.event.comment.user.login }}
ISSUE: ${{ github.event.issue.number }}
COMMENT_URL: ${{ github.event.comment.html_url }}
run: python3 tools/ci/nightly_set.py command
+56 -11
View File
@@ -263,8 +263,9 @@ silent (no ping and Discord's @silent flag). Launcher releases post without a pi
### One channel
Since 2026-10-23 there is one release channel, and it is every launcher's default. Since 2026-10-27 (Ludovic's
decision, revising 2026-10-23's) players may also turn on [Nightly](#nightly-channel), an opt-in pre-release built
from reviewed pull requests; nothing about releases changes for anyone who doesn't. Every game release is published
decision, revising 2026-10-23's) players may also turn on [Nightly](#nightly-channel), an opt-in pre-release of main
plus pull requests the trusted reviewers picked, not all reviewed yet; nothing about releases changes for anyone who
doesn't. Every game release is published
as the release, never a pre-release, and marked GitHub's *latest*: the launcher, `horizon-server update` and `install.sh` take it at once. Because nothing
promotes it later, the checks that used to gate a promotion run in the release itself, and the publish job
(`tools/release_train.py gate`) publishes nothing unless both pass:
@@ -411,22 +412,66 @@ launcher and the website read: both then look the newest launcher tags up one by
## Nightly channel
`.github/workflows/nightly-build.yml` publishes an opt-in build once a night (20:17 UTC), for players who want
reviewed fixes before they are released (#2681). It builds the newest `union/<agent>-<name>` branch on origin (main
plus the pull requests the contribution gate proved together in one wave) when that union is newer than main's head
and holds something main lacks, otherwise main (`tools/ci/nightly.py pick`). A night with nothing new publishes
nothing. Only proven unions are pushed to origin, so nothing unreviewed ships.
`.github/workflows/nightly-build.yml` publishes an opt-in build once a night (20:17 UTC) and when a trusted
reviewer asks, for players who want fixes before they are released (#2681). It builds main plus the pull requests the
trusted reviewers picked, merged in their order. With none picked, it builds the newest `union/<agent>-<name>` branch
on origin (main plus the pull requests the contribution gate proved together in one wave) when that union is newer
than main's head and holds something main lacks, otherwise main (`tools/ci/nightly.py pick`). A night with nothing
new publishes nothing. A Nightly can include pull requests not reviewed yet: that is what it is for, playing them
before the gate.
- **Jobs.** `pick` chooses the commit and writes the notes (the open pull requests it holds beyond main). `build` is
### Trusted reviewers pick the pull requests
The Nightly is where contributors test pull requests before the gate. The trusted reviewers listed in
`.github/nightly-reviewers.txt` (kacpherek, rdbtCVS and levzzz5154 since 2026-10-27) and Ludovic pick them with a
comment on any issue or pull request (`.github/workflows/nightly-command.yml`, `tools/ci/nightly_set.py`):
```text
/nightly 2640 2642 the set becomes these pull requests, merged onto main in this order; builds now
/nightly add 2650 adds one, or takes its newest head again; builds now
/nightly remove 2640 drops one; builds now
/nightly clear empties the set: back to the proven union or main; builds now
/nightly status what the set holds
/nightly dry-run 2640 builds main + these and signs with a throwaway key; publishes nothing, the set stays
```
- **The answer.** The workflow answers in the thread with one comment starting `🤖 Nightly:`: the set, the build's
run, and later the published Nightly (or why it failed).
- **The set** is `set.json` on the `nightly-state` branch: who asked, when, and each pull request at the head it had
then. A head is taken again only when someone asks again or at the scheduled run, never silently in between. The
scheduled run takes every pull request's newest head and drops the merged and closed ones; the notes say so.
`builds.jsonl` there records each build's set (for `nightly_stats.py`).
- **Assembly.** `pick` (main's code) fetches each head and merges them onto main with `git merge-tree
--write-tree`: git objects only, no working tree, so no file, hook or filter of theirs reaches the runner. The
result is pushed as `nightly/build-<date>-<n>` and `build` compiles that, without secrets, as for a release.
Equal inputs give the same commit, so an unchanged set and main publish nothing new. On a conflict the build
stops and answers which two pull requests conflict and where; a reviewer can then open an integration pull
request from their fork that combines them, and pick that one instead.
- **Refused.** A pull request that changes a path CODEOWNERS gives to Ludovic (`.github/`, `tools/ci/`, the
signing and update code, `launcher/src/backend.rs`, `launcher/links.json`…), more than 30 in a set, and more than
6 builds a day (the scheduled one always runs).
- **No repository role.** Reviewers need no permission on the repository: the list file and the workflow are the
whole of it.
- **Ludovic stays in charge.**
- Ludovic's `/nightly clear` or `/nightly remove` always applies. A pull request he removed can only come back
when he adds it.
- A one-line pull request removing a login from `.github/nightly-reviewers.txt` revokes it as soon as it merges
(the file is his under CODEOWNERS).
- A line `paused` in that file stops every reviewer's `/nightly`; his own still work.
- Main, the gate and releases don't change: picks reach only players who turned Nightly on.
- **Jobs.** `pick` chooses or assembles the commit and writes the notes (each pull request in it with its title,
author and who picked it, or for a union the open pull requests it holds beyond main). `build` is
`game-build.yml`, the same builds and smoke test as a release, with the version `nightly-<date>` and
`HORIZON_NIGHTLY="<date> <short sha>"` built in, macOS signed ad hoc. `sign` signs SHA256SUMS for the channel
(the message says `horizon release nightly`, so a nightly's signature never passes for a release's). `publish`
checks the signature and the smoke test (not `release-blocker`: a nightly is how blockers get tested), renames the
previous `nightly` pre-release to `nightly-<its date>`, publishes the new one as the `nightly` pre-release (never
GitHub's latest), and deletes the `nightly-<date>` pre-releases and tags older than 7 days, nothing else.
- **The signing key never meets the union's code.** Every workflow file and script runs from main's copy (a schedule
runs the default branch; `uses: ./…` takes the caller's commit), never the union's `.github/`. `build` compiles the
union with a read-only token that isn't kept in the checkout and no secrets; the runner's Developer ID keychain
- **The signing key never meets the pull requests' code.** Every workflow file and script runs from main's copy (a
schedule and `issue_comment` run the default branch; `uses: ./…` takes the caller's commit), never a pull
request's `.github/`, and a pull request that changes `.github/` or `tools/ci/` is refused. `build` compiles the
merge with a read-only token that isn't kept in the checkout and no secrets; the runner's Developer ID keychain
stays locked. `sign` is the only job with the key, and checks out only main's `tools/ci/sign_release.sh`, which
hashes the archives with the runner's `sha256sum` and signs with its OpenSSL: it never runs what `build` made.
`publish` runs main's `horizon-release-sign`, never the archives.
+139 -11
View File
@@ -5,10 +5,12 @@
nightly.py rotate renames the current `nightly` pre-release to nightly-<its date>, frees the tag
nightly.py prune [--days 7] deletes the nightly-<date> pre-releases and tags older than that, nothing else
A nightly builds the newest union branch on origin (`union/<agent>-<name>`: main plus pull requests the contribution
gate proved together), or main when no union is newer than main's head. It is published as the `nightly`
pre-release; the previous one stays a week as nightly-<date>. Runs from main's checkout with `gh`; it reads the
branch it picks with git and never runs anything from it.
A nightly builds main plus the pull requests the trusted reviewers picked (the set: tools/ci/nightly_set.py), merged
in their order and pushed as nightly/build-<date>-<n>. With no set it builds the newest union branch on origin
(`union/<agent>-<name>`: main plus pull requests the contribution gate proved together), or main when no union is
newer than main's head. It is published as the `nightly` pre-release; the previous one stays a week as
nightly-<date>. Runs from main's checkout with `gh`; it reads and merges the branches with git and never runs
anything from them.
"""
from __future__ import annotations
@@ -20,6 +22,12 @@ import re
import subprocess
import sys
from dataclasses import dataclass
from pathlib import Path
if __package__: # imported as tools.ci.nightly (the tests)
from . import nightly_set as ns
else: # run as tools/ci/nightly.py: its folder is on the path
import nightly_set as ns
DATED = re.compile(r"^nightly-(\d{4}-\d{2}-\d{2})$")
TITLE_DATE = re.compile(r"Nightly (\d{4}-\d{2}-\d{2})")
@@ -69,11 +77,27 @@ def output(**values: str) -> None:
f.write(f"{k}={v}\n")
def notes(today: str, chosen: Ref, held: list[dict]) -> str:
lines = [f"Nightly {today} · {chosen.sha[:7]}: built from `{chosen.name}` ({chosen.sha}).", "",
"**Opt-in, not a release.** Fixes the maintainers reviewed but haven't released yet: it may break. "
"Turn it on in the launcher's settings; your release install and your worlds stay as they are. "
"Report bugs with the version the game shows (\"Nightly <date> · <commit>\").", ""]
OPT_IN = ("**Opt-in, not a release.** A Nightly can include pull requests not reviewed yet, picked by trusted "
"reviewers: it may break. Turn it on in the launcher's settings; your release install and your worlds stay "
"as they are. Report bugs with the version the game shows (\"Nightly <date> · <commit>\").")
def set_notes(today: str, chosen: Ref, main: Ref, prs: list[dict], left_out: list[str]) -> str:
"""The notes of a build of main plus the reviewers' set."""
lines = [f"Nightly {today} · {chosen.sha[:7]}: main ({main.sha[:7]}) with {len(prs)} pull requests merged in, "
f"built from `{chosen.name}` ({chosen.sha}).", "", OPT_IN, "",
f"### Pull requests in this Nightly ({len(prs)})", ""]
lines += [f"- {ns.plain(e['title'])} (#{e['number']}) by {e['author']}, at {e['head'][:7]}, picked by "
f"{e['asked_by']}" for e in prs]
if left_out:
lines += ["", f"### Left out ({len(left_out)})", ""] + [f"- {ns.plain(why)}" for why in left_out]
return "\n".join(lines) + "\n"
def notes(today: str, chosen: Ref, held: list[dict], left_out: list[str] | None = None) -> str:
lines = [f"Nightly {today} · {chosen.sha[:7]}: built from `{chosen.name}` ({chosen.sha}).", "", OPT_IN, ""]
if left_out:
lines += [f"The reviewers' set had nothing left to build: {'; '.join(ns.plain(w) for w in left_out)}.", ""]
if held:
lines += [f"### Not on main yet ({len(held)})", ""]
lines += [f"- {p['title']} (#{p['number']})" for p in held]
@@ -82,12 +106,116 @@ def notes(today: str, chosen: Ref, held: list[dict]) -> str:
return "\n".join(lines) + "\n"
def refresh(entries: list[dict], get, patterns: list[str]) -> tuple[list[dict], list[str]]:
"""The scheduled nightly's set: each pull request at its newest head; merged, closed and refused ones out."""
kept, left_out = [], []
for e in entries:
pr = get(e["number"])
if pr is not None and pr.state == "merged":
left_out.append(f"#{e['number']} {e['title']}: merged, so it's in main")
elif why := ns.check(pr, e["number"], patterns):
left_out.append(f"{why}: left out")
else:
kept.append({**e, "head": pr.head, "title": pr.title})
return kept, left_out
def requested(spec: str, get) -> list[dict]:
"""A dry run's set from its input: `2640@<head> 2642@<head>`."""
prs = []
for word in spec.split():
number, _, head = word.partition("@")
pr = get(int(number))
prs.append({"number": int(number), "head": head or (pr.head if pr else ""), "title": pr.title if pr else "?",
"author": pr.author if pr else "?", "asked_by": "dry run"})
return prs
def stop(repo: str, issue: str, text: str) -> None:
"""Says why the build stopped, where it was asked for, and fails the job."""
print(text)
if issue and repo:
ns.answer(repo, issue, text)
sys.exit(1)
def build_set(main: Ref, prs: list[dict], left_out: list[str], today: str, force: bool) -> None:
"""main + the set, merged with git only (nightly_set.assemble), pushed as nightly/build-<date>-<n>."""
repo, issue = os.environ.get("GITHUB_REPOSITORY", ""), os.environ.get("NIGHTLY_ISSUE", "")
token, event = os.environ.get("GH_TOKEN", ""), os.environ.get("GITHUB_EVENT_NAME", "")
dry_run = os.environ.get("DRY_RUN") == "true"
patterns = ns.guarded_patterns(Path(ns.CODEOWNERS).read_text() if Path(ns.CODEOWNERS).exists() else "")
gone = set(ns.fetch_heads([(e["number"], e["head"]) for e in prs]))
kept = []
for e in prs:
if e["number"] in gone:
left_out.append(f"#{e['number']} {e['title']}: its head {e['head'][:7]} is gone; ask for it again")
elif bad := [f for f in ns.changed_files(main.sha, e["head"]) if ns.guarded(f, patterns)]:
left_out.append(f"#{e['number']} {e['title']}: changes `{bad[0]}`, which only Ludovic merges")
else:
kept.append(e)
if not kept:
return build_union(main, today, force, left_out)
try:
sha = ns.assemble(main.sha, [(e["number"], e["head"]) for e in kept])
except ns.Conflict as c:
state, _, _ = ns.load_state()
asked_in = issue or next((x["issue"] for x in reversed(state.get("log", [])) if x.get("issue")), "")
stop(repo, asked_in, f"the build stopped: {c.text()}")
previous = git("ls-remote", "--tags", "origin", "refs/tags/nightly").split("\t")[0] or None
build = force or previous != sha
name = "(unchanged)"
if build:
done = ns.builds_today(today)
if len(done) >= ns.MAX_BUILDS_PER_DAY and event != "schedule":
stop(repo, issue, f"{len(done)} Nightly builds today already, the most a day takes: the next scheduled "
"one (20:17 UTC) builds the set.")
name = ns.next_build(today, done)
if not ns.push(sha, name, token):
stop(repo, issue, f"could not push {name}")
record = {"ref": name, "sha": sha, "main": main.sha, "at": dt.datetime.now(dt.timezone.utc).isoformat(
timespec="seconds"), "event": event, "dry_run": dry_run, "run": os.environ.get("GITHUB_RUN_ID", ""),
"prs": [{k: e[k] for k in ("number", "head", "title", "author", "asked_by")} for e in kept],
"left_out": left_out}
ns.update_state(lambda st, builds: (st, builds + json.dumps(record) + "\n", f"build {name}"), token)
chosen = Ref(name, sha, dt.datetime.now(dt.timezone.utc))
with open("nightly-notes.md", "w") as f:
f.write(set_notes(today, chosen, main, kept, left_out))
output(build=str(build).lower(), sha=sha, short=sha[:7], source=name, date=today, version=f"nightly-{today}",
nightly=f"{today} {sha[:7]}")
print(f"{'build' if build else 'skip (unchanged since the last nightly)'}: {name} {sha}, main {main.sha[:7]} + "
+ ", ".join(f"#{e['number']}" for e in kept))
def pick(force: bool) -> None:
git("fetch", "--quiet", "origin", "+refs/heads/main:refs/remotes/origin/main",
"+refs/heads/union/*:refs/remotes/origin/union/*")
main = refs("refs/remotes/origin/main")[0]
chosen = choose(main, refs("refs/remotes/origin/union/"))
today = dt.datetime.now(dt.timezone.utc).date().isoformat()
repo, token = os.environ.get("GITHUB_REPOSITORY", ""), os.environ.get("GH_TOKEN", "")
if spec := os.environ.get("NIGHTLY_PRS", "").strip(): # a dry run's own set; the saved one stays
return build_set(main, requested(spec, ns.lookup(repo)), [], today, force)
state, _, _ = ns.load_state()
prs, left_out = state.get("prs", []), []
if prs and os.environ.get("GITHUB_EVENT_NAME") == "schedule":
patterns = ns.guarded_patterns(Path(ns.CODEOWNERS).read_text() if Path(ns.CODEOWNERS).exists() else "")
get = ns.lookup(repo)
def fresh(st: dict, builds: str):
kept, out = refresh(st.get("prs", []), get, patterns)
left_out[:] = out
if kept == st.get("prs", []):
return None
return {**st, "prs": kept}, builds, "the scheduled nightly takes the newest heads"
prs = ns.update_state(fresh, token).get("prs", [])
if prs:
return build_set(main, prs, left_out, today, force)
build_union(main, today, force, left_out)
def build_union(main: Ref, today: str, force: bool, left_out: list[str] | None = None) -> None:
"""No set: the newest proven union, or main."""
chosen = choose(main, refs("refs/remotes/origin/union/"))
previous = git("ls-remote", "--tags", "origin", "refs/tags/nightly").split("\t")[0] or None
build = force or previous != chosen.sha
# The open pull requests this build holds beyond main: their heads are in it and not in main.
@@ -101,7 +229,7 @@ def pick(force: bool) -> None:
held.append(pr)
held.sort(key=lambda p: p["number"])
with open("nightly-notes.md", "w") as f:
f.write(notes(today, chosen, held))
f.write(notes(today, chosen, held, left_out))
output(build=str(build).lower(), sha=chosen.sha, short=chosen.sha[:7], source=chosen.name, date=today,
version=f"nightly-{today}", nightly=f"{today} {chosen.sha[:7]}")
print(f"{'build' if build else 'skip (unchanged since the last nightly)'}: {chosen.name} {chosen.sha}, "