ci: a merge to main is the public release; every dev push dry-runs it (#8358)
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m44s
release / android (push) Successful in 2m9s
release / Build signed APK (push) Successful in 2m1s
release / Build + push container image (push) Failing after 4s
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m44s
release / android (push) Successful in 2m9s
release / Build signed APK (push) Successful in 2m1s
release / Build + push container image (push) Failing after 4s
Every push now builds its image from the git archive export, after the changelog and the leak gate have run on it, so a dev push is the public release's dry run. A push to main then also commits and tags the export on github.com/Fabled-Sword/minstrel as AmateurDungeoneer, publishes ghcr.io/fabled-sword/minstrel :<name> and :latest, and creates the release page on GitHub (public changelog) and on this forge (private changelog). The scripts are Librarian's (ci/changelog.sh, ci/leakgate.sh, ci/releases.mjs, with their tests), with Minstrel's false positives and a changelog that ignores the forge-only v* tags from before the public releases, so the first public release is the fixed note. The tag build, its APK attach and its verify job, and the manual GHCR dispatch are gone: phones get the app from the server image, and no release carries a file. The push trigger has no path filter, because the README, docs and tests ship in the public release too. The README's image tags now name what GHCR carries: :latest and :<version>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
package ci
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// leakgate runs leakgate.sh over one file holding text, and says whether it
|
||||
// passed.
|
||||
func leakgate(t *testing.T, text string) (bool, string) {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "f.go"), []byte(text), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out, err := exec.Command("bash", "leakgate.sh", dir).CombinedOutput()
|
||||
return err == nil, string(out)
|
||||
}
|
||||
|
||||
// The gate fails on a banned word or a private record id, wherever it sits on
|
||||
// the line, and passes the known false positives.
|
||||
func TestTheLeakGateRefusesWhatMustNotBePublished(t *testing.T) {
|
||||
for _, c := range []struct{ name, text string }{
|
||||
{"a banned word", "// a folder some downloader called Lidarr made\n"},
|
||||
{"a banned word in a fixture path", `{".sluice-held/Artist/01.flac", true},` + "\n"},
|
||||
{"a banned word beside an allowed one", "var list JsonArray // the torrent's files\n"},
|
||||
{"a ticket", "// fixed in (#4321)\n"},
|
||||
{"a worded citation", "// as milestone 635 decided\n"},
|
||||
{"a short milestone id", "// added in m7-scan-progress\n"},
|
||||
{"a citation split across comment lines", "// as the rule\n// 12 says\n"},
|
||||
{"a library measured, split across lines", "// counted on the reference\n// library\n"},
|
||||
{"an id beside a drawing path", "<path d=\"M3 4\"/> see rule 9\n"},
|
||||
{"an id beside Material 3", "// M3's default, as M12 chose\n"},
|
||||
} {
|
||||
if passed, out := leakgate(t, c.text); passed {
|
||||
t.Errorf("%s: passed %q\n%s", c.name, c.text, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheLeakGatePassesItsKnownFalsePositives(t *testing.T) {
|
||||
text := strings.Join([]string{
|
||||
"import kotlinx.serialization.json.JsonArray",
|
||||
`<path d="M8 1.5 15 14H1z" />`,
|
||||
`android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21z" />`,
|
||||
`back: 'M15 5l-7 7 7 7',`,
|
||||
"97 -322 147 -488 125z m928 -812 c53 -27 39 -34",
|
||||
"// M3 inactive default is secondaryContainer; drops M3's stop",
|
||||
`expect(css).toMatch(/--fs-obsidian: #000;[\s\S]*--fs-parchment: #FFF;/);`,
|
||||
"// a song called the rule of three is fine",
|
||||
}, "\n") + "\n"
|
||||
if passed, out := leakgate(t, text); !passed {
|
||||
t.Errorf("refused a known false positive:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
// repo makes a git repository whose commits carry the given subjects, and
|
||||
// returns its path.
|
||||
func repo(t *testing.T, subjects ...string) string {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
git(t, dir, "init", "-q", "-b", "main")
|
||||
for _, s := range subjects {
|
||||
commit(t, dir, s)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
// commit makes one commit with the given subject, changing a file so that it
|
||||
// is never empty.
|
||||
func commit(t *testing.T, dir, subject string) {
|
||||
t.Helper()
|
||||
if err := os.WriteFile(filepath.Join(dir, "f"), []byte(subject), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
git(t, dir, "add", "f")
|
||||
git(t, dir, "commit", "-q", "-m", subject)
|
||||
}
|
||||
|
||||
func git(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
cmd := exec.Command("git", append([]string{"-c", "user.name=t", "-c", "user.email=t@example.com"}, args...)...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), "GIT_CONFIG_GLOBAL=/dev/null", "GIT_CONFIG_SYSTEM=/dev/null")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||
}
|
||||
return strings.TrimSpace(string(out))
|
||||
}
|
||||
|
||||
// changelog runs changelog.sh in dir and returns the private and public lists.
|
||||
func changelog(t *testing.T, dir string) (string, string) {
|
||||
t.Helper()
|
||||
script, err := filepath.Abs("changelog.sh")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := t.TempDir()
|
||||
cmd := exec.Command("bash", script, out)
|
||||
cmd.Dir = dir
|
||||
if msg, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("changelog.sh: %v\n%s", err, msg)
|
||||
}
|
||||
read := func(name string) string {
|
||||
b, err := os.ReadFile(filepath.Join(out, name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
return read("private.md"), read("public.md")
|
||||
}
|
||||
|
||||
// The first public release has no public release before it, and its changelog
|
||||
// is the fixed note rather than every commit the project ever made. A v* tag
|
||||
// from before the public releases began is not a public release, so it does
|
||||
// not count as one.
|
||||
func TestTheFirstReleaseIsAFixedNote(t *testing.T) {
|
||||
dir := repo(t, "library: the first commit")
|
||||
git(t, dir, "tag", "v2026.10.26.1520")
|
||||
commit(t, dir, "web: after the forge-only release")
|
||||
private, public := changelog(t, dir)
|
||||
if private != public || strings.Contains(public, "web:") || !strings.Contains(public, "first public release") {
|
||||
t.Errorf("private %q, public %q: want the same fixed note", private, public)
|
||||
}
|
||||
}
|
||||
|
||||
// A later release lists what changed since the previous one. The public list
|
||||
// loses its record ids and the commits that only touch CI or tests.
|
||||
func TestALaterReleaseListsWhatChangedSinceThePrevious(t *testing.T) {
|
||||
dir := repo(t, "library: before the release")
|
||||
git(t, dir, "tag", "v2026.12.05.0000")
|
||||
for _, s := range []string{
|
||||
"fix(library): a song keeps its title (#4321)",
|
||||
"web, ci: a page and its lane (rule 12, #77)",
|
||||
"ci: a faster lane",
|
||||
"test(web): one test fewer",
|
||||
"web tests: one more",
|
||||
"server, tests: a route, as milestone 635 asks",
|
||||
} {
|
||||
commit(t, dir, s)
|
||||
}
|
||||
|
||||
private, public := changelog(t, dir)
|
||||
if strings.Contains(private, "before the release") {
|
||||
t.Errorf("the private list reaches past the previous release:\n%s", private)
|
||||
}
|
||||
if !strings.Contains(private, "(#4321)") || !strings.Contains(private, "- ci: a faster lane") {
|
||||
t.Errorf("the private list is not as written:\n%s", private)
|
||||
}
|
||||
want := "Changes since v2026.12.05.0000:\n\n" +
|
||||
"- fix(library): a song keeps its title\n" +
|
||||
"- web, ci: a page and its lane\n" +
|
||||
"- server, tests: a route, as asks\n"
|
||||
if public != want {
|
||||
t.Errorf("public list:\n%s\nwant:\n%s", public, want)
|
||||
}
|
||||
}
|
||||
|
||||
// A re-run of a release finds its own tag on the commit, and lists from the
|
||||
// release before it.
|
||||
func TestARerunListsFromTheReleaseBefore(t *testing.T) {
|
||||
dir := repo(t, "library: before")
|
||||
git(t, dir, "tag", "v2026.12.05.0000")
|
||||
commit(t, dir, "web: after")
|
||||
git(t, dir, "tag", "v2026.12.06.0000")
|
||||
_, public := changelog(t, dir)
|
||||
if !strings.Contains(public, "since v2026.12.05.0000") || !strings.Contains(public, "- web: after") {
|
||||
t.Errorf("re-run list:\n%s", public)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user