From 85f02930e427791487429bd8caec959225c2d984 Mon Sep 17 00:00:00 2001 From: David Julian Albers Date: Fri, 4 Dec 2026 14:11:08 +0100 Subject: [PATCH 1/2] chore: Plexus 0.137.0 Conflicted, committed with their markers, at the root: - mise.toml Set in the markers, the defaults of the questions 0.137.0 asks: - PLEXUS.md: postgres: "" - PLEXUS.md: turbo_cache_host: "" --- .github/workflows/on_pr.yml | 56 +++++++--- .github/workflows/on_push.yml | 53 ++++++--- .github/workflows/plx-update.yml | 41 ++++--- PLEXUS.md | 4 +- hk.pkl | 8 +- mise.toml | 90 ++++++++++------ turbo.json | 25 ++++- turbow | 180 +++++++++++++++++++++++++++++++ 8 files changed, 377 insertions(+), 80 deletions(-) create mode 100755 turbow diff --git a/.github/workflows/on_pr.yml b/.github/workflows/on_pr.yml index c5abea3..2d02063 100644 --- a/.github/workflows/on_pr.yml +++ b/.github/workflows/on_pr.yml @@ -1,7 +1,7 @@ name: on_pr -# Generated from plexus-ms/tooling, templates/repo-turbo: edit the template, never this file. -# A package repo's pull-request mount, check and the changeset guard (§ 5 PLX-Delivery). +# Generated from templates/repo-turbo of @plexus-ms/cli: edit the template, never this file. +# On a pull request: the job repo runs test, the guard asks for a changeset, and on the bot's the job changeset commits the one its bump owes; a newer push cancels them. on: pull_request: @@ -14,31 +14,53 @@ concurrency: cancel-in-progress: true jobs: - check: - uses: plexus-ms/tooling/.github/workflows/_check.yml@0.133.0 - with: - strategy: ${{ vars.CI_STRATEGY || 'github' }} - tasks: verify + repo: + runs-on: ${{ (vars.CI_STRATEGY || 'github') == 'github' && 'ubuntu-latest' || 'ci-repo' }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: jdx/mise-action@7e2b3c3d1450331892809a84e22e30e3f52c1e92 # v5.5.0 + with: + cache: ${{ runner.environment == 'github-hosted' }} + - id: setup + env: + GITHUB_TOKEN: ${{ github.token }} + run: plx-ci setup repo --publishes npm + - run: mise run test changeset-status: # `changeset version` consumed the release branch's changesets, and the bot's branches get theirs from the # changeset job: the guard counts any file under a package, so a devDependency bump would trip it. if: ${{ !startsWith(github.head_ref, 'changeset-release/') && !startsWith(github.head_ref, 'renovate/') }} - runs-on: ${{ (vars.CI_STRATEGY || 'github') == 'github' && 'ubuntu-latest' || 'ci-small' }} + runs-on: ${{ (vars.CI_STRATEGY || 'github') == 'github' && 'ubuntu-latest' || 'ci-repo' }} steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 - - uses: jdx/mise-action@v5 + - uses: jdx/mise-action@7e2b3c3d1450331892809a84e22e30e3f52c1e92 # v5.5.0 + with: + cache: ${{ runner.environment == 'github-hosted' }} - run: pnpm install --frozen-lockfile - run: pnpm exec changeset status --since=origin/main changeset: if: ${{ startsWith(github.head_ref, 'renovate/') }} - uses: plexus-ms/tooling/.github/workflows/_changeset.yml@0.133.0 - with: - gh-client-id: ${{ vars.GH_CLIENT_ID }} - strategy: ${{ vars.CI_STRATEGY || 'github' }} - secrets: - gh-private-key: ${{ secrets.GH_PRIVATE_KEY }} - op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + runs-on: ${{ (vars.CI_STRATEGY || 'github') == 'github' && 'ubuntu-latest' || 'ci-repo' }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: jdx/mise-action@7e2b3c3d1450331892809a84e22e30e3f52c1e92 # v5.5.0 + with: + cache: ${{ runner.environment == 'github-hosted' }} + - id: setup + env: + GH_CLIENT_ID: ${{ vars.GH_CLIENT_ID }} + GH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + run: plx-ci setup changeset + # The bot's branch again, its pushes the App's: a push with the workflow's own token would start no run on the new + # head, whose checks a ruleset may require. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + token: ${{ steps.setup.outputs.app-token }} + - run: plx changeset --commit diff --git a/.github/workflows/on_push.yml b/.github/workflows/on_push.yml index e55f32c..cf59351 100644 --- a/.github/workflows/on_push.yml +++ b/.github/workflows/on_push.yml @@ -1,7 +1,7 @@ name: on_push -# Generated from plexus-ms/tooling, templates/repo-turbo: edit the template, never this file. -# A package repo's trunk mount, check then publish; started by hand on a branch, snapshot versions of it (§ 5 PLX-Delivery). +# Generated from templates/repo-turbo of @plexus-ms/cli: edit the template, never this file. +# On a push to main: the job repo runs test and build, then changesets/action versions or publishes; started by hand with a dist-tag, a snapshot. on: push: @@ -19,16 +19,39 @@ permissions: id-token: write jobs: - check: - uses: plexus-ms/tooling/.github/workflows/_check.yml@0.133.0 - with: - strategy: ${{ vars.CI_STRATEGY || 'github' }} - tasks: verify - - publish: - needs: check - uses: plexus-ms/tooling/.github/workflows/_publish-package.yml@0.133.0 - with: - strategy: ${{ vars.CI_STRATEGY || 'github' }} - registry: npm - snapshot: ${{ inputs.snapshot }} + repo: + runs-on: ${{ (vars.CI_STRATEGY || 'github') == 'github' && 'ubuntu-latest' || 'ci-repo' }} + # A run waits for the one before it and is never cancelled, so that the publish never runs twice at once. + concurrency: + group: publish + cancel-in-progress: false + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: jdx/mise-action@7e2b3c3d1450331892809a84e22e30e3f52c1e92 # v5.5.0 + with: + cache: ${{ runner.environment == 'github-hosted' }} + - id: setup + env: + GITHUB_TOKEN: ${{ github.token }} + run: plx-ci setup repo --publishes npm + - run: mise run test + - run: mise run build + # The version script versions the packages for the "Version Packages" pull request; once that is merged, the + # publish script publishes what build built, and the action tags and releases each package it published. + - if: ${{ inputs.snapshot == '' }} + uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 + with: + version-script: pnpm exec changeset version + publish-script: mise run publish + commit-message: "chore: version packages" + pr-title: Version Packages + # A snapshot leaves the trunk alone: the versions it writes (0.0.0--) are published under the + # dist-tag and never committed or tagged. + - if: ${{ inputs.snapshot != '' }} + env: + SNAPSHOT: ${{ inputs.snapshot }} + run: pnpm exec changeset version --snapshot "$SNAPSHOT" + - if: ${{ inputs.snapshot != '' }} + env: + SNAPSHOT: ${{ inputs.snapshot }} + run: pnpm exec changeset publish --tag "$SNAPSHOT" --no-git-tag diff --git a/.github/workflows/plx-update.yml b/.github/workflows/plx-update.yml index 206902d..185f2b6 100644 --- a/.github/workflows/plx-update.yml +++ b/.github/workflows/plx-update.yml @@ -1,7 +1,7 @@ name: plx-update -# Generated from plexus-ms/tooling, templates/updates: edit the template, never this file. -# Mounts the update verb, `plx update` (§ 3 PLX-Updates). +# Generated from templates/updates of @plexus-ms/cli: edit the template, never this file. +# Mounts the update verb, `plx update` (§ 3 PLX-Updates): on the schedule the repo takes the version its step and its interval allow; run by hand, the newest version whatever its step, or the one named. on: schedule: @@ -18,13 +18,30 @@ permissions: jobs: update: - uses: plexus-ms/tooling/.github/workflows/_plx-update.yml@0.133.0 - with: - version: ${{ inputs.version || '' }} - now: ${{ github.event_name == 'workflow_dispatch' }} - gh-client-id: ${{ vars.GH_CLIENT_ID }} - strategy: ${{ vars.CI_STRATEGY || 'github' }} - secrets: - gh-private-key: ${{ secrets.GH_PRIVATE_KEY }} - op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} - + runs-on: ${{ (vars.CI_STRATEGY || 'github') == 'github' && 'ubuntu-latest' || 'ci-repo' }} + steps: + # The first checkout brings the mise.toml that pins plx and plx-ci, which every repo template writes. The push and + # the pull request are made as the tenant's GitHub App, so that the branch's tip runs the repo's checks and a + # workflow file may change: setup mints the App's token, and the second checkout persists it. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: jdx/mise-action@7e2b3c3d1450331892809a84e22e30e3f52c1e92 # v5.5.0 + with: + cache: ${{ runner.environment == 'github-hosted' }} + - id: setup + env: + GH_CLIENT_ID: ${{ vars.GH_CLIENT_ID }} + GH_PRIVATE_KEY: ${{ secrets.GH_PRIVATE_KEY }} + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} + run: plx-ci setup update + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + token: ${{ steps.setup.outputs.app-token }} + - env: + GH_TOKEN: ${{ steps.setup.outputs.app-token }} + PLX_UPDATE_TO: ${{ inputs.version }} + PLX_UPDATE_NOW: ${{ github.event_name == 'workflow_dispatch' }} + GIT_AUTHOR_NAME: plx[bot] + GIT_AUTHOR_EMAIL: plx-bot@users.noreply.github.com + GIT_COMMITTER_NAME: plx[bot] + GIT_COMMITTER_EMAIL: plx-bot@users.noreply.github.com + run: plx -y update diff --git a/PLEXUS.md b/PLEXUS.md index e51fa64..36b73c9 100644 --- a/PLEXUS.md +++ b/PLEXUS.md @@ -1,5 +1,5 @@ --- -version: 0.133.0 +version: 0.137.0 templates: [repo-turbo, updates] ci_strategy: github package_registry: npm @@ -8,6 +8,8 @@ private_packages_scope: '' publishes_packages: true tenant: plexus-ms update_max_age: 7 +postgres: "" +turbo_cache_host: "" --- - The `@plexus-ms/*` libraries: tenant-neutral methodology for the web/Node/TypeScript world on its own semver, versioned by changesets and published through trusted publishing (§ 5 PLX-Delivery); `plx` and `@plexus-ms/lib` live in `tooling` and carry the Plexus version (§ 1.5 PLX). diff --git a/hk.pkl b/hk.pkl index 6ec23d4..8f7c368 100644 --- a/hk.pkl +++ b/hk.pkl @@ -10,12 +10,16 @@ hooks { check = "mise :lint {{ files }}" fix = "mise :lint --write {{ files }}" } + ["check"] { + depends = "lint" + check = "mise :check" + } } } ["pre-push"] { steps { - ["check"] { - check = "mise :check" + ["test"] { + check = "mise :test" } } } diff --git a/mise.toml b/mise.toml index b9bc22e..6a22770 100644 --- a/mise.toml +++ b/mise.toml @@ -8,9 +8,14 @@ node = "24" hk = "latest" # The plx pins are written with each Plexus version, never by the update bot (§ 1 PLX-Updates); # allow_low_downloads only waives npm's young-package heuristics. +<<<<<<< current "npm:@plexus-ms/cli" = { version = "0.133.0", allow_low_downloads = true } # The server @plexus-ms/test-postgres starts in its own tests; PLX_POSTGRES_MAJOR below names its major. "conda:postgresql" = "18.6" +======= +"npm:@plexus-ms/cli" = { version = "0.137.0", allow_low_downloads = true } +"npm:@plexus-ms/cli-ci" = { version = "0.137.0", allow_low_downloads = true } +>>>>>>> new render [settings] # Not a version source: it lets config_roots match a project without a mise config of its own, @@ -23,9 +28,16 @@ postinstall = "if command -v hk >/dev/null; then hk install --mise; fi && npx co [env] _.path = ["{{config_root}}/node_modules/.bin"] +<<<<<<< current # The major the tests ask the server for: that of the conda:postgresql pin, which a wrong one fails. # Declared in turbo.json, so a new major runs the tests again. PLX_POSTGRES_MAJOR = "18" +======= +PLX_TURBO_CACHE_HOST = "" +# Turbo hashes these where a turbo.json declares them: the platform on an app's build only, and never in the +# root's env or globalEnv, which would move the hash of every task; the major in the root's env of test and e2e. +PLX_PLATFORM = "{{ os() }}-{{ arch() }}" +>>>>>>> new render [tasks.dev] description = "No-op: a package repo has no development environment to start; build builds its packages and test exercises them" @@ -45,37 +57,12 @@ if [ -n "${usage_name:-}" ]; then [ ! -f "packages/$usage_name/package.json" ] || dir=packages/$usage_name [ -n "$dir" ] || { echo "build: no package $usage_name under packages/" >&2; exit 1; } fi -turbo run build ${dir:+--filter="{./$dir}..."} +./turbow trusted run build ${dir:+--filter="{./$dir}..."} ''' -[tasks.verify] -description = "Perform all steps that verify code quality" -usage = 'arg "[name]" help="Package to verify, by its directory name under packages/ (e.g. my-package, defaults to all)"' -run = [ - 'mise run check ${usage_name:+"$usage_name"}', - 'mise run test ${usage_name:+"$usage_name"}', -] - -[tasks.install] -description = "Install and wire up project dependencies" -hide = true -run = "pnpm install" -sources = ["package.json", "packages/*/package.json", "pnpm-lock.yaml", "pnpm-workspace.yaml"] -outputs = ["node_modules/.pnpm/lock.yaml"] - -[tasks.lint] -depends = ["install"] -description = "Lint and format the codebase" -usage = ''' -flag "--write" help="Apply safe fixes and formatting in place" -arg "" var=#true default="." help="Files or directories to lint (defaults to the whole repo)" -''' -# usage shell-quotes var-arg values, so re-parse them via eval instead of bare expansion. -run = 'eval "set -- $usage_paths"; biome check ${usage_write:+--write} --no-errors-on-unmatched "$@"' - [tasks.check] depends = ["install"] -description = "Run static checks on the codebase: lint and the contracts' checks (plx doctor), repo-wide, then each project's check script" +description = "Run every static check, executing no test: lint (Biome) and the contracts' checks (plx doctor), repo-wide, then each project's check script" usage = 'arg "[name]" help="Package to check, by its directory name under packages/ (e.g. my-package, defaults to all)"' run = ''' dir= @@ -88,12 +75,12 @@ if [ -n "${usage_name:-}" ]; then fi mise run lint plx doctor -turbo run check ${dir:+--filter="{./$dir}..."} +./turbow shared+builds run check ${dir:+--filter="{./$dir}..."} ''' [tasks.test] depends = ["install"] -description = "Run tests on the codebase" +description = "Run check, then every test that lives beside the code; no built app is needed" usage = 'arg "[name]" help="Package to test, by its directory name under packages/ (e.g. my-package, defaults to all)"' run = ''' dir= @@ -104,5 +91,48 @@ if [ -n "${usage_name:-}" ]; then [ ! -f "packages/$usage_name/package.json" ] || dir=packages/$usage_name [ -n "$dir" ] || { echo "test: no package $usage_name under packages/" >&2; exit 1; } fi -turbo run test ${dir:+--filter="{./$dir}..."} +mise run check ${usage_name:+"$usage_name"} +./turbow shared+builds run test ${dir:+--filter="{./$dir}..."} +''' + +[tasks.e2e] +depends = ["install"] +description = "Run the end-to-end suites, after the workspace packages they depend on are built; it neither checks nor tests" +usage = 'arg "[name]" help="Package to e2e, by its directory name under packages/ (e.g. my-package, defaults to all)"' +# A name selects the project and the projects that depend on it, since a suite is a package that depends on its app. +run = ''' +dir= +if [ -n "${usage_name:-}" ]; then + case $usage_name in + */* | . | ..) echo "e2e: $usage_name is not a directory name under packages/" >&2; exit 1 ;; + esac + [ ! -f "packages/$usage_name/package.json" ] || dir=packages/$usage_name + [ -n "$dir" ] || { echo "e2e: no package $usage_name under packages/" >&2; exit 1; } +fi +./turbow trusted run e2e ${dir:+--filter="...{./$dir}"} +''' + +[tasks.publish] +depends = ["install"] +description = "Publish the packages that carry a pending release: changeset publish; a name is accepted and ignored, it applies to every package" +usage = 'arg "[name]" hide=#true' +# What a package repo publishes is its packages, as they were built: this task builds nothing itself, so `build` runs +# before it. +run = 'pnpm exec changeset publish' + +[tasks.install] +description = "Install and wire up project dependencies" +hide = true +run = "pnpm install" +sources = ["package.json", "packages/*/package.json", "pnpm-lock.yaml", "pnpm-workspace.yaml"] +outputs = ["node_modules/.pnpm/lock.yaml"] + +[tasks.lint] +depends = ["install"] +description = "Lint and format the codebase" +usage = ''' +flag "--write" help="Apply safe fixes and formatting in place" +arg "" var=#true default="." help="Files or directories to lint (defaults to the whole repo)" ''' +# usage shell-quotes var-arg values, so re-parse them via eval instead of bare expansion. +run = 'eval "set -- $usage_paths"; biome check ${usage_write:+--write} --no-errors-on-unmatched "$@"' diff --git a/turbo.json b/turbo.json index 8198a1c..8683af5 100644 --- a/turbo.json +++ b/turbo.json @@ -3,17 +3,36 @@ "tasks": { "build": { "dependsOn": ["^build"], - "inputs": ["$TURBO_DEFAULT$", "!**/{README,AGENTS,PLEXUS}.md", "!docs/**", "!docker/compose*.yaml"], + "inputs": [ + "$TURBO_DEFAULT$", + "!**/{README,AGENTS,PLEXUS}.md", + "!docs/**", + "!docker/compose*.yaml", + "!**/*.{test,spec}.*", + "!**/{__tests__,__snapshots__}/**", + "!tests/**", + "!{vitest,playwright,jest}*.config.*" + ], "outputs": ["dist/**"] }, + // A package repo builds its packages, so there a check or a test waits for the builds it reads. An app repo's + // packages export their source, so these two read no build, wait for none, and the shared cache holds no build + // output; each depends on its project's transit instead, which carries the hashes of what the project imports, so + // that a change to a package runs them again in every project that imports it, and no check waits for another. "check": { "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", "!**/{README,AGENTS,PLEXUS}.md", "!docs/**", "!docker/compose*.yaml"] }, "test": { - "dependsOn": ["build"], + "dependsOn": ["^build"], + "inputs": ["$TURBO_DEFAULT$", "!**/{README,AGENTS,PLEXUS}.md", "!docs/**"], + // CI is passed through, never hashed: a pass on a developer's machine counts in CI, so no test may change what it tests by CI. + "passThroughEnv": ["CI"] + }, + "e2e": { + "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", "!**/{README,AGENTS,PLEXUS}.md", "!docs/**"], - "passThroughEnv": ["CI", "DATABASE_URL", "E2E_*", "PLAYWRIGHT_*", "PW_TEST_*"] + "passThroughEnv": ["CI", "PLAYWRIGHT_BROWSERS_PATH"] }, "dev": { "cache": false, diff --git a/turbow b/turbow new file mode 100755 index 0000000..d4af0af --- /dev/null +++ b/turbow @@ -0,0 +1,180 @@ +#!/bin/sh +# Generated from plexus-ms/tooling, templates/repo-turbo. +# Turbo with the remote cache its verb may use, as the tasks call it: ./turbow (below). +set -eu + +cache=${1:-} +case $cache in + shared | trusted) shift ;; + shared+builds) + shift + if [ "${1:-}" != run ] || [ -z "${2:-}" ]; then + echo "usage: ./turbow shared+builds run " >&2 + exit 2 + fi + ;; + *) + echo "usage: ./turbow " >&2 + exit 2 + ;; +esac + +# Where and how artifacts go is turbow's alone: no remote-cache setting of the caller's shell reaches Turbo, and no +# artifact is signed. +unset TURBO_API TURBO_TEAM TURBO_TEAMID TURBO_TOKEN TURBO_LOGIN TURBO_CACHE TURBO_REMOTE_CACHE_SIGNATURE_KEY \ + TURBO_REMOTE_CACHE_TIMEOUT TURBO_REMOTE_CACHE_UPLOAD_TIMEOUT TURBO_REMOTE_CACHE_READ_ONLY TURBO_PREFLIGHT \ + TURBO_REMOTE_ONLY + +# Which server (§ 8 PLX-Delivery): check and test call turbow with `shared`, a package repo's with `shared+builds` +# (below), build, e2e and publish with `trusted`. +# In a job of the forge (GITHUB_ACTIONS=true, which the forge's runner sets and CI alone does not), a trusted verb uses +# the trusted server and no local cache, and a shared verb the shared server. Outside a job every verb uses the shared +# server: no machine but CI holds the trusted token. +# the shared server PLX_TURBO_SHARED, else http://:8585 +# the trusted server PLX_TURBO_TRUSTED, else http://:8586 +# their tokens PLX_TURBO_SHARED_TOKEN, PLX_TURBO_TRUSTED_TOKEN +# PLX_TURBO_CACHE_HOST is the answer turbo_cache_host, which mise sets from mise.toml. A slot of a runner host names its +# own host's servers in PLX_TURBO_SHARED and PLX_TURBO_TRUSTED, which come first. An empty variable names nothing. +# In a job, PLX_TURBO_TRUSTED=local is plx-ci setup's word that the job reaches no trusted server that answers: build, +# e2e and publish then share the local cache of the job's checkout and need no token, so that each build runs once in +# the job and every later run replays it: e2e and publish an app's, which the image is made from, and the step build a +# package's that check and test read. +# +# In a job no build is restored from the shared server, which development machines write, so every build in the job's +# checkout and its local cache is the job's own or the trusted server's. In an app repo check and test read no build: +# they depend on the transit of their project, so what the shared server puts into the checkout is their verdicts, and +# no files. In a package repo they read builds, those of the packages they import (^build) and any a turbo.json adds, +# and call turbow as `./turbow shared+builds run ...`; outside a job that is `shared`. In a job, Turbo's dry run +# of the task, which asks no cache, names every task build its run holds, whatever edge leads there; turbow runs +# exactly those against the trusted server with the job's local cache, or that cache alone where no trusted server +# answers, then the task against the shared server, which finds each build in the local cache, read first: Turbo asks +# the shared server for no build and writes none there. Without node to read the dry run with, the task runs without a +# remote cache. The guarantee holds for the tasks named build: a check or test that reads the outputs of a task by +# another name is outside it. +# In a job, task by task, each read and written where it says: +# +# app repo check, test the shared server and the local cache: verdicts +# build, e2e the trusted server; where none answers, the local cache +# publish never cached; the build it waits for, as build +# package repo the builds check the trusted server and the local cache; where none answers, the local cache; in a +# and test read run of their own, ahead of the task's +# check, test the shared server and the local cache: verdicts; their builds, from the local cache +# build, e2e the trusted server; where none answers, the local cache +# +# A package repo's publish is changeset publish, which runs no Turbo. +# +# It runs without a remote cache, and says why in one line, where no server is named, where the shared token is +# missing, where no node is on PATH to ask the server with, where the server refuses the token or does not answer +# within two seconds, and where origin names no team. +# In a job, a trusted server named without the trusted token fails the verb in one line instead. +host=${PLX_TURBO_CACHE_HOST:-} +job= +if [ "${GITHUB_ACTIONS:-}" = true ]; then job=true; fi + +# Sets the remote cache of Turbo's next run to that of $1, shared, trusted, or builds (the trusted server with the +# local cache, for the builds that check and test read), and says which in one line. +use() { + if [ -n "$job" ] && [ "$1" != shared ]; then + from=trusted server=${PLX_TURBO_TRUSTED:-${host:+http://$host:8586}} token=${PLX_TURBO_TRUSTED_TOKEN:-} + if [ "$1" = trusted ]; then + with=remote:rw without=remote:rw what="build, e2e and publish" + else + with=local:rw,remote:rw without=local:rw what="the builds that check and test read" + fi + else + from=shared server=${PLX_TURBO_SHARED:-${host:+http://$host:8585}} token=${PLX_TURBO_SHARED_TOKEN:-} + with=local:rw,remote:rw without=local:rw + fi + + reason= + if [ -z "$server" ]; then + reason="the repo names no cache host (turbo_cache_host), and the environment no $from server" + elif [ "$from" = trusted ] && [ "$server" = local ]; then + reason="plx-ci setup found no trusted server that answers, so $what share the job's local cache" + without=local:rw + elif [ -z "$token" ] && [ "$from" = trusted ]; then + echo "turbow: in a job of the forge, $what need a token for the trusted remote cache at $server, and this job has none (PLX_TURBO_TRUSTED_TOKEN is unset)" >&2 + exit 1 + elif [ -z "$token" ]; then + reason="no token for the shared remote cache at $server (PLX_TURBO_SHARED_TOKEN is unset)" + elif ! command -v node >/dev/null 2>&1; then + reason="no node on PATH to ask the $from remote cache at $server with" + else + # The request Turbo makes first, with the token: 200 is a server to use. + status=$(TOKEN=$token node -e ' + fetch(process.argv[1], { + headers: { Authorization: "Bearer " + process.env.TOKEN }, + signal: AbortSignal.timeout(2000), + }).then( + (answer) => console.log(answer.status), + () => console.log(0), + );' "$server/v8/artifacts/status") + case $status in + 200) ;; + 401) reason="the $from remote cache at $server refuses the token" ;; + *) reason="nothing answers at $server" ;; + esac + fi + + # The team keeps the repos of a tenant apart in a bucket: owner-repo, the last two names of the path of origin's URL + # (a nested group keeps its last two), in lower case, without .git, every character but [a-z0-9._-] a dash. + if [ -z "$reason" ]; then + if url=$(git remote get-url origin 2>/dev/null); then + path=$(printf '%s' "$url" | LC_ALL=C tr '[:upper:]' '[:lower:]') + case $path in + *://*) + path=${path#*://} + path=${path#*/} + ;; + *) case ${path%%/*} in *:*) path=${path#*:} ;; esac ;; + esac + path=${path%/} + path=${path%.git} + case $path in + */*) + rest=${path%/*} + team=$(printf '%s-%s' "${rest##*/}" "${path##*/}" | LC_ALL=C sed 's/[^a-z0-9._-]/-/g') + ;; + *) reason="origin's URL names no owner to name the team with ($url)" ;; + esac + else + reason="the checkout has no origin to name its team" + fi + fi + + if [ -n "$reason" ]; then + echo "turbow: without a remote cache: $reason" >&2 + # Told to Turbo too: a login and a linked repo would otherwise send the artifacts there. + export TURBO_API='' TURBO_TEAM='' TURBO_TEAMID='' TURBO_TOKEN='' TURBO_CACHE="$without" + else + echo "turbow: the $from remote cache at $server, team $team" >&2 + # No team id: a linked repo's (.turbo/config.json) would otherwise reach the server beside the team. + export TURBO_API="$server" TURBO_TEAM="$team" TURBO_TEAMID='' TURBO_TOKEN="$token" TURBO_CACHE="$with" + fi +} + +if [ "$cache" = shared+builds ]; then + task=$2 + shift 2 + if [ -n "$job" ] && command -v node >/dev/null 2>&1; then + graph=$(TURBO_API='' TURBO_TEAM='' TURBO_TEAMID='' TURBO_TOKEN='' TURBO_CACHE=local:r \ + turbo run "$task" "$@" --dry=json) + builds=$(printf '%s' "$graph" | node -e ' + const { tasks } = JSON.parse(require("node:fs").readFileSync(0, "utf8")); + for (const { task, package: name } of tasks) if (task === "build") console.log(`--filter=${name}`);') + if [ -n "$builds" ]; then + use builds + # One filter a line, split on lines alone: a package's name holds no whitespace and no pattern. + set -f + IFS=' +' + turbo run build $builds + unset IFS + set +f + fi + fi + use shared + exec turbo run "$task" "$@" +fi +use "$cache" +exec turbo "$@" From 2c545a04c413abe3aec535d496c2f8b4b7d1081b Mon Sep 17 00:00:00 2001 From: David Julian Albers Date: Fri, 4 Dec 2026 14:12:29 +0100 Subject: [PATCH 2/2] chore: resolve Plexus 0.137.0 conflicts, set the postgres answer mise.toml takes the new render and keeps the repo's PostgreSQL pin through the postgres answer (18.6), which also declares PLX_POSTGRES_MAJOR in turbo.json's test and e2e. Co-Authored-By: Claude Sonnet 5.5 --- PLEXUS.md | 2 +- mise.toml | 15 +++------------ turbo.json | 2 ++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/PLEXUS.md b/PLEXUS.md index 36b73c9..2b898f7 100644 --- a/PLEXUS.md +++ b/PLEXUS.md @@ -8,7 +8,7 @@ private_packages_scope: '' publishes_packages: true tenant: plexus-ms update_max_age: 7 -postgres: "" +postgres: "18.6" turbo_cache_host: "" --- diff --git a/mise.toml b/mise.toml index 6a22770..c738dd5 100644 --- a/mise.toml +++ b/mise.toml @@ -8,14 +8,10 @@ node = "24" hk = "latest" # The plx pins are written with each Plexus version, never by the update bot (§ 1 PLX-Updates); # allow_low_downloads only waives npm's young-package heuristics. -<<<<<<< current -"npm:@plexus-ms/cli" = { version = "0.133.0", allow_low_downloads = true } -# The server @plexus-ms/test-postgres starts in its own tests; PLX_POSTGRES_MAJOR below names its major. -"conda:postgresql" = "18.6" -======= "npm:@plexus-ms/cli" = { version = "0.137.0", allow_low_downloads = true } "npm:@plexus-ms/cli-ci" = { version = "0.137.0", allow_low_downloads = true } ->>>>>>> new render +# The database of test and e2e: a real server from a binary, never a container or an emulation. +"conda:postgresql" = "18.6" [settings] # Not a version source: it lets config_roots match a project without a mise config of its own, @@ -28,16 +24,11 @@ postinstall = "if command -v hk >/dev/null; then hk install --mise; fi && npx co [env] _.path = ["{{config_root}}/node_modules/.bin"] -<<<<<<< current -# The major the tests ask the server for: that of the conda:postgresql pin, which a wrong one fails. -# Declared in turbo.json, so a new major runs the tests again. -PLX_POSTGRES_MAJOR = "18" -======= PLX_TURBO_CACHE_HOST = "" # Turbo hashes these where a turbo.json declares them: the platform on an app's build only, and never in the # root's env or globalEnv, which would move the hash of every task; the major in the root's env of test and e2e. PLX_PLATFORM = "{{ os() }}-{{ arch() }}" ->>>>>>> new render +PLX_POSTGRES_MAJOR = "18" [tasks.dev] description = "No-op: a package repo has no development environment to start; build builds its packages and test exercises them" diff --git a/turbo.json b/turbo.json index 8683af5..56a34cb 100644 --- a/turbo.json +++ b/turbo.json @@ -26,12 +26,14 @@ "test": { "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", "!**/{README,AGENTS,PLEXUS}.md", "!docs/**"], + "env": ["PLX_POSTGRES_MAJOR"], // CI is passed through, never hashed: a pass on a developer's machine counts in CI, so no test may change what it tests by CI. "passThroughEnv": ["CI"] }, "e2e": { "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", "!**/{README,AGENTS,PLEXUS}.md", "!docs/**"], + "env": ["PLX_POSTGRES_MAJOR"], "passThroughEnv": ["CI", "PLAYWRIGHT_BROWSERS_PATH"] }, "dev": {