diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b9a8daf9..eca89e577 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -158,6 +158,20 @@ $ uv run scripts/build-tmux-matrix/build_tmux_matrix.py ~/tmux-builds It reads the lane list from `gradle/tmux-lanes.json`, so it cannot drift from what the matrix runs. +You can also install local matrix versions (`3.0a` onward, `preview`, or git +refs) on Linux and macOS with +[`libtmux/mise-tmux`](https://github.com/libtmux/mise-tmux) (`v0.1.0`), which +writes the same `/bin/tmux` layout under +`"${MISE_DATA_DIR:-$HOME/.local/share/mise}/installs/tmux"`: + +```console +$ mise plugins install tmux https://github.com/libtmux/mise-tmux +``` + +```console +$ mise install tmux@3.3a tmux@3.8 +``` + ## Checks that must pass One command has to pass before anything is proposed: @@ -412,26 +426,25 @@ $ uv run scripts/ci-plan/ci_plan.py matrix \ ### Native tmux in CI -Each lane builds the tmux it is named after with the -[`build-tmux`](https://github.com/libtmux/.github/tree/30f81842b1e639ea4e25f93f1f2543504178e228/actions/build-tmux) -action of `libtmux/.github`, pinned to a full commit, into `~/tmux-builds/`. -A release uses the official archive and the SHA256 pin in the action's -`tmux-releases.json`, and the action refuses a release with none, so a new one -is pinned there first. Any other ref resolves once to a commit, and the build -fetches that exact commit. Only the installed prefix is cached. - -The cache key includes the runner image and its version, the architecture, the -compiler, the versions of the build packages, the source identity and the -action's build script. Every restored executable must match its recorded hash -and version, start a private daemon, and report the same connected version. A -failed check discards that job's prefix and rebuilds it, and the workflow saves -a validated installation before the suite runs. GitHub caches are immutable, so -a repaired exact hit fixes the current job only, and a change to the build -script is what invalidates the key for later jobs. Never add a broad restore-key -fallback for native binaries. The action's README has the rest. +Each lane installs the tmux it is named after with +[`libtmux/setup-tmux`](https://github.com/libtmux/setup-tmux) (`v0.1.0`), +pinned to a full commit, into `~/tmux-builds/`. Releases `3.6a` onward +(except `3.7`) use verified prebuilt archives; older releases and `3.7` build +from checksum-pinned source tarballs in `releases.json` with bundled static +`libevent`. Any other ref resolves once to a 40-hex commit SHA. Custom prefixes +stay off `PATH` on daemon/client lanes via `add-to-path: false`, and only the +installed prefix is cached. + +Source caches key on OS ABI, architecture, source identity, configure arguments, +patches, and a prefix hash rather than weekly runner image rollouts. Every +restored executable must match its recorded hash and version, start a private +daemon, and report the same connected version. A failed check discards that +job's prefix and reinstalls it, and the action saves a validated installation +before the suite runs. Never add a broad restore-key fallback for native +binaries. The action's README has the rest. Every `apt-get` call goes through the [`apt-get`](https://github.com/libtmux/.github/tree/30f81842b1e639ea4e25f93f1f2543504178e228/actions/apt-get) -action of the same repository, which retries on another mirror when one hangs. +action of `libtmux/.github`, which retries on another mirror when one hangs. [`scripts/ci-check`](../scripts/ci-check/README.md) fails when the README, this page or the workflows disagree with `gradle/tmux-lanes.json`. Each dispatch is diff --git a/.github/workflows/clojure-compatibility.yml b/.github/workflows/clojure-compatibility.yml index 5ce5b2d88..9b9e5a1ed 100644 --- a/.github/workflows/clojure-compatibility.yml +++ b/.github/workflows/clojure-compatibility.yml @@ -78,9 +78,9 @@ jobs: enable-cache: false - name: Build tmux ${{ matrix.tmux }} - uses: libtmux/.github/actions/build-tmux@30f81842b1e639ea4e25f93f1f2543504178e228 + uses: libtmux/setup-tmux@96c8f0d575eae62d1c3419ef919b69ecc43f3cac # v0.1.0 with: - ref: ${{ matrix.tmux }} + version: ${{ matrix.tmux }} prefix: ~/tmux-builds/${{ matrix.tmux }} add-to-path: "true" diff --git a/.github/workflows/tmux-matrix.yml b/.github/workflows/tmux-matrix.yml index 257bf65ec..60637ed1b 100644 --- a/.github/workflows/tmux-matrix.yml +++ b/.github/workflows/tmux-matrix.yml @@ -118,22 +118,24 @@ jobs: version: '0.12.0' enable-cache: false - # A release is pinned by checksum in the action; any other ref is resolved to the commit it - # names. The action keys its cache on the runner image, so a build made on one image is not - # restored onto another, and it rebuilds a restore that fails to start. + # A release uses a verified prebuilt archive or checksum-pinned source tarball from + # libtmux/setup-tmux; any other ref resolves to a 40-hex commit SHA. Custom prefixes stay + # off PATH so daemon and client builds remain isolated. - name: Build tmux ${{ matrix.tmux }} - uses: libtmux/.github/actions/build-tmux@30f81842b1e639ea4e25f93f1f2543504178e228 + uses: libtmux/setup-tmux@96c8f0d575eae62d1c3419ef919b69ecc43f3cac # v0.1.0 with: - ref: ${{ matrix.tmux }} + version: ${{ matrix.tmux }} prefix: ~/tmux-builds/${{ matrix.slug }} + add-to-path: false # The daemon of a 3.0a or 3.1c lane is reached by this client. - name: Build tmux ${{ matrix.client }} for the client if: matrix.client - uses: libtmux/.github/actions/build-tmux@30f81842b1e639ea4e25f93f1f2543504178e228 + uses: libtmux/setup-tmux@96c8f0d575eae62d1c3419ef919b69ecc43f3cac # v0.1.0 with: - ref: ${{ matrix.client }} + version: ${{ matrix.client }} prefix: ~/tmux-builds/${{ matrix.client }} + add-to-path: false - name: The lane runs the tmux it is named after env: diff --git a/scripts/build-tmux-matrix/README.md b/scripts/build-tmux-matrix/README.md index 565ea8056..287aa3818 100644 --- a/scripts/build-tmux-matrix/README.md +++ b/scripts/build-tmux-matrix/README.md @@ -15,15 +15,14 @@ source archive from [tmux/tmux](https://github.com/tmux/tmux/releases), runs `./configure --prefix=/`, `make` and `make install`, and prints the version of each result. A release that is already built is kept. -Before it builds, it checks each archive against the SHA256 that the -[`build-tmux` action](https://github.com/libtmux/.github/tree/main/actions/build-tmux) -of `libtmux/.github` pins for that release, read at the commit that -`tmux-matrix.yml` pins, so a build here starts from the bytes CI starts from. It -reads that file over the network, and refuses an archive that differs or a -release the action does not pin. It does not call the action: that is a runner -step, which reads `RUNNER_TEMP`, writes `GITHUB_OUTPUT` and installs packages -with apt. A download or build step that stops making progress ends the run -with the step named. +Before it builds, it checks each archive against the tarball SHA256 that +[`libtmux/setup-tmux`](https://github.com/libtmux/setup-tmux) pins in +`releases.json`, read at the commit that `tmux-matrix.yml` pins, so a build +here starts from the bytes CI starts from. It reads that file over the network, +and refuses an archive that differs or a release the action does not pin. It +does not call the action: that is a runner step, which reads `RUNNER_TEMP`, +writes `GITHUB_OUTPUT` and manages CI caches. A download or build step that +stops making progress ends the run with the step named. The previews, `master` and the development builds, are not built here. CI builds them from a commit, and `gh workflow run tmux-matrix.yml` runs any ref @@ -31,8 +30,7 @@ them from a commit, and `gh workflow run tmux-matrix.yml` runs any ref `--only RELEASE` builds one release of the manifest. The macOS lanes of `clojure-compatibility.yml` run it that way, with Homebrew's libevent, ncurses and -jemalloc found through pkg-config and `--disable-utf8proc`, because the shared -`build-tmux` action installs its packages with apt and runs on Linux. +jemalloc found through pkg-config and `--disable-utf8proc`. Building needs a C compiler, `make`, `libevent` and `ncurses` headers, and `yacc` or `bison`. Then run the matrix: diff --git a/scripts/build-tmux-matrix/build_tmux_matrix.py b/scripts/build-tmux-matrix/build_tmux_matrix.py index b44177569..03747b819 100755 --- a/scripts/build-tmux-matrix/build_tmux_matrix.py +++ b/scripts/build-tmux-matrix/build_tmux_matrix.py @@ -18,9 +18,9 @@ On macOS the build finds libevent, ncurses and jemalloc through Homebrew, and `--only RELEASE` builds one release, which is what a macOS lane does. -Each archive is checked against the SHA256 that the `build-tmux` action of -`libtmux/.github` pins for that release, read at the commit `tmux-matrix.yml` -pins, so a build here starts from the bytes CI starts from. +Each archive is checked against the SHA256 that `libtmux/setup-tmux` pins in +`releases.json`, read at the commit `tmux-matrix.yml` pins, so a build here +starts from the bytes CI starts from. """ import argparse @@ -46,11 +46,8 @@ MANIFEST = ROOT / "gradle/tmux-lanes.json" WORKFLOW = ROOT / ".github/workflows/tmux-matrix.yml" RELEASES = "https://github.com/tmux/tmux/releases/download" -DIGESTS = ( - "https://raw.githubusercontent.com/libtmux/.github/{commit}" - "/actions/build-tmux/tmux-releases.json" -) -SHARED_ACTION_PIN = re.compile(r"libtmux/\.github/actions/build-tmux@([0-9a-f]{40})") +DIGESTS = "https://raw.githubusercontent.com/libtmux/setup-tmux/{commit}/releases.json" +SHARED_ACTION_PIN = re.compile(r"libtmux/setup-tmux@([0-9a-f]{40})") DEFAULT_DESTINATION = Path("~/tmux-builds") # A stalled connection ends the download; the limit is per socket operation. DOWNLOAD_TIMEOUT_SECONDS = 60.0 @@ -100,34 +97,42 @@ def archive_url(base: str, release: str) -> str: def pinned_commit(workflow: Path) -> str: - """Return the commit of `libtmux/.github` that the workflow pins its tmux builds to. + """Return the commit of `libtmux/setup-tmux` that the workflow pins its tmux builds to. >>> import tempfile >>> with tempfile.TemporaryDirectory() as directory: ... path = Path(directory) / "w.yml" - ... _ = path.write_text("uses: libtmux/.github/actions/build-tmux@" + "a" * 40) + ... _ = path.write_text("uses: libtmux/setup-tmux@" + "a" * 40) ... pinned_commit(path) == "a" * 40 True """ found = SHARED_ACTION_PIN.search(workflow.read_text()) if found is None: - message = f"{workflow.name} does not pin the build-tmux action of libtmux/.github" + message = f"{workflow.name} does not pin libtmux/setup-tmux" raise DigestError(message) return found[1] def read_digests(url: str) -> dict[str, str]: - """Return each release's pinned SHA256 from the shared action's `tmux-releases.json`.""" + """Return each release's pinned tarball SHA256 from `libtmux/setup-tmux`'s `releases.json`.""" try: with urllib.request.urlopen(url, timeout=DOWNLOAD_TIMEOUT_SECONDS) as response: document = json.load(response) except (OSError, ValueError) as error: message = f"cannot read the pinned tmux digests from {url}: {error}" raise DigestError(message) from error - if not isinstance(document, dict): - message = f"{url} is not a table of release digests" + if not isinstance(document, dict) or not isinstance(document.get("releases"), list): + message = f"{url} is not a setup-tmux releases.json manifest" raise DigestError(message) - return {str(release): str(digest) for release, digest in document.items()} + digests: dict[str, str] = {} + for entry in document["releases"]: + if ( + isinstance(entry, dict) + and isinstance(entry.get("version"), str) + and isinstance(entry.get("tarball_sha256"), str) + ): + digests[entry["version"]] = entry["tarball_sha256"] + return digests def verify_archive(archive: Path, release: str, digests: dict[str, str]) -> None: @@ -269,7 +274,7 @@ def main(argv: list[str] | None = None) -> int: parser.add_argument("--base-url", default=RELEASES, help="where release archives are published") parser.add_argument( "--digests-url", - help="the tmux-releases.json to verify archives against " + help="the releases.json to verify archives against " "(default: the one at the commit tmux-matrix.yml pins)", ) options = parser.parse_args(argv) diff --git a/scripts/build-tmux-matrix/tests/test_build_tmux_matrix.py b/scripts/build-tmux-matrix/tests/test_build_tmux_matrix.py index 20d691457..9d496a7ff 100644 --- a/scripts/build-tmux-matrix/tests/test_build_tmux_matrix.py +++ b/scripts/build-tmux-matrix/tests/test_build_tmux_matrix.py @@ -56,9 +56,15 @@ def publish(base: Path, release: str, *, configure: str = CONFIGURE) -> str: def pin(tmp_path: Path, digests: dict[str, str]) -> list[str]: - """Write the digests a shared action would pin and return the option that names them.""" - path = tmp_path / "tmux-releases.json" - path.write_text(json.dumps(digests)) + """Write the digests setup-tmux would pin and return the option that names them.""" + path = tmp_path / "releases.json" + payload = { + "schema_version": 1, + "releases": [ + {"version": release, "tarball_sha256": digest} for release, digest in digests.items() + ], + } + path.write_text(json.dumps(payload)) return ["--digests-url", path.as_uri()] diff --git a/scripts/check-tmux-build/README.md b/scripts/check-tmux-build/README.md index 71c2ce861..9b1b571c2 100644 --- a/scripts/check-tmux-build/README.md +++ b/scripts/check-tmux-build/README.md @@ -1,7 +1,7 @@ # check-tmux-build -Checks that the tmux a lane runs is the one the lane is named after. The shared -`build-tmux` action validates a restored build before it uses it. This runs after +Checks that the tmux a lane runs is the one the lane is named after. The +`libtmux/setup-tmux` action validates a restored build before it uses it. This runs after the action and checks the wiring around it: the build under `~/tmux-builds/` is the release the matrix row names, a development lane runs a `next-X.Y` build, and the client build is the release it says. diff --git a/scripts/check-tmux-build/check_tmux_build.py b/scripts/check-tmux-build/check_tmux_build.py index 230887da3..4336eac19 100755 --- a/scripts/check-tmux-build/check_tmux_build.py +++ b/scripts/check-tmux-build/check_tmux_build.py @@ -5,7 +5,7 @@ # /// """Check that the tmux a lane built is the one it is named after. -The `build-tmux` action validates a restored build before it uses it. This runs +The `libtmux/setup-tmux` action validates a restored build before it uses it. This runs after the action and checks the wiring around it: the matrix builds each release under `~/tmux-builds/`, and this reads the version that build reports: