diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 068b07a0..6a0df674 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,7 @@ # Monthly updates, each ecosystem in one grouped pull request, for devvm's Go modules and the actions its workflows pin by SHA. Their titles follow -# Conventional Commits, as the PR title check asks. Pinned downloads in assets/, the shared tools' lock -# and the e2e pins are bumped with scripts/bump.sh, which Dependabot doesn't know. +# Conventional Commits, as the PR title check asks. scripts/bump.sh moves these too, and every pin +# Dependabot doesn't know, and holds each module or action as an ignore entry below does: keep each +# one's dependency-name line followed by a versions: [">= X"] line, the form it reads. version: 2 updates: - package-ecosystem: gomod diff --git a/.github/workflows/pins.yml b/.github/workflows/pins.yml index a01bcd8d..31cef13e 100644 --- a/.github/workflows/pins.yml +++ b/.github/workflows/pins.yml @@ -25,7 +25,17 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false + # mise for the dev tools' newest versions; no tools, as nothing builds. + - uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8 + with: + version: 2026.11.8 + install: false + cache: false - name: Check the pins + # gh api reads the actions' releases, and mise GitHub's for the dev tools. + env: + GH_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ github.token }} run: | set -euo pipefail scripts/bump.sh --check | tee "$RUNNER_TEMP/check.txt" @@ -38,7 +48,12 @@ jobs: run: | set -euo pipefail title="Pinned versions to bump" - grep -F ' -> ' "$RUNNER_TEMP/check.txt" > "$RUNNER_TEMP/outdated.txt" || true + # Each outdated pin, under its group's [header], with only the + # characters --check's lines use, so no upstream text can end the + # issue's code fence (a backtick) or add markup; \133 and \135 are + # the brackets, written so no tr reads them as a class. + awk '/^\[/ { g = $0; next } index($0, " -> ") { if (g != "") print g; g = ""; print }' \ + "$RUNNER_TEMP/check.txt" | LC_ALL=C tr -cd '0-9A-Za-z.+~_ ()>:/,\133\135\n-' > "$RUNNER_TEMP/outdated.txt" number=$(gh issue list --state open --search "in:title \"$title\"" --json number,title \ --jq "map(select(.title == \"$title\")) | .[0].number // empty") if [[ ! -s $RUNNER_TEMP/outdated.txt ]]; then @@ -55,7 +70,8 @@ jobs: cat "$RUNNER_TEMP/outdated.txt" echo '````' echo - echo "Bump them with \`scripts/bump.sh TOOL…\` (the tools named above), or \`scripts/bump.sh\` for all." + echo "Bump them with \`scripts/bump.sh\`, which applies every patch and minor, or \`scripts/bump.sh TOOL…\`;" + echo "its header says which tool moves each pin, and a line marked by hand or only when named says how." echo "Pin bumps change images, so run the \`--from\` tier of the end-to-end tests before merging:" echo "see [Updating pinned versions](https://devvm.dev/docs/contributing/maintaining/#updating-pinned-versions)." } > "$RUNNER_TEMP/body.md" diff --git a/docs/content/docs/contributing/maintaining.md b/docs/content/docs/contributing/maintaining.md index a78d48fd..6c9d50de 100644 --- a/docs/content/docs/contributing/maintaining.md +++ b/docs/content/docs/contributing/maintaining.md @@ -8,14 +8,46 @@ For maintainers: version bumps and releases. Run the scripts with mise, which pu ## Updating pinned versions -- `scripts/bump.sh --check` lists every pin against upstream; `scripts/bump.sh [tool...]` rewrites the pins (all tools by default) and prints a summary for the commit message. It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit), since some of the edited files run on the host, and edits nothing unless every value is good. It needs `curl` and `jq`. When upstream's latest is older than a pin, as when a release marker hasn't moved yet, `--check` says the pin is newer and `bump.sh` leaves it as it is. -- Every Monday the Pins workflow (`.github/workflows/pins.yml`) runs `scripts/bump.sh --check` and opens or updates one issue, "Pinned versions to bump", which lists the outdated pins, and closes it once none is left. It never bumps anything: you run `scripts/bump.sh` with the tools it lists, then the `--from` tier of the [end-to-end tests](tests.md#end-to-end-tests), because pin bumps change images. -- The tools: `docker`, `nix`, `direnv`, `nix-direnv`, `mise`, `rustup`, `crane`, `omb`, `eza`, `tealdeer`, `e2e-tools`, `e2e-from`, `e2e-ubuntu`, `e2e-lima`. base's Ubuntu cloud image and its apt packages have nothing to bump: devvm pins the newest image on each machine at its first build of base, and records the newest packages for each key of base at its first build ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image), [base's packages](../internals/images.md#bases-packages)). `docker` moves Docker's packages (`assets/layers/docker.sh`), read from its repository for base's Ubuntu release, and its signing key. Packages added to `assets/layers/base.sh` or `assets/features/` need no pin of their own: they change base's key, whose first build records them. +`scripts/bump.sh` moves every version pinned in the repo, so preparing a release's pins is one command: + +```sh +scripts/bump.sh --check # every pin, by group, against upstream; changes nothing +scripts/bump.sh # every patch and minor bump, then a summary for the commit message +scripts/bump.sh docker mermaid # only these tools, with a named images or e2e tool's major +``` + +- `--check` prints each group's pins under its name in brackets, such as `[go]`, with each pin's current version and upstream's newest, and whether a bump would be a patch, a minor or a major, or a new digest, commit, checksum or release for a pin that isn't a version. A held pin says which version holds it, and a line that the run wouldn't apply says how to apply it. When upstream's latest is older than a pin, as when a release marker hasn't moved yet, `--check` says the pin is newer and `bump.sh` leaves it as it is. +- With no tools named, `bump.sh` applies every patch and minor bump, and never a major, a held pin or a tool that it applies only when named. Naming an images or e2e tool applies its major too. `e2e-tools` always applies one, because users get the shared tools' new majors as well, and `assets/shared-tools/mise.toml` holds what stays. +- It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit, an image digest), since some of the edited files run on the host, and it edits nothing unless every value is good. Then it runs the commands that finish a bump: `mise lock` for Go and the dev tools, `go get` and `go mod tidy` for the modules, `go get` and `hugo mod tidy` in `docs/` for Hextra, and actionlint and zizmor for the workflows. If one of those fails, the pins are already edited, and it says so. +- It needs `curl` and `jq`, `mise` for Go, the dev tools and the end-to-end lock, `go` to apply the modules and Hextra, and `gh` for the actions. +- Every Monday the Pins workflow (`.github/workflows/pins.yml`) runs `scripts/bump.sh --check` and opens or updates one issue, "Pinned versions to bump", which lists the outdated pins under their groups, and closes it once none is left. It never bumps anything: you run `scripts/bump.sh`, then the `--from` tier of the [end-to-end tests](tests.md#end-to-end-tests) when an images or e2e pin moved, because those bumps change images. + +The tools, by group, as `--check` prints them: + +| Group | Tools | What they move | +| --- | --- | --- | +| `images` | `docker`, `nix`, `direnv`, `nix-direnv`, `mise`, `git-lfs`, `rustup`, `crane`, `omb`, `eza`, `tealdeer` | the downloads pinned in `assets/`, and devvm's host mise | +| `shared-tools` | `cursor`, only when named | Cursor's CLI in `assets/shared-tools/mise.toml`, the one shared tool pinned for users | +| `e2e` | `e2e-tools`, `e2e-from`, `e2e-curl`, `e2e-ubuntu`, `e2e-lima` | the end-to-end tests' own pins | +| `go` | `go`, `go-minor` only when named, `go-mods`, `deadcode` | Go, its modules and the deadcode task | +| `dev-tools` | `dev-tools` | `mise.toml`'s tools but Go, with their `mise.lock` entries | +| `ci` | `ci-mise`, `actions` | the mise the workflows install, and their actions | +| `docs` | `hextra`, `mermaid` only when named | the docs site's theme and Mermaid | + +- `go` moves Go to its newest patch release of the minor that `go.mod` names: the `go` lines of `go.mod` and `docs/go.mod`, `mise.toml`'s `go`, and its `mise.lock` entries, from `go.dev/dl`. `--check` reports a newer minor on the `go-minor` line, and `scripts/bump.sh go-minor` moves the same files to it. +- `go-mods` moves `go.mod`'s direct modules, the ones the depguard allowlist allows and the tests' own, to their newest patch or minor release from the Go module proxy, with `go get` and `go mod tidy`. The indirect ones move as `go mod tidy` needs them. A module's next major has a new path, so `--check` reports it and you move it by hand. `deadcode` moves the deadcode task's version in `mise.toml` to golang.org/x/tools' newest release. +- `dev-tools` moves each of `mise.toml`'s tools but Go to mise's newest version of it, edits its line and runs `mise lock`, so `mise.lock` keeps every platform's checksum, and markdownlint-cli2's lock folder in `.mise/locks/` moves with it. +- `ci-mise` moves the `version` that the workflows give jdx/mise-action to base's mise, as the run leaves it, so `scripts/bump.sh mise ci-mise` moves both. `actions` moves each workflow's `uses:` to its newest release's tag, as the tag's commit from `gh api`, with the tag in the comment after it, and reports a newer major without applying it. +- `hextra` moves the docs site's theme in `docs/go.mod`, and it reminds you to compare the copies of Hextra's files in `docs/layouts/` with the new release's. `mermaid` moves the Mermaid version in `docs/hugo.yaml`, only when named, because its diagrams need a look on the built site. +- `cursor` moves Cursor's CLI, only when named, to the release that Cursor's install script fetches, with each platform's SHA-256 computed from its download, because Cursor publishes no checksums. devvm's login and proxy code was read against the pinned release, so read the new one where that code names it, then run `e2e-tools`. +- A hold keeps a pin below a version, and `--check` shows the newest version beside it. Go modules and actions take Dependabot's ignore list in `.github/dependabot.yml`, which keeps pflag below 1.1.0, because pflag 1.1 prints every boolean flag with `[=true|false]` in the help. The other holds are in `bump.sh`'s `holds`, which keeps Node, the one in `mise.toml`, on its major. +- `bump.sh`'s header lists every pin with the tool that moves it, or with `-` and the reason it's left, as `# pin` lines. `TestBumpCoversPins` in `internal/structure` finds the pins in `assets/`, `mise.toml`, both `go.mod` files, the workflows, `tests/e2e-mise.lock`, `tests/e2e`'s consts and `docs/hugo.yaml`, without the network, and fails on a pin that no line covers or on a line that covers nothing, so a new pin gets a tool or a reason. The header also says why the pins outside those files are left as they are, such as the Lima that `install.sh` installs, which is the newest release checked against its `SHA256SUMS`, and the Homebrew formula, whose URLs and checksums `release.sh` fills in. +- base's Ubuntu cloud image and its apt packages have nothing to bump: devvm pins the newest image on each machine at its first build of base, and records the newest packages for each key of base at its first build ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image), [base's packages](../internals/images.md#bases-packages)). `docker` moves Docker's packages (`assets/layers/docker.sh`), read from its repository for base's Ubuntu release, and its signing key. Packages added to `assets/layers/base.sh` or `assets/features/` need no pin of their own: they change base's key, whose first build records them. - `mise` moves base's mise (`assets/layers/base.sh`) and devvm's host mise (`internal/tools/mise.go`) together: the host one writes the lock base's installs from. `TestMisePins` fails when their versions or Linux checksums differ, and base's mise version is in the key of each tool image mise installs, so a bump builds them again. -- The shared tools aren't pinned for users: holds go in `assets/shared-tools/mise.toml` (`node = "24"` stays on that major). `testdata/mise.lock` is a fixed lock for the tests. +- The shared tools aren't pinned for users, but for Cursor's CLI: holds go in `assets/shared-tools/mise.toml` (`node = "24"` stays on that major). `testdata/mise.lock` is a fixed lock for the tests. - Their backends are named in `mise.toml`'s `[tool_alias]` table, for every tool that isn't one of mise's own `core:` tools, because mise's registry can move a tool to another backend in any release ([versions](../internals/images.md#versions)). A new shared tool gets its alias there, and `TestToolBackendsNamed` fails when a tool that isn't a `core:` tool has none, or when its alias isn't the backend that `tests/e2e-mise.lock` resolved. - When opencode's major version changes, or a bump of `e2e-tools` moves opencode to a version that adds migrations, refresh `internal/vm/testdata/opencode-.sql`, the schema of opencode's database that `TestOpencodeCleanSchema` cleans. Print it with `sqlite3 ~/.local/share/opencode/opencode.db .schema` in a VM with that opencode, after `opencode auth list` has made the database, and copy only the schema, never rows. Name the file for the version, and in the test put each new table in its list of tables that devvm empties or keeps, which the test asks for. A table or a column that holds a login also goes into `opencodeLogins` (`internal/vm/agents.go`) and the design note's [opencode's database in history exports](../internals/design.md#opencodes-database-in-history-exports). -- `e2e-tools`, `e2e-from` and `e2e-ubuntu` move the end-to-end tests' own pins, which keep their cached images valid between runs: `e2e-tools` resolves `tests/e2e-mise.lock` again, with devvm's pinned host mise, for both architectures' glibc and musl VMs, and refuses a tool whose download has no checksum on every platform yet; `e2e-from` moves the digests of `node:24`, `alpine:3` and `ubuntu:26.04` in `tests/e2e/from_test.go` to Docker Hub's; `e2e-ubuntu` moves `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go`, the dated release of Ubuntu's cloud image that e2e pins base to in place of the newest, to the newest Ubuntu lists. Ubuntu removes dated releases after a few months, and e2e's going stops its first builds of base: bump `e2e-ubuntu` before that. Run `e2e-tools` after any change to `assets/shared-tools/mise.toml`, because the end-to-end tests refuse a lock resolved from another one ([end-to-end tests](tests.md#end-to-end-tests)). `mise run test` catches it first: `TestE2ELockPins` checks the lock's first line against `mise.toml` and that it locks each of its tools, and `TestE2EUbuntuPins` checks that `e2eUbuntuRelease` is a dated release of base's Ubuntu release, which `e2e-ubuntu` lists, and that `scripts/bump.sh` and `tests/e2e` name only that release. +- `e2e-tools`, `e2e-from`, `e2e-curl` and `e2e-ubuntu` move the end-to-end tests' own pins, which keep their cached images valid between runs: `e2e-tools` resolves `tests/e2e-mise.lock` again, with devvm's pinned host mise, for both architectures' glibc and musl VMs, and refuses a tool whose download has no checksum on every platform yet; `e2e-from` moves the digests of `node:24`, `alpine:3` and `ubuntu:26.04` in `tests/e2e/from_test.go` to Docker Hub's; `e2e-curl` moves `curlImage` in `tests/e2e/transparent_test.go`, the curl image that the network checks run in containers, to curlimages/curl's newest release, by its digest; `e2e-ubuntu` moves `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go`, the dated release of Ubuntu's cloud image that e2e pins base to in place of the newest, to the newest Ubuntu lists. Ubuntu removes dated releases after a few months, and e2e's going stops its first builds of base: bump `e2e-ubuntu` before that. Run `e2e-tools` after any change to `assets/shared-tools/mise.toml`, because the end-to-end tests refuse a lock resolved from another one ([end-to-end tests](tests.md#end-to-end-tests)). `mise run test` catches it first: `TestE2ELockPins` checks the lock's first line against `mise.toml` and that it locks each of its tools, and `TestE2EUbuntuPins` checks that `e2eUbuntuRelease` is a dated release of base's Ubuntu release, which `e2e-ubuntu` lists, and that `scripts/bump.sh` and `tests/e2e` name only that release. - `e2e-lima` moves the Lima release that CI's end-to-end workflow installs, `LIMA_VERSION` in `.github/workflows/e2e.yml`, to Lima's newest release, and `LIMA_SHA256` to its `Linux-x86_64` tarball's line in that release's `SHA256SUMS`. Lima's release notes print the SHA-256 of `SHA256SUMS` itself, so `e2e-lima` checks the downloaded file against that value first and edits nothing when they differ. - `assets/layers/ubuntu-cloud.gpg` is Ubuntu's cloud image signing key (fingerprint `D2EB44626FDDC30B513D5BB71A5D6C4C7DB87C81`), from keyserver.ubuntu.com. If Ubuntu changes it, pinning a new image (a first build of base, or `devvm rebuild base`) stops with `ubuntu_bad_signature`: fetch the new key, check its fingerprint against Ubuntu's announcement, and replace the file (`gpg --export FPR`). - `assets/layers/ubuntu-archive.gpg` is Ubuntu's archive signing key, "Ubuntu Archive Automatic Signing Key (2018)" (fingerprint `F6ECB3762474EDA9D21B7022871920D1991BC93C`), fetched from keyserver.ubuntu.com by that fingerprint, checked against the fingerprint that [Ubuntu's security team lists](https://wiki.ubuntu.com/SecurityTeam/FAQ), and exported with `gpg --export-options export-minimal --export FPR`. devvm checks the `InRelease` files of a first build of base against it (`ubuntu.ArchiveKeyring`). If Ubuntu signs the archive with a new key, that build stops with `packages_refused`: fetch the new key, check its fingerprint the same way, and replace the file. The key must be RSA, because `internal/ubuntu/pgp.go` checks only RSA signatures. Moving base to a new Ubuntu release (`ubuntu.Series`, `ubuntu.Version`) also moves `ubuntu.Released`, the day Ubuntu released it, which is the date of that release's own `InRelease` (`dists//InRelease`), because devvm refuses a release pocket dated before it. diff --git a/docs/content/docs/contributing/structure.md b/docs/content/docs/contributing/structure.md index aeffac97..b2a5903c 100644 --- a/docs/content/docs/contributing/structure.md +++ b/docs/content/docs/contributing/structure.md @@ -142,7 +142,7 @@ A VM's state, `vm.json`, has one owner too, `internal/state`, which reads and wr ### Agreement tests -When two places must agree but can't be one, a test checks that they agree. `TestEveryPartHasAPolicy` checks that every image part has its policy, `TestSharedToolsPolicies` that the policies in `assets/shared-tools/` are one for each shared tool in `image.SharedTools`, `TestConfigTools` that `assets/shared-tools/mise.toml` lists each shared tool's members and nothing else, `TestBuiltinPolicies` that every policy devvm ships parses, `TestEveryMessageIsUsed` that every message has a caller, `TestDocLinks` that every doc link is a message and a heading, `TestPreludeUsers` that only the scripts that get the prelude use it, `TestDefsComplete` that every coding agent has its `[tool_alias]` line and its row in the docs' Supported agents table, `TestProvidersComplete` that every provider in `agents.Providers` has its row in the docs' table of the API keys the proxy puts in, `TestToolchainsComplete` that every toolchain has files that call for it and its row and section on the toolchains page, which names those files and its `PATH` folders, `TestFormatsCoverLogins` that every agent's login file has its format in `internal/agentlogin`, and `TestReferenceIsCurrent` that the CLI reference matches the commands. A new pair of places that must agree gets such a test. +When two places must agree but can't be one, a test checks that they agree. `TestEveryPartHasAPolicy` checks that every image part has its policy, `TestSharedToolsPolicies` that the policies in `assets/shared-tools/` are one for each shared tool in `image.SharedTools`, `TestConfigTools` that `assets/shared-tools/mise.toml` lists each shared tool's members and nothing else, `TestBuiltinPolicies` that every policy devvm ships parses, `TestEveryMessageIsUsed` that every message has a caller, `TestDocLinks` that every doc link is a message and a heading, `TestPreludeUsers` that only the scripts that get the prelude use it, `TestDefsComplete` that every coding agent has its `[tool_alias]` line and its row in the docs' Supported agents table, `TestProvidersComplete` that every provider in `agents.Providers` has its row in the docs' table of the API keys the proxy puts in, `TestToolchainsComplete` that every toolchain has files that call for it and its row and section on the toolchains page, which names those files and its `PATH` folders, `TestFormatsCoverLogins` that every agent's login file has its format in `internal/agentlogin`, `TestBumpCoversPins` that `scripts/bump.sh` moves every pin it finds, or says why it's left ([updating pinned versions](maintaining.md#updating-pinned-versions)), and `TestReferenceIsCurrent` that the CLI reference matches the commands. A new pair of places that must agree gets such a test. ### The consolidation pass diff --git a/internal/structure/pins_test.go b/internal/structure/pins_test.go new file mode 100644 index 00000000..cc8e524d --- /dev/null +++ b/internal/structure/pins_test.go @@ -0,0 +1,178 @@ +package structure + +import ( + "io/fs" + "os" + "path" + "regexp" + "slices" + "strings" + "testing" +) + +// pinPattern is where TestBumpCoversPins looks for one kind of pin: a +// file (a glob, or a folder for every file below it, ending in /), and +// in it only a TOML section when one is named, a pattern whose first +// group names a pin, and the key's prefix it gets, before the name. A +// key is "FILE:NAME", or "FILE:KIND:NAME" for the files with more than +// one kind of pin. +type pinPattern struct { + glob, section, prefix string + re *regexp.Regexp +} + +// pinPatterns are the pins TestBumpCoversPins finds. +func pinPatterns() []pinPattern { + type p = pinPattern + version := `v?[0-9]+\.[0-9]+` + return []p{ + // A pinned download's _version, _commit and _sha256* lines, + // and a version in a mise.toml's inline table (cursor's). + {"assets/", "", "", regexp.MustCompile(`(?m)^([a-z][a-z0-9_]*?)_(?:version|commit|sha256(?:_[a-z0-9]+)*)=`)}, + {"assets/", "", "", regexp.MustCompile(`(?m)^"?([A-Za-z0-9_.:/-]+)"? = \{ ?version = "[^"]*[0-9]+\.[0-9]+`)}, + {"mise.toml", "tools", "tool:", regexp.MustCompile(`(?m)^"?([A-Za-z0-9_.:/-]+)"? = `)}, + {"mise.toml", "", "run:", regexp.MustCompile(`([A-Za-z0-9_./-]+)@` + version)}, + {"go.mod", "", "", regexp.MustCompile(`(?m)^(go|toolchain) `)}, + {"go.mod", "", "require:", regexp.MustCompile(`(?m)^(?:require )?\t?([a-z0-9]\S*) v[0-9]+\.\S+$`)}, + {"go.mod", "", "indirect:", regexp.MustCompile(`(?m)^(?:require )?\t?([a-z0-9]\S*) v[0-9]+\.\S+ // indirect$`)}, + {"docs/go.mod", "", "", regexp.MustCompile(`(?m)^(go|toolchain) `)}, + {"docs/go.mod", "", "require:", regexp.MustCompile(`(?m)^(?:require )?\t?([a-z0-9]\S*) v[0-9]+\.\S+$`)}, + {"docs/go.mod", "", "indirect:", regexp.MustCompile(`(?m)^(?:require )?\t?([a-z0-9]\S*) v[0-9]+\.\S+ // indirect$`)}, + // Every workflow's uses:, and every value that is a version or a + // SHA-256, by its key. + {".github/workflows/*.yml", "", "uses:", regexp.MustCompile(`uses: ([^.\s@][^\s@]*)@`)}, + {".github/workflows/*.yml", "", "", regexp.MustCompile(`(?m)^\s*([A-Za-z_][A-Za-z0-9_-]*): ["']?` + version + `[0-9A-Za-z.+-]*["']?\s*$`)}, + {".github/workflows/*.yml", "", "", regexp.MustCompile(`(?m)^\s*([A-Za-z_][A-Za-z0-9_-]*): [0-9a-f]{64}\s*$`)}, + {"tests/e2e-mise.lock", "", "", regexp.MustCompile(`(?m)^\[\[tools\.("?[^\]"]+"?)\]\]$`)}, + // tests/e2e's pinned consts: an image digest, a dated release or a + // version. + {"tests/e2e/*.go", "", "", regexp.MustCompile(`(?m)^const (\w+) = ".*(?:sha256:[0-9a-f]{64}|release-[0-9]{8}|[0-9]+\.[0-9]+\.[0-9]+).*"$`)}, + {"docs/hugo.yaml", "", "", regexp.MustCompile(`([A-Za-z0-9_.-]+)@` + version)}, + {"docs/hugo.yaml", "", "", regexp.MustCompile(`(?m)^\s*([A-Za-z_]+): ["']?` + version + `\.[0-9]+["']?\s*$`)}, + } +} + +// pinFiles is the files p reads, by their names in the repo. +func pinFiles(t *testing.T, fsys fs.FS, p pinPattern) []string { + t.Helper() + if dir, ok := strings.CutSuffix(p.glob, "/"); ok { + var files []string + err := fs.WalkDir(fsys, dir, func(name string, d fs.DirEntry, err error) error { + if err == nil && !d.IsDir() { + files = append(files, name) + } + return err + }) + if err != nil { + t.Fatal(err) + } + return files + } + files, err := fs.Glob(fsys, p.glob) + if err != nil || len(files) == 0 { + t.Fatalf("%s: no files (%v)", p.glob, err) + } + return files +} + +// tomlSection is the lines of data's [name] section, or all of data +// when name is "". +func tomlSection(data, name string) string { + if name == "" { + return data + } + _, s, ok := strings.Cut(data, "\n["+name+"]\n") + if !ok { + return "" + } + s, _, _ = strings.Cut(s, "\n[") + return s +} + +// foundPins is every pin pinPatterns finds, each key once. The +// workflows' keys are all .github/workflows's, tests/e2e's files' all +// tests/e2e's. +func foundPins(t *testing.T) []string { + t.Helper() + fsys := os.DirFS(root) + var keys []string + for _, p := range pinPatterns() { + for _, f := range pinFiles(t, fsys, p) { + data, err := fs.ReadFile(fsys, f) + if err != nil { + t.Fatal(err) + } + file := f + if d := path.Dir(f); d == ".github/workflows" || d == "tests/e2e" { + file = d + } + for _, m := range p.re.FindAllStringSubmatch(tomlSection(string(data), p.section), -1) { + keys = append(keys, file+":"+p.prefix+strings.Trim(m[1], `"`)) + } + } + } + slices.Sort(keys) + return slices.Compact(keys) +} + +// TestBumpCoversPins checks that scripts/bump.sh moves every pin in the +// files pinPatterns reads, or says why not: each pin found is a "# pin +// KEY TOOL" line of its header (a KEY ending in * covers every key it +// starts), whose TOOL is one bump.sh has, or "-" and a reason. A line +// that covers nothing fails too, so the list stays the pins there are. +// It reads only the repo: it checks coverage, not freshness, which +// bump.sh --check does. +func TestBumpCoversPins(t *testing.T) { + data, err := os.ReadFile(path.Join(root, "scripts/bump.sh")) + if err != nil { + t.Fatal(err) + } + bump := string(data) + every := regexp.MustCompile(`(?m)^every="([^"]*)"$`).FindStringSubmatch(bump) + if every == nil { + t.Fatal(`scripts/bump.sh has no every="TOOL..." line`) + } + tools := strings.Fields(every[1]) + for _, tool := range tools { + if !strings.Contains(bump, "\nbump_"+tool+"() {") { + t.Errorf("scripts/bump.sh lists %s but has no bump_%s", tool, tool) + } + } + entries := regexp.MustCompile(`(?m)^# pin (\S+) (\S+)(?: (.*))?$`).FindAllStringSubmatch(bump, -1) + if len(entries) == 0 { + t.Fatal("scripts/bump.sh's header has no # pin lines") + } + used := make(map[string]bool) + for _, e := range entries { + switch key, tool, why := e[1], e[2], e[3]; { + case tool == "-" && strings.TrimSpace(why) == "": + t.Errorf("scripts/bump.sh: # pin %s is left without a reason", key) + case tool != "-" && !slices.Contains(tools, tool): + t.Errorf("scripts/bump.sh: # pin %s names %s, which isn't one of its tools", key, tool) + } + } + for _, key := range foundPins(t) { + // The exact key, else the longest * that starts it. + match := "" + for _, e := range entries { + k := e[1] + if k == key { + match = k + break + } + if p, ok := strings.CutSuffix(k, "*"); ok && strings.HasPrefix(key, p) && len(k) > len(match) { + match = k + } + } + if match == "" { + t.Errorf("%s is a pin that scripts/bump.sh doesn't cover: give it a tool, or a # pin line with - and why it's left", key) + continue + } + used[match] = true + } + for _, e := range entries { + if !used[e[1]] { + t.Errorf("scripts/bump.sh: # pin %s matches no pin: remove it, or fix its key", e[1]) + } + } +} diff --git a/scripts/bump.sh b/scripts/bump.sh index c313c82a..2878afe6 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -1,33 +1,126 @@ #!/bin/bash -# Update the versions and checksums pinned in assets/ (layers/base.sh, layers/docker.sh, layers/nix.sh, features/*.sh, -# shared-tools/build.sh, oci/build.sh) and internal/tools/mise.go (devvm's host mise), and the -# end-to-end tests' own pins (tests/e2e-mise.lock, the --from images' digests in tests/e2e/from_test.go, -# Ubuntu's cloud image release in tests/e2e/sandbox_test.go, and CI's Lima in .github/workflows/e2e.yml). -# scripts/bump.sh --check show current and latest for every pin; change nothing -# scripts/bump.sh [tool...] update the given tools (default: all) and print a summary -# Tools: docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer e2e-tools e2e-from e2e-ubuntu e2e-lima -# mise: base's, and the one devvm runs on the host to resolve the shared tools' versions -# e2e-tools: the shared tools' versions every e2e section but tools uses -# e2e-from: the container images e2e's --from checks start from, by digest -# e2e-ubuntu: the dated release of Ubuntu's cloud image e2e pins base to -# e2e-lima: the Lima release CI's e2e workflow installs, and its tarball's checksum +# Update every version and checksum pinned in the repo: the downloads in assets/ and devvm's host mise, +# the end-to-end tests' own pins, Go and its modules, the dev tools in mise.toml, the workflows' actions +# and the docs site's theme and Mermaid. +# scripts/bump.sh --check show current and latest for every pin, by group, with whether a bump is +# a patch, minor or major; change nothing +# scripts/bump.sh apply every safe bump: patches and minors, never a major or a held pin, +# nor the tools applied only when named; print a summary for the commit +# scripts/bump.sh tool... update the given tools; naming an images or e2e tool applies its major too +# Tools, by group: +# images: docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer +# mise: base's, and the one devvm runs on the host to resolve the shared tools' versions +# shared-tools: cursor (only when named), the one shared tool pinned for users +# (assets/shared-tools/mise.toml): devvm's login and proxy code was read against its pinned release +# e2e: e2e-tools e2e-from e2e-curl e2e-ubuntu e2e-lima +# e2e-tools: the shared tools' versions every e2e section but tools uses; it applies majors, as +# users get them too (assets/shared-tools/mise.toml holds what's held) +# e2e-from: the container images e2e's --from checks start from, by digest +# e2e-curl: the curl image e2e's network checks run in containers, its newest release by digest +# e2e-ubuntu: the dated release of Ubuntu's cloud image e2e pins base to +# e2e-lima: the Lima release CI's e2e workflow installs, and its tarball's checksum +# go: go go-minor go-mods deadcode +# go: Go's newest patch release (go.mod's and docs/go.mod's go lines, mise.toml and mise.lock) +# go-minor (only when named): Go's newest minor release, the same files +# go-mods: go.mod's direct modules (the depguard allowlist), patches and minors, with go get and +# go mod tidy; a module's next major, a new path, is only reported; the indirect ones move as +# go mod tidy needs them +# deadcode: mise.toml's deadcode task, golang.org/x/tools' newest release +# dev-tools: mise.toml's tools but go, through mise lock, so mise.lock keeps their checksums +# ci: ci-mise actions +# ci-mise: the mise the workflows install (jdx/mise-action's version), base's mise +# actions: every workflow's uses:, by its release's tag's commit, then actionlint and zizmor +# docs: hextra mermaid +# hextra: the docs site's theme, docs/go.mod +# mermaid (only when named): docs/hugo.yaml's Mermaid; its diagrams need a look after a bump +# Holds: a pin that never moves past a version. Go modules and actions take Dependabot's ignore +# list (.github/dependabot.yml: pflag stays below 1.1.0, whose help prints every boolean flag with +# [=true|false]); the rest are holds below. +holds="node 25" # NAME BOUND...: node stays on its major, 24, which is an LTS release # The shared tools themselves (node, claude, ...) and Ubuntu's cloud image aren't pinned for users: # devvm resolves them per user. Only e2e pins them, so its cached images stay valid between runs. -# Needs curl and jq. Checksums come from upstream's published sums where there are -# any; otherwise they're computed from the download (said so in the output). Edited scripts change -# image keys, so the affected images rebuild on next use: test with `devvm build `, then -# `devvm gc`. +# Left as they are, on purpose: +# install.sh's Lima: the newest release, checked against its SHA256SUMS when it's installed +# packaging/homebrew/devvm.rb: release.sh fills in each release's URLs and checksums +# testdata/mise.lock and testdata/v/: fixed for the tests, and frozen +# skills-lock.json: the vendored security-audit skill's hash, from the skills tool +# docs/static's fonts and docs/assets/icons: files copied in, with their versions in comments +# docs/layouts' copies of Hextra's files (the hero button, Mermaid's partial): checked by hand +# against Hextra's after a hextra bump +# assets/layers/ubuntu-*.gpg and internal/ubuntu's Series: keys and a release, moved by hand +# (contributing/maintaining.md) +# tests/e2e/tools_test.go's cowsay@1.6.0: any version works, it only installs one +# Pins: each pin internal/structure's TestBumpCoversPins finds (assets/'s _version, _commit and +# _sha256 lines and its mise.toml's versions, mise.toml, the go.mod files, the workflows' uses: and +# version values, tests/e2e-mise.lock, tests/e2e's pinned consts and docs/hugo.yaml), as KEY and the +# tool that moves it, or "-" and why it's left. A KEY ending in * is every key it starts. A pin +# found and not here fails the test, and so does a line here that finds nothing. +# pin assets/features/cli-tools.sh:eza eza +# pin assets/features/cli-tools.sh:tealdeer tealdeer +# pin assets/features/omb.sh:omb omb +# pin assets/layers/base.sh:mise mise +# pin assets/layers/base.sh:git_lfs git-lfs +# pin assets/layers/docker.sh:docker docker +# pin assets/layers/docker.sh:containerd docker +# pin assets/layers/docker.sh:buildx docker +# pin assets/layers/docker.sh:compose docker +# pin assets/layers/docker.sh:model docker +# pin assets/layers/docker.sh:docker_gpg docker +# pin assets/layers/nix.sh:nix nix +# pin assets/layers/nix.sh:direnv direnv +# pin assets/layers/nix.sh:nix_direnv nix-direnv +# pin assets/oci/build.sh:crane crane +# pin assets/shared-tools/build.sh:rustup rustup +# pin assets/shared-tools/mise.toml:cursor cursor +# pin go.mod:go go +# pin go.mod:require:* go-mods +# pin go.mod:indirect:* - moved by go mod tidy, as the direct modules need them +# pin docs/go.mod:go go +# pin docs/go.mod:indirect:github.com/imfing/hextra hextra +# pin mise.toml:tool:go go +# pin mise.toml:tool:* dev-tools +# pin mise.toml:run:golang.org/x/tools/cmd/deadcode deadcode +# pin .github/workflows:uses:* actions +# pin .github/workflows:version ci-mise +# pin .github/workflows:LIMA_VERSION e2e-lima +# pin .github/workflows:LIMA_SHA256 e2e-lima +# pin tests/e2e-mise.lock:* e2e-tools +# pin tests/e2e:e2eUbuntuRelease e2e-ubuntu +# pin tests/e2e:fromNodeDigest e2e-from +# pin tests/e2e:fromAlpineDigest e2e-from +# pin tests/e2e:fromUbuntuDigest e2e-from +# pin tests/e2e:curlImage e2e-curl +# pin tests/e2e:dotnetOther - an SDK other than the shared one for a global.json to ask for: any older one works +# pin docs/hugo.yaml:mermaid mermaid +# pin docs/hugo.yaml:min - Hextra's oldest Hugo, which Hugo checks; mise.toml pins the Hugo that builds the site +# Needs curl and jq, and per group mise (dev-tools, go, e2e lock checks), go (go-mods, hextra when +# applied) and gh (actions). Checksums come from upstream's published sums where there are any; +# otherwise they're computed from the download (said so in the output). Edited scripts change image +# keys, so the affected images rebuild on next use: test with `devvm build `, then `devvm gc`. set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -all="docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer e2e-tools e2e-from e2e-ubuntu e2e-lima" +every="docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer cursor e2e-tools e2e-from e2e-curl e2e-ubuntu e2e-lima go go-minor go-mods deadcode dev-tools ci-mise actions hextra mermaid" +# Applied only when named: --check reports them. +named_only="cursor go-minor mermaid" +# Naming one of these applies its major too. +legacy="docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer e2e-tools e2e-from e2e-curl e2e-ubuntu e2e-lima" -check=false +check=false named=false if [[ ${1:-} == --check ]]; then check=true; shift; fi -tools=${*:-$all} -for t in $tools; do [[ " $all " == *" $t "* ]] || { echo "bump: unknown tool '$t' (have: $all)" >&2; exit 1; }; done +if (( $# > 0 )); then + named=true tools=$* +elif $check; then + tools=$every +else + tools="" + for t in $every; do [[ " $named_only " == *" $t "* ]] || tools+="$t "; done +fi +for t in $tools; do [[ " $every " == *" $t "* ]] || { echo "bump: unknown tool '$t' (have: $every)" >&2; exit 1; }; done for c in curl jq; do command -v "$c" >/dev/null || { echo "bump: needs $c" >&2; exit 1; }; done +# need CMD: the current tool needs CMD. +need() { command -v "$1" >/dev/null || { echo "bump: $cur_tool needs $1" >&2; exit 1; }; } -summary=() +summary=() notes=() tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT @@ -57,6 +150,8 @@ valid() { *_digest | *Digest) re='^sha256:[0-9a-f]{64}$' ;; *_release) re='^release-[0-9]{8}$' ;; *_built) re='^[0-9]{8}T[0-9]{6}Z$' ;; + *Image) re='^[a-z0-9][a-z0-9./-]*:[0-9A-Za-z][0-9A-Za-z._-]*@sha256:[0-9a-f]{64}$' ;; + *_module) re='^[A-Za-z0-9][A-Za-z0-9._~/-]*$' ;; esac [[ $2 =~ $re ]] || { printf 'bump: upstream gave %s an unexpected value: %q\n' "$1" "$2" >&2; exit 1; } } @@ -88,13 +183,51 @@ write_staged() { fi cat "$tmp/edit" > "$root/${staged[i]}" done + # set_text's edits: a whole line, or every occurrence of a text. + for (( i = 0; i < ${#texts[@]}; i += 4 )); do + M=${texts[i + 1]} O=${texts[i + 2]} V=${texts[i + 3]} awk ' + ENVIRON["M"] == "line" { if ($0 == ENVIRON["O"]) print ENVIRON["V"]; else print; next } + { o = ENVIRON["O"]; out = ""; s = $0 + while ((j = index(s, o)) > 0) { out = out substr(s, 1, j - 1) ENVIRON["V"]; s = substr(s, j + length(o)) } + print out s }' "$root/${texts[i]}" > "$tmp/edit" + cat "$tmp/edit" > "$root/${texts[i]}" + done +} +# set_text FILE line|text OLD NEW: stages NEW in place of the line OLD, or of each OLD in the file's +# lines. The caller checks NEW's values with valid first. +texts=() +set_text() { texts+=("$1" "$2" "$3" "$4"); } +# staged_value FILE VAR: VAR's value as this run stages it, else as FILE has it. +staged_value() { + local i v + v=$(get "$1" "$2") + for (( i = 0; i < ${#staged[@]}; i += 3 )); do + [[ ${staged[i]} != "$1" || ${staged[i + 1]} != "$2" ]] || v=${staged[i + 2]} + done + echo "$v" } -# report TOOL CURRENT LATEST: print it; true when an update is wanted (not --check, and different). +# bump_kind CURRENT NEW: patch, minor or major for two versions (a leading v aside); calendar for a +# new year of a version that starts with one (mise's 2026.11.8), which is safe; else change. +bump_kind() { + local a=${1#v} b=${2#v} re='^[0-9]+(\.[0-9]+)*$' a1 b1 + [[ $a =~ $re && $b =~ $re ]] || { echo change; return; } + a1=${a%%.*} b1=${b%%.*} + if [[ $a1 != "$b1" ]]; then + if (( a1 >= 1000 )); then echo calendar; else echo major; fi + return + fi + a=${a#"$a1"}; a=${a#.}; b=${b#"$b1"}; b=${b#.} + if [[ ${a%%.*} == "${b%%.*}" ]]; then echo patch; else echo minor; fi +} + +# report TOOL CURRENT LATEST [KIND]: print it, with the bump's kind (else bump_kind's); true when an +# update is wanted: not --check, different, and neither a major the run doesn't apply (majors_ok) +# nor a tool applied only when named that wasn't. report() { if [[ $2 == "$3" ]]; then printf ' %-9s %-14s up to date\n' "$1" "$2"; return 1; fi # The latest comes from upstream: no control characters on the terminal. - local shown + local shown kind note="" shown=$(LC_ALL=C tr -d '\000-\037\177' <<<"$3") # Upstream's latest can lag behind a pin (a release marker not yet moved): an older version is # never offered. @@ -102,11 +235,59 @@ report() { if [[ $2 =~ $ver && $3 =~ $ver && $(printf '%s\n%s\n' "${2#v}" "${3#v}" | sort -V | head -1) == "${3#v}" ]]; then printf " %-9s %-14s newer than upstream's latest, %s\n" "$1" "$2" "$shown"; return 1 fi - printf ' %-9s %-14s -> %s\n' "$1" "$2" "$shown" + kind=${4:-$(bump_kind "$2" "$3")} + if [[ $kind == major ]] && ! $majors_ok; then + if [[ " $legacy " == *" $cur_tool "* ]]; then note=", applied when named: scripts/bump.sh $cur_tool"; else note=", not applied: by hand"; fi + elif $only_named; then + note=", applied only when named: scripts/bump.sh $cur_tool" + fi + printf ' %-9s %-14s -> %s (%s%s)\n' "$1" "$2" "$shown" "$kind" "$note" $check && return 1 + [[ -z $note ]] || return 1 summary+=("$1: $2 -> $3") } +# held NAME VERSION: VERSION is at or past a hold on NAME (holds, then .github/dependabot.yml's +# ignore list); prints the bound. +held() { + local b + # shellcheck disable=SC2086 # holds: NAME BOUND pairs, a word each + b=$( { printf '%s %s\n' $holds + awk '/- dependency-name:/ { n = $3 } n && /versions: \[">= / { v = $0; sub(/.*">= /, "", v); sub(/".*/, "", v); print n, v; n = "" }' \ + "$root/.github/dependabot.yml"; } | awk -v n="$1" '$1 == n { print $2; exit }') + [[ -n $b && $(printf '%s\n%s\n' "${b#v}" "${2#v}" | sort -V | head -1) == "${b#v}" ]] || return 1 + echo "$b" +} +# say_held NAME CURRENT BOUND NEWEST: the line for a newest version that a hold keeps out. +say_held() { + printf ' %-9s %-14s held below %s (newest %s)\n' "$1" "$2" "$3" "$(LC_ALL=C tr -d '\000-\037\177' <<<"$4")" +} + +# newest_of [MAJOR]: the newest of the versions on stdin (a leading v kept), only release versions, +# within MAJOR when given; nothing for none. +newest_of() { + { grep -E '^v?[0-9]+(\.[0-9]+)*$' || true; } | awk -v m="${1:-}" '{ v = $0; sub(/^v/, "", v); split(v, p, ".") } m == "" || p[1] == m' | + sed 's/^v\(.*\)/\1 v/' | sort -V | tail -1 | awk '{ print $2 $1 }' +} + +# choose NAME CURRENT NEWEST WITHIN: report the bump to NEWEST, or when it's a major the run doesn't +# apply or a held one, to WITHIN (the newest that is neither) and NEWEST's line beside it. Sets +# target to the version to move to; true when there's one. +choose() { + local b + target="" + if b=$(held "$1" "$3"); then + say_held "$1" "$2" "$b" "$3" + elif [[ $(bump_kind "$2" "$3") == major ]] && ! $majors_ok; then + report "$1" "$2" "$3" || true + else + if report "$1" "$2" "$3"; then target=$3; fi + [[ -n $target ]]; return + fi + if [[ -n $4 && $4 != "$2" ]] && report "$1" "$2" "$4"; then target=$4; fi + [[ -n $target ]] +} + # A version plus per-arch checksums in one script. pin3() { # pin3 FILE PREFIX VERSION SHA_ARM64 SHA_AMD64 set_var "$1" "${2}_version" "$3" @@ -120,7 +301,7 @@ pin3() { # pin3 FILE PREFIX VERSION SHA_ARM64 SHA_AMD64 bump_e2e-ubuntu() { local f=tests/e2e/sandbox_test.go new new=$(fetch https://cloud-images.ubuntu.com/releases/resolute/ | grep -o 'release-[0-9]\{8\}' | sort -ru | head -1 || true) - if report e2e-ubuntu "$(get_const $f e2eUbuntuRelease)" "$new"; then set_var $f e2eUbuntuRelease "$new" e2e_ubuntu_release; fi + if report e2e-ubuntu "$(get_const $f e2eUbuntuRelease)" "$new" release; then set_var $f e2eUbuntuRelease "$new" e2e_ubuntu_release; fi } # The Lima release CI's e2e workflow installs (.github/workflows/e2e.yml's LIMA_VERSION), and its @@ -153,7 +334,7 @@ bump_docker() { if report "${p#*:}" "$(get $f "$var")" "$new"; then set_var $f "$var" "$new"; fi done sha=$(sha_of https://download.docker.com/linux/ubuntu/gpg) - if report docker-gpg "$(get $f docker_gpg_sha256 | cut -c1-12)" "$(cut -c1-12 <<<"$sha")"; then + if report docker-gpg "$(get $f docker_gpg_sha256 | cut -c1-12)" "$(cut -c1-12 <<<"$sha")" checksum; then echo " (Docker's signing key changed: check it before committing)" set_var $f docker_gpg_sha256 "$sha" fi @@ -169,6 +350,7 @@ bump_nix() { new=$(fetch https://nixos.org/nix/install | sed -n 's|^ *path=[0-9a-z]*/nix-\([0-9.]*\)-x86_64-linux\.tar\.xz$|\1|p' | head -1) [[ -n $new ]] || { echo "bump: nixos.org's installer names no nix-VERSION-x86_64-linux.tar.xz: see the layer's pins" >&2; exit 1; } report nix "$cur" "$new" || return 0 + valid nix_version "$new" u="https://releases.nixos.org/nix/nix-$new/nix-$new" pin3 $f nix "$new" "$(fetch "$u-aarch64-linux.tar.xz.sha256" | cut -c1-64)" "$(fetch "$u-x86_64-linux.tar.xz.sha256" | cut -c1-64)" } @@ -177,6 +359,7 @@ bump_direnv() { local f=assets/layers/nix.sh cur new u cur=$(get $f direnv_version); new=$(gh_latest direnv/direnv); new=${new#v} report direnv "$cur" "$new" || return 0 + valid direnv_version "$new" echo " (checksums computed from the downloads)" u="https://github.com/direnv/direnv/releases/download/v$new" pin3 $f direnv "$new" "$(sha_of "$u/direnv.linux-arm64")" "$(sha_of "$u/direnv.linux-amd64")" @@ -187,6 +370,7 @@ bump_nix-direnv() { local f=assets/layers/nix.sh cur new cur=$(get $f nix_direnv_version); new=$(gh_latest nix-community/nix-direnv); new=${new#v} report nix-direnv "$cur" "$new" || return 0 + valid nix_direnv_version "$new" echo " (checksum computed from the download)" set_var $f nix_direnv_version "$new" set_var $f nix_direnv_sha256 "$(sha_of "https://raw.githubusercontent.com/nix-community/nix-direnv/$new/direnvrc")" @@ -198,6 +382,7 @@ bump_mise() { local f=assets/layers/base.sh cur new sums cur=$(get $f mise_version); new=$(gh_latest jdx/mise); new=${new#v} report mise "$cur" "$new" || return 0 + valid mise_version "$new" sums=$(fetch "https://github.com/jdx/mise/releases/download/v$new/SHASUMS256.txt") pin3 $f mise "$new" "$(awk '$2 ~ /-linux-arm64$/ { print $1 }' <<<"$sums")" \ "$(awk '$2 ~ /-linux-x64$/ { print $1 }' <<<"$sums")" @@ -217,6 +402,7 @@ bump_rustup() { cur=$(get $f rustup_version) new=$(fetch https://static.rust-lang.org/rustup/release-stable.toml | sed -n "s/^version = '\(.*\)'/\1/p") report rustup "$cur" "$new" || return 0 + valid rustup_version "$new" u="https://static.rust-lang.org/rustup/archive/$new" pin3 $f rustup "$new" "$(fetch "$u/aarch64-unknown-linux-gnu/rustup-init.sha256" | cut -c1-64)" \ "$(fetch "$u/x86_64-unknown-linux-gnu/rustup-init.sha256" | cut -c1-64)" @@ -230,6 +416,7 @@ bump_git-lfs() { local f=assets/layers/base.sh cur new sums cur=$(get $f git_lfs_version); new=$(gh_latest git-lfs/git-lfs); new=${new#v} report git-lfs "$cur" "$new" || return 0 + valid git_lfs_version "$new" sums=$(fetch "https://github.com/git-lfs/git-lfs/releases/download/v$new/sha256sums.asc") pin3 $f git_lfs "$new" "$(awk -v n="*git-lfs-linux-arm64-v$new.tar.gz" '$2 == n { print $1 }' <<<"$sums")" \ "$(awk -v n="*git-lfs-linux-amd64-v$new.tar.gz" '$2 == n { print $1 }' <<<"$sums")" @@ -239,6 +426,7 @@ bump_eza() { local f=assets/features/cli-tools.sh cur new u cur=$(get $f eza_version); new=$(gh_latest eza-community/eza); new=${new#v} report eza "$cur" "$new" || return 0 + valid eza_version "$new" echo " (checksums computed from the downloads)" u="https://github.com/eza-community/eza/releases/download/v$new" pin3 $f eza "$new" "$(sha_of "$u/eza_aarch64-unknown-linux-gnu.tar.gz")" "$(sha_of "$u/eza_x86_64-unknown-linux-musl.tar.gz")" @@ -248,6 +436,7 @@ bump_tealdeer() { # publishes a .sha256 next to each binary local f=assets/features/cli-tools.sh cur new u cur=$(get $f tealdeer_version); new=$(gh_latest tealdeer-rs/tealdeer); new=${new#v} report tealdeer "$cur" "$new" || return 0 + valid tealdeer_version "$new" u="https://github.com/tealdeer-rs/tealdeer/releases/download/v$new" pin3 $f tealdeer "$new" "$(fetch "$u/tealdeer-linux-aarch64-musl.sha256" | cut -c1-64)" \ "$(fetch "$u/tealdeer-linux-x86_64-musl.sha256" | cut -c1-64)" @@ -258,6 +447,7 @@ bump_crane() { local f=assets/oci/build.sh cur new sums cur=$(get $f crane_version); new=$(gh_latest google/go-containerregistry); new=${new#v} report crane "$cur" "$new" || return 0 + valid crane_version "$new" sums=$(fetch "https://github.com/google/go-containerregistry/releases/download/v$new/checksums.txt") pin3 $f crane "$new" "$(awk '$2 == "go-containerregistry_Linux_arm64.tar.gz" { print $1 }' <<<"$sums")" \ "$(awk '$2 == "go-containerregistry_Linux_x86_64.tar.gz" { print $1 }' <<<"$sums")" @@ -266,7 +456,8 @@ bump_crane() { bump_omb() { local f=assets/features/omb.sh cur new cur=$(get $f omb_commit); new=$(gh_head ohmybash/oh-my-bash) - report omb "${cur:0:12}" "${new:0:12}" || return 0 + report omb "${cur:0:12}" "${new:0:12}" commit || return 0 + valid omb_commit "$new" set_var $f omb_commit "$new" } @@ -350,7 +541,7 @@ bump_e2e-tools() { if report "e2e $tool" "${cur:-none}" "$new"; then want=true; fi done < <(awk -F' *= *' '/^\[tools\]/ { s = 1; next } /^\[/ { s = 0 } s && NF == 2 { print $1 }' "$d/mise.toml") sum=$(shasum -a 256 "$d/mise.toml" | cut -c1-64) - if report "e2e lock" "$(sed -n '1s/^# devvm e2e: shared-tools\/mise.toml sha256:\(.\{12\}\).*/\1/p' "$root/$f" 2>/dev/null)" "${sum:0:12}"; then + if report "e2e lock" "$(sed -n '1s/^# devvm e2e: shared-tools\/mise.toml sha256:\(.\{12\}\).*/\1/p' "$root/$f" 2>/dev/null)" "${sum:0:12}" checksum; then want=true fi $want || return 0 @@ -358,14 +549,14 @@ bump_e2e-tools() { e2e_lock=$tmp/e2e-mise.lock } -# hub_index REPO TAG FILE: Docker Hub's index (manifest list) of library/REPO:TAG into FILE, as the -# registry sent it, so its SHA-256 is its digest. The anonymous pull token goes to curl as a header -# it reads from a file, never in a process's arguments. +# hub_index REPO TAG FILE: Docker Hub's index (manifest list) of REPO:TAG (library/node for node) into +# FILE, as the registry sent it, so its SHA-256 is its digest. The anonymous pull token goes to curl +# as a header it reads from a file, never in a process's arguments. hub_index() { printf 'Authorization: Bearer %s\n' \ - "$(fetch "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/$1:pull" | jq -r .token)" > "$tmp/hub-auth" + "$(fetch "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$1:pull" | jq -r .token)" > "$tmp/hub-auth" fetch -H @"$tmp/hub-auth" -H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json' \ - "https://registry-1.docker.io/v2/library/$1/manifests/$2" > "$3" + "https://registry-1.docker.io/v2/$1/manifests/$2" > "$3" jq -e '.manifests | length > 0' "$3" >/dev/null || { echo "bump: Docker Hub sent no index for $1:$2" >&2; exit 1; } } @@ -375,21 +566,272 @@ bump_e2e-from() { local f=tests/e2e/from_test.go p ref var new for p in node:24=fromNodeDigest alpine:3=fromAlpineDigest ubuntu:26.04=fromUbuntuDigest; do ref=${p%%=*} var=${p#*=} - hub_index "${ref%%:*}" "${ref#*:}" "$tmp/e2e-from-index" + hub_index "library/${ref%%:*}" "${ref#*:}" "$tmp/e2e-from-index" new=sha256:$(shasum -a 256 "$tmp/e2e-from-index" | cut -c1-64) - if report "$ref" "$(get_const $f "$var" | cut -c8-19)" "${new:7:12}"; then set_var $f "$var" "$new"; fi + if report "$ref" "$(get_const $f "$var" | cut -c8-19)" "${new:7:12}" digest; then set_var $f "$var" "$new"; fi done } -for t in $tools; do "bump_$t"; done +# The curl image e2e's network checks run in containers (tests/e2e/transparent_test.go's curlImage): +# curlimages/curl's newest release tag, by its index's digest. +bump_e2e-curl() { + local f=tests/e2e/transparent_test.go repo=curlimages/curl cur new + cur=$(get_const $f curlImage); cur=${cur#"$repo":}; cur=${cur%%@*} + new=$(fetch "https://hub.docker.com/v2/repositories/$repo/tags?page_size=100&ordering=last_updated" | jq -r '.results[].name' | newest_of) + report e2e-curl "$cur" "$new" || return 0 + valid curl_version "$new" + hub_index "$repo" "$new" "$tmp/e2e-curl-index" + set_var $f curlImage "$repo:$new@sha256:$(shasum -a 256 "$tmp/e2e-curl-index" | cut -c1-64)" +} + +# Cursor's CLI, the one shared tool pinned for users (assets/shared-tools/mise.toml): the release +# Cursor's install script fetches, with each platform's SHA-256 computed from its download, as Cursor +# publishes none. Only when named: devvm's login and proxy code was read against the pinned release. +bump_cursor() { + local f=assets/shared-tools/mise.toml cur new p old sum u + cur=$(sed -n 's/^cursor = { version = "\([^"]*\)".*/\1/p' "$root/$f") + new=$(fetch https://cursor.com/install | + sed -n 's|^DOWNLOAD_URL="https://downloads\.cursor\.com/lab/\([0-9A-Za-z.-]*\)/\${OS}/\${ARCH}/agent-cli-package\.tar\.gz"$|\1|p' | head -1) + [[ -n $new ]] || { echo "bump: cursor.com/install names no package: see assets/shared-tools/mise.toml's cursor" >&2; exit 1; } + report cursor "$cur" "$new" release || return 0 + valid cursor_version "$new" + echo " (checksums computed from the downloads)" + for p in x64 arm64; do + old=$(grep '^cursor = ' "$root/$f" | grep -o "linux-$p = { url = \"[^\"]*\", checksum = \"sha256:[0-9a-f]*\"" | sed 's/.*sha256://; s/"$//') + u="https://downloads.cursor.com/lab/$new/linux/$p/agent-cli-package.tar.gz" + sum=$(sha_of "$u"); valid cursor_sha256 "$sum" + set_text $f text "sha256:$old" "sha256:$sum" + done + set_text $f text "$cur" "$new" + notes+=("cursor: read the new CLI where devvm's code names its release (internal/agentlogin/cursor.go, internal/proxy/cursor.go, internal/agents/agents.go), then run scripts/bump.sh e2e-tools") +} + +# go_releases: Go's stable releases, oldest first. +go_releases() { + [[ -s $tmp/go.json ]] || fetch 'https://go.dev/dl/?mode=json&include=all' > "$tmp/go.json" + jq -r '.[] | select(.stable) | .version | ltrimstr("go")' "$tmp/go.json" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V +} +# go_to NAME NEW: move Go to NEW: go.mod's and docs/go.mod's go lines, mise.toml's go, then mise.lock. +go_to() { + local cur + cur=$(sed -n 's/^go \([0-9.]*\)$/\1/p' "$root/go.mod") + report "$1" "$cur" "$2" || return 0 + valid go_version "$2" + set_text go.mod line "go $cur" "go $2" + set_text docs/go.mod line "go $(sed -n 's/^go \([0-9.]*\)$/\1/p' "$root/docs/go.mod")" "go $2" + set_text mise.toml line "go = \"$(mise_spec go)\"" "go = \"$2\"" + mise_locks+=(go) +} +# Go's newest patch release of go.mod's minor. +bump_go() { + # go-minor in the same run moves the same lines. + if [[ " $tools " == *" go-minor "* ]] && ! $check; then return 0; fi + local cur + cur=$(sed -n 's/^go \([0-9.]*\)$/\1/p' "$root/go.mod") + go_to go "$(go_releases | awk -v m="${cur%.*}." 'index($0, m) == 1' | tail -1)" +} +# Go's newest minor release, only when named. +bump_go-minor() { + local cur new + cur=$(sed -n 's/^go \([0-9.]*\)$/\1/p' "$root/go.mod") + new=$(go_releases | awk -F. -v m="${cur%%.*}" '$1 == m' | tail -1) + # No newer minor: go reports the patches. + [[ ${new%.*} != "${cur%.*}" ]] || new=$cur + go_to go-minor "$new" +} + +# mod_versions MODULE: the Go module proxy's release versions of MODULE, none for a module it hasn't. +mod_versions() { + valid go_module "$1" + # The proxy's escaped path: !a for each capital A. + fetch "https://proxy.golang.org/$(awk '{ for (i = 1; i <= length($0); i++) { c = substr($0, i, 1) + printf "%s", (c ~ /[A-Z]/ ? "!" tolower(c) : c) } }' <<<"$1")/@v/list" 2>/dev/null | + grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true +} +# mod_bump NAME MODULE CURRENT: choose MODULE's newest release within its path's major, under any hold, +# and report the next major's path when the proxy has one. Sets target. +mod_bump() { + local list newest within major base next b + list=$(mod_versions "$2") + newest=$(newest_of <<<"$list") + within=$newest + if b=$(held "$2" "$newest"); then + within=$(awk -v b="$b" '{ print } END { print b }' <<<"$list" | sed 's/^v\(.*\)/\1 v/' | sort -V | + awk -v b="${b#v}" '$1 == b { exit } { print $2 $1 }' | tail -1) + fi + choose "$1" "$3" "${newest:-$3}" "$within" || true + major=${3#v}; major=${major%%.*}; (( major >= 1 )) || major=1 + base=$2 + [[ ! $2 =~ /v[0-9]+$ ]] || base=${2%/v*} + next="$base/v$((major + 1))" + newest=$(mod_versions "$next" | newest_of) + if [[ -n $newest ]]; then printf ' %-9s %-14s -> %s %s (major, a new path: by hand)\n' "$1" "$3" "$next" "$newest"; fi + [[ -n $target ]] +} + +# go.mod's direct modules: the depguard allowlist's and the tests'. +bump_go-mods() { + local mod cur + while read -r mod cur; do + if mod_bump "$mod" "$mod" "$cur"; then + valid go_version "$target" + go_gets+=("$mod@$target") + fi + done < <(awk '/^require \(/ { r = 1; next } r && /^\)/ { r = 0 } r && !/\/\/ indirect/ && NF >= 2 { print $1, $2 } + /^require [^(]/ && !/\/\/ indirect/ { print $2, $3 }' "$root/go.mod") +} + +# mise.toml's deadcode task: golang.org/x/tools' newest release. +bump_deadcode() { + local cur + cur=$(sed -n 's|.*golang\.org/x/tools/cmd/deadcode@\(v[0-9.]*\) .*|\1|p' "$root/mise.toml") + mod_bump deadcode golang.org/x/tools "$cur" || return 0 + valid deadcode_version "$target" + set_text mise.toml text "golang.org/x/tools/cmd/deadcode@$cur " "golang.org/x/tools/cmd/deadcode@$target " +} + +# The docs site's theme, docs/go.mod's Hextra, through go get and hugo mod tidy in docs/ (go mod tidy +# there would drop it: the module has no Go code). +bump_hextra() { + local mod=github.com/imfing/hextra cur + cur=$(awk -v m="$mod" '$1 == m { print $2 } $1 == "require" && $2 == m { print $3 }' "$root/docs/go.mod") + mod_bump hextra "$mod" "$cur" || return 0 + valid hextra_version "$target" + docs_gets+=("$mod@$target") + notes+=("hextra: compare docs/layouts' copies of Hextra's files (the hero button, Mermaid's partial) with $target's, and build the site: mise run docs") +} + +# docs/hugo.yaml's Mermaid, npm's newest, only when named: its diagrams need a look. +bump_mermaid() { + local cur new + cur=$(sed -n 's|.*/npm/mermaid@\([0-9.]*\)/.*|\1|p' "$root/docs/hugo.yaml") + new=$(fetch https://registry.npmjs.org/mermaid/latest | jq -r .version) + report mermaid "$cur" "$new" || return 0 + valid mermaid_version "$new" + set_text docs/hugo.yaml text "/npm/mermaid@$cur/" "/npm/mermaid@$new/" + notes+=("mermaid: look at the diagrams on the docs site (mise run docs) before committing") +} + +# mise_spec TOOL: mise.toml's version for TOOL in [tools], an inline table's version included. +mise_spec() { + mise_tools | awk -F'\t' -v t="$1" '$1 == t { print $2 }' +} +# mise_tools: mise.toml's [tools], a TOOLVERSION line each. +mise_tools() { + awk '/^\[tools\]/ { s = 1; next } /^\[/ { s = 0 } + s && /^[^#]/ && / = / { k = $1; gsub(/"/, "", k) + if (match($0, /version = "[^"]*"/)) v = substr($0, RSTART + 11, RLENGTH - 12); else { v = $3; gsub(/"/, "", v) } + print k "\t" v }' "$root/mise.toml" +} + +# mise.toml's dev tools, go aside (bump_go): mise's newest of each, a major or a held one only +# reported, then mise lock, so mise.lock keeps their checksums. +bump_dev-tools() { + need mise + local key spec newest within line + while IFS=$'\t' read -r key spec; do + [[ $key != go ]] || continue + newest=$(mise latest "$key" 2>/dev/null) || { echo "bump: mise latest $key failed" >&2; exit 1; } + within=$(mise latest "$key@${spec%%.*}" 2>/dev/null) || within="" + choose "$key" "$spec" "$newest" "$within" || continue + valid "${key##*/}_version" "$target" + line=$(K=$key awk '/^\[tools\]/ { s = 1; next } /^\[/ { s = 0 } { k = $1; gsub(/"/, "", k) } + s && k == ENVIRON["K"] && / = / { print; exit }' "$root/mise.toml") + set_text mise.toml line "$line" "$(O="\"$spec\"" V="\"$target\"" awk '{ i = index($0, ENVIRON["O"]) + print substr($0, 1, i - 1) ENVIRON["V"] substr($0, i + length(ENVIRON["O"])) }' <<<"$line")" + mise_locks+=("$key") + done < <(mise_tools) +} + +# The mise the workflows install (jdx/mise-action's version input): base's mise, as this run leaves it. +bump_ci-mise() { + local f cur want + want=$(staged_value assets/layers/base.sh mise_version) + while read -r cur; do + report ci-mise "$cur" "$want" || continue + for f in "$root"/.github/workflows/*.yml; do set_text "${f#"$root"/}" text "version: $cur" "version: $want"; done + workflows_changed=true + done < <(grep -h -A4 'uses: jdx/mise-action@' "$root"/.github/workflows/*.yml | sed -n 's/^ *version: \([^ ]*\)$/\1/p' | sort -u) +} + +# Every workflow's uses:, pinned by a release's tag's commit with the tag as a comment: moved to the +# newest release's (within its major, the next major only reported), the commit from gh api. +bump_actions() { + need gh + local repo sha tag newest within f new + while read -r repo sha tag; do + gh api "repos/$repo/releases?per_page=100" --jq '.[] | select((.draft or .prerelease) | not) | .tag_name' > "$tmp/tags" + newest=$(newest_of < "$tmp/tags") + within=$(newest_of "$(sed 's/^v//; s/\..*//' <<<"$tag")" < "$tmp/tags") + choose "$repo" "$tag" "${newest:-$tag}" "$within" || continue + valid action_version "$target" + new=$(gh api "repos/$repo/commits/$target" --jq .sha) + valid action_commit "$new" + for f in "$root"/.github/workflows/*.yml; do + set_text "${f#"$root"/}" text "uses: $repo@$sha # $tag" "uses: $repo@$new # $target" + done + workflows_changed=true + done < <(sed -n 's/^ *\(- \)\{0,1\}uses: \([^@ ]*\)@\([0-9a-f]\{40\}\) # \([^ ]*\)$/\2 \3 \4/p' "$root"/.github/workflows/*.yml | sort -u) +} + +mise_locks=() go_gets=() docs_gets=() workflows_changed=false +# run_logged STEP CMD...: run CMD in the repo, its output shown only when it fails. +run_logged() { + local step=$1 + shift + echo "==> $step" + (cd "$root" && "$@") >"$tmp/step.log" 2>&1 || + { cat "$tmp/step.log" >&2; echo "bump: $step failed; the pins above are already edited" >&2; exit 1; } +} + +group="" +for cur_tool in $tools; do + case $cur_tool in + cursor) g=shared-tools ;; + e2e-*) g=e2e ;; + go | go-minor | go-mods | deadcode) g=go ;; + dev-tools) g=dev-tools ;; + ci-mise | actions) g=ci ;; + hextra | mermaid) g=docs ;; + *) g=images ;; + esac + [[ $g == "$group" ]] || { group=$g; echo "[$g]"; } + # Majors: e2e-tools takes them (assets/shared-tools/mise.toml holds what's held), a named images + # or e2e tool too, and a tool applied only when named, when it is. + majors_ok=false only_named=false + if [[ $cur_tool == e2e-tools ]] || { $named && [[ " $legacy $named_only " == *" $cur_tool "* && $cur_tool != go-minor ]]; }; then + majors_ok=true + fi + if ! $named && [[ " $named_only " == *" $cur_tool "* ]]; then only_named=true; fi + "bump_$cur_tool" +done write_staged [[ -z $e2e_lock ]] || cat "$e2e_lock" > "$root/tests/e2e-mise.lock" - $check && exit 0 + +if (( ${#mise_locks[@]} > 0 )); then need mise; run_logged "mise lock ${mise_locks[*]}" mise lock "${mise_locks[@]}"; fi +if (( ${#go_gets[@]} > 0 )); then + need go + run_logged "go get ${go_gets[*]}" go get "${go_gets[@]}" + run_logged "go mod tidy" go mod tidy +fi +if (( ${#docs_gets[@]} > 0 )); then + need go; need mise + run_logged "go get ${docs_gets[*]} (docs)" sh -c 'cd docs && exec go get "$@"' sh "${docs_gets[@]}" + # go.sum keeps the old version's lines; Hugo's tidy, not Go's, which would drop the module. + run_logged "hugo mod tidy (docs)" sh -c 'cd docs && exec mise exec -- hugo mod tidy' +fi +if $workflows_changed; then + need mise + run_logged actionlint mise exec -- actionlint + run_logged "zizmor --offline ." mise exec -- zizmor --offline . +fi + if (( ${#summary[@]} == 0 )); then echo "==> everything is up to date"; exit 0; fi echo echo "Bump pinned versions" echo printf -- '- %s\n' "${summary[@]}" echo +(( ${#notes[@]} == 0 )) || { printf -- '==> %s\n' "${notes[@]}"; echo; } echo "==> the edited images and tools rebuild on next use. Test: devvm build ; then devvm gc" diff --git a/testdata/script/bump.txtar b/testdata/script/bump.txtar index a0b15dfb..af254e2c 100644 --- a/testdata/script/bump.txtar +++ b/testdata/script/bump.txtar @@ -1,13 +1,19 @@ # scripts/bump.sh, on a scratch copy of the files it edits, with upstream -# answered by a curl that reads $WORK/up/ (repo.sh). +# answered by a curl that reads $WORK/up/ (repo.sh), and mise, go and gh +# stubs that answer from there too and log their calls. [!exec:jq] skip env PATH=$WORK/bin:$PATH chmod 755 bin/curl +chmod 755 bin/mise +chmod 755 bin/go +chmod 755 bin/gh exec bash repo.sh -# crane's version and checksums are written as they are. +# crane's version and checksums are written as they are: a named images +# tool takes its major. exec repo/scripts/bump.sh crane -stdout '^ crane +0\.22\.1 +-> 9\.9\.9$' +stdout '^\[images\]$' +stdout '^ crane +0\.22\.1 +-> 9\.9\.9 \(major\)$' stdout '^- crane: 0\.22\.1 -> 9\.9\.9$' exec grep '^crane_' repo/assets/oci/build.sh cmp stdout crane.want @@ -22,7 +28,7 @@ cmp stdout mise-go.want # e2e-ubuntu moves the cloud image release e2e pins to the newest Ubuntu # lists; with none listed, nothing is edited. exec repo/scripts/bump.sh e2e-ubuntu -stdout '^ e2e-ubuntu +release-[0-9]{8} +-> release-29990101$' +stdout '^ e2e-ubuntu +release-[0-9]{8} +-> release-29990101 \(release\)$' exec grep '^const e2eUbuntuRelease = ' repo/tests/e2e/sandbox_test.go stdout '^const e2eUbuntuRelease = "release-29990101"$' exec bash repo.sh @@ -36,7 +42,7 @@ cmp repo/tests/e2e/sandbox_test.go e2e.before # tarball's checksum, from a SHA256SUMS that matches the release notes' # sha256; one that doesn't is refused, and nothing is edited. exec repo/scripts/bump.sh e2e-lima -stdout '^ e2e-lima +[0-9.]+ +-> 9\.8\.7$' +stdout '^ e2e-lima +[0-9.]+ +-> 9\.8\.7 \(major\)$' exec grep -E '^ LIMA_(VERSION|SHA256):' repo/.github/workflows/e2e.yml cmp stdout lima.want exec bash repo.sh @@ -56,9 +62,13 @@ cp sums-hostile up/crane-sums stderr '^bump: upstream gave crane_sha256_arm64 an unexpected value: ' cmp repo/assets/oci/build.sh before cp sums-good up/crane-sums +# A hostile version is refused before any URL is built from it: crane's +# checksums are never fetched. +rm curl.calls cp latest-hostile up/crane-latest ! exec repo/scripts/bump.sh crane stderr '^bump: upstream gave crane_version an unexpected value: ' +! grep 'checksums\.txt' curl.calls cmp repo/assets/oci/build.sh before cp latest-good up/crane-latest cp sums-missing up/crane-sums @@ -75,10 +85,24 @@ stderr '^bump: upstream gave mise_sha256 an unexpected value: ' cmp repo/internal/tools/mise.go mise.go.before ! exists pwned +# mise's version, hostile: refused before its SHASUMS256.txt's URL, with +# neither file edited. +cp mise-sums up/mise-sums +cp repo/assets/layers/base.sh base.before +cp mise-latest-hostile up/mise-latest +rm curl.calls +! exec repo/scripts/bump.sh mise +stderr '^bump: upstream gave mise_version an unexpected value: ' +! grep 'SHASUMS256' curl.calls +cmp repo/assets/layers/base.sh base.before +cmp repo/internal/tools/mise.go mise.go.before +! exists pwned +cp mise-latest up/mise-latest + # --check prints upstream's version without control characters. cp latest-escape up/crane-latest exec repo/scripts/bump.sh --check crane -stdout ' -> 9\.9\.9\[2J$' +stdout ' -> 9\.9\.9\[2J \(change\)$' ! stdout '\x1b' cmp repo/assets/oci/build.sh before @@ -94,13 +118,80 @@ cmp repo/assets/oci/build.sh before ! exec repo/scripts/bump.sh nope stderr '^bump: unknown tool ''nope''' +# go moves Go to its minor's newest patch, and go-minor to the newest minor. +exec bash repo.sh +exec repo/scripts/bump.sh --check go go-minor +stdout '^\[go\]$' +stdout '^ go +1\.27\.4 +-> 1\.27\.9 \(patch\)$' +stdout '^ go-minor +1\.27\.4 +-> 1\.28\.2 \(minor\)$' +cmp repo/go.mod go.mod.fixture +exec repo/scripts/bump.sh go +grep '^go 1\.27\.9$' repo/go.mod +grep '^go 1\.27\.9$' repo/docs/go.mod +grep '^go = "1\.27\.9"$' repo/mise.toml +grep '^mise lock go$' mise.calls +exec bash repo.sh +exec repo/scripts/bump.sh go-minor +grep '^go 1\.28\.2$' repo/go.mod + +# go-mods: a direct module's minor through go get and go mod tidy, its next +# major's path only reported, and pflag held by Dependabot's ignore list. +exec bash repo.sh +exec repo/scripts/bump.sh go-mods +stdout '^ github\.com/spf13/cobra v1\.10\.2 +-> v1\.11\.0 \(minor\)$' +stdout '^ github\.com/spf13/cobra v1\.10\.2 +-> github\.com/spf13/cobra/v2 v2\.0\.1 \(major, a new path: by hand\)$' +stdout '^ github\.com/spf13/pflag v1\.0\.10 +held below 1\.1\.0 \(newest v1\.1\.0\)$' +! stdout 'golang\.org/x/tools' +grep '^go get github\.com/spf13/cobra@v1\.11\.0$' go.calls +grep '^go mod tidy$' go.calls + +# deadcode and hextra take the module proxy's newest; hextra's go.sum is +# tidied by Hugo, in docs/. +exec repo/scripts/bump.sh deadcode hextra +grep 'deadcode@v0\.999\.0 ' repo/mise.toml +grep '^go get github\.com/imfing/hextra@v0\.999\.0$' go.calls +grep '^mise exec -- hugo mod tidy$' mise.calls + +# dev-tools: a minor through mise lock, Node held on its major. +exec bash repo.sh +exec repo/scripts/bump.sh dev-tools +stdout '^ vale +[0-9.]+ +-> 3\.999\.0 \(minor\)$' +stdout '^ node +[0-9.]+ +held below 25 \(newest 999\.0\.0\)$' +grep '^vale = "3\.999\.0"$' repo/mise.toml +grep '^mise lock vale$' mise.calls + +# actions: the newest within the major, by its tag's commit, the next major +# only reported, then actionlint and zizmor. +exec bash repo.sh +exec repo/scripts/bump.sh actions +stdout '^ actions/checkout v[0-9.]+ +-> v999\.0\.0 \(major, not applied: by hand\)$' +stdout '^ actions/checkout v[0-9.]+ +-> v[0-9]\.999\.0 \(minor\)$' +grep 'uses: actions/checkout@cccccccccccccccccccccccccccccccccccccccc # v[0-9]\.999\.0$' repo/.github/workflows/e2e.yml +! grep 'checkout@[0-9a-f]* # v999' repo/.github/workflows/e2e.yml +grep '^mise exec -- actionlint$' mise.calls +grep '^mise exec -- zizmor --offline \.$' mise.calls + +# mermaid, only when named, takes its major too. +exec repo/scripts/bump.sh mermaid +grep '/npm/mermaid@99\.0\.0/' repo/docs/hugo.yaml + -- repo.sh -- # A copy of the files bump.sh edits, and upstream's good answers. set -eu -rm -rf repo up -mkdir -p repo/scripts repo/assets/oci repo/assets/layers repo/internal/tools repo/tests/e2e repo/.github/workflows up +rm -rf repo up mise.calls go.calls +mkdir -p repo/scripts repo/assets/oci repo/assets/layers repo/internal/tools repo/tests/e2e repo/.github/workflows repo/docs up cp "$DEVVM_REPO/scripts/bump.sh" repo/scripts/ -cp "$DEVVM_REPO/.github/workflows/e2e.yml" repo/.github/workflows/ +cp "$DEVVM_REPO"/.github/workflows/*.yml repo/.github/workflows/ +cp "$DEVVM_REPO/.github/dependabot.yml" repo/.github/ +cp "$DEVVM_REPO/mise.toml" repo/ +cp "$DEVVM_REPO/docs/hugo.yaml" repo/docs/ +cp go.mod.fixture repo/go.mod +cp docs-go.mod.fixture repo/docs/go.mod +mkdir up/latest +echo 3.999.0 > up/latest/vale +echo 999.0.0 > up/latest/node +echo 0.12 > up/latest/minisign +echo 0.12 > up/latest/minisign_0 cp lima-latest up/lima-latest cp lima-sums up/lima-sums cp "$DEVVM_REPO/assets/oci/build.sh" repo/assets/oci/ @@ -116,6 +207,8 @@ cp cloud-listing up/cloud-listing #!/bin/bash # Answers crane's, mise's and Lima's releases and Ubuntu's list of cloud # image releases from $WORK/up/, to stdout or -o's file; anything else fails. +# Every call goes in $WORK/curl.calls. +echo "curl $*" >> "$WORK/curl.calls" out=/dev/stdout for a in "$@"; do [[ ${o:-} == next ]] && { out=$a; o=; }; [[ $a == -o ]] && o=next; done exec >"$out" @@ -127,8 +220,57 @@ for a in "$@"; do case $a in */jdx/mise/releases/latest) cat "$WORK/up/mise-latest"; exit ;; */jdx/mise/*/SHASUMS256.txt) cat "$WORK/up/mise-sums"; exit ;; https://cloud-images.ubuntu.com/releases/resolute/) cat "$WORK/up/cloud-listing"; exit ;; + 'https://go.dev/dl/?mode=json&include=all') cat "$WORK/go-releases"; exit ;; + https://proxy.golang.org/github.com/spf13/cobra/@v/list) printf 'v1.10.2\nv1.11.0\nv1.12.0-rc.1\n'; exit ;; + https://proxy.golang.org/github.com/spf13/cobra/v2/@v/list) printf 'v2.0.1\n'; exit ;; + https://proxy.golang.org/github.com/spf13/pflag/@v/list) printf 'v1.0.10\nv1.1.0\n'; exit ;; + https://proxy.golang.org/golang.org/x/tools/@v/list) printf 'v0.52.0\nv0.999.0\n'; exit ;; + https://proxy.golang.org/github.com/imfing/hextra/@v/list) printf 'v0.13.0\nv0.999.0\n'; exit ;; + https://registry.npmjs.org/mermaid/latest) echo '{"version":"99.0.0"}'; exit ;; esac; done exit 22 +-- bin/mise -- +#!/bin/bash +# mise latest from $WORK/up/latest/, else mise.toml's own version; lock and +# exec succeed. Every call goes in $WORK/mise.calls. +echo "mise $*" >> "$WORK/mise.calls" +case $1 in + latest) + f=$WORK/up/latest/${2//[@\/:]/_} + if [[ -f $f ]]; then cat "$f"; exit; fi + awk -F' = ' -v k="${2%@*}" '{ g = $1; gsub(/"/, "", g) } g == k { v = $2; gsub(/"/, "", v); print v; exit }' "$WORK/repo/mise.toml" ;; + lock | exec) ;; + *) exit 1 ;; +esac +-- bin/go -- +#!/bin/bash +echo "go $*" >> "$WORK/go.calls" +-- bin/gh -- +#!/bin/bash +# actions/checkout's releases and any tag's commit; no releases for the rest. +case $2 in + repos/actions/checkout/releases*) printf 'v7.999.0\nv8.999.0\nv9.999.0\nv999.0.0\n' ;; + repos/*/commits/*) echo cccccccccccccccccccccccccccccccccccccccc ;; +esac +-- go-releases -- +[{"version":"go1.29rc1","stable":false},{"version":"go1.28.2","stable":true},{"version":"go1.28.1","stable":true},{"version":"go1.27.9","stable":true},{"version":"go1.27.4","stable":true}] +-- go.mod.fixture -- +module example.com/m + +go 1.27.4 + +require ( + github.com/spf13/cobra v1.10.2 + github.com/spf13/pflag v1.0.10 +) + +require golang.org/x/tools v0.52.0 // indirect +-- docs-go.mod.fixture -- +module example.com/m/docs + +go 1.27.4 + +require github.com/imfing/hextra v0.13.0 // indirect -- lima-latest -- {"tag_name":"v9.8.7","body":"The sha256sum of the SHA256SUMS file itself is `58af05498b64199f1e9de8d1bc11ea71e397df7c0ece4f313dd7c4e44b9497b1` ."} -- lima-sums -- @@ -168,6 +310,8 @@ crane_sha256_arm64=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa crane_sha256_amd64=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -- mise-latest -- {"tag_name":"v2099.1.1"} +-- mise-latest-hostile -- +{"tag_name":"v1.2.3;touch${IFS}pwned"} -- mise-sums -- 1111111111111111111111111111111111111111111111111111111111111111 mise-v2099.1.1-linux-arm64 2222222222222222222222222222222222222222222222222222222222222222 mise-v2099.1.1-linux-x64