Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/on_pr.yml
Original file line number Diff line number Diff line change
@@ -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).
# A package repo's pull-request mount, the test job and the changeset guard (§ 5 PLX-Delivery).

on:
pull_request:
Expand All @@ -14,11 +14,13 @@ concurrency:
cancel-in-progress: true

jobs:
check:
uses: plexus-ms/tooling/.github/workflows/_check.yml@0.133.0
test:
uses: plexus-ms/tooling/.github/workflows/_check.yml@0.134.1
with:
strategy: ${{ vars.CI_STRATEGY || 'github' }}
tasks: verify
tasks: test
secrets:
op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

changeset-status:
# `changeset version` consumed the release branch's changesets, and the bot's branches get theirs from the
Expand All @@ -35,7 +37,7 @@ jobs:

changeset:
if: ${{ startsWith(github.head_ref, 'renovate/') }}
uses: plexus-ms/tooling/.github/workflows/_changeset.yml@0.133.0
uses: plexus-ms/tooling/.github/workflows/_changeset.yml@0.134.1
with:
gh-client-id: ${{ vars.GH_CLIENT_ID }}
strategy: ${{ vars.CI_STRATEGY || 'github' }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
@@ -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).
# A package repo's trunk mount, the test job then publish; started by hand on a branch, snapshot versions of it (§ 5 PLX-Delivery).

on:
push:
Expand All @@ -19,15 +19,17 @@ permissions:
id-token: write

jobs:
check:
uses: plexus-ms/tooling/.github/workflows/_check.yml@0.133.0
test:
uses: plexus-ms/tooling/.github/workflows/_check.yml@0.134.1
with:
strategy: ${{ vars.CI_STRATEGY || 'github' }}
tasks: verify
tasks: test
secrets:
op-service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

publish:
needs: check
uses: plexus-ms/tooling/.github/workflows/_publish-package.yml@0.133.0
needs: test
uses: plexus-ms/tooling/.github/workflows/_publish-package.yml@0.134.1
with:
strategy: ${{ vars.CI_STRATEGY || 'github' }}
registry: npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/plx-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ permissions:

jobs:
update:
uses: plexus-ms/tooling/.github/workflows/_plx-update.yml@0.133.0
uses: plexus-ms/tooling/.github/workflows/_plx-update.yml@0.134.1
with:
version: ${{ inputs.version || '' }}
now: ${{ github.event_name == 'workflow_dispatch' }}
Expand Down
3 changes: 2 additions & 1 deletion PLEXUS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 0.133.0
version: 0.134.1
templates: [repo-turbo, updates]
ci_strategy: github
package_registry: npm
Expand All @@ -8,6 +8,7 @@ private_packages_scope: ''
publishes_packages: true
tenant: plexus-ms
update_max_age: 7
postgres: ""
---

- 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).
Expand Down
8 changes: 6 additions & 2 deletions hk.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
80 changes: 50 additions & 30 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ 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.134.1", 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,
Expand All @@ -23,9 +27,15 @@ 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"
=======
# 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"
Expand All @@ -45,37 +55,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 "<paths>" 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=
Expand All @@ -88,12 +73,12 @@ if [ -n "${usage_name:-}" ]; then
fi
mise run lint
plx doctor
turbo run check ${dir:+--filter="{./$dir}..."}
./turbow shared 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=
Expand All @@ -104,5 +89,40 @@ 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 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.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 "<paths>" 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 "$@"'
21 changes: 18 additions & 3 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@
"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/**"]
},
"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,
Expand Down
86 changes: 86 additions & 0 deletions turbow
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/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 <shared|trusted> <turbo arguments>.
set -eu

cache=${1:-}
case $cache in
shared | trusted) shift ;;
*)
echo "usage: ./turbow <shared|trusted> <turbo arguments>" >&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_CACHE TURBO_REMOTE_CACHE_SIGNATURE_KEY \
TURBO_REMOTE_CACHE_READ_ONLY TURBO_PREFLIGHT TURBO_REMOTE_ONLY

reason=
# Outside a job of the forge no machine holds the trusted keys: every verb uses the shared server, by default this
# machine's own, run without a token. In a job (GITHUB_ACTIONS=true, which the forge's runner sets and CI alone does not)
# a verb uses only the server its job started (.github/actions/turbo-cache of plexus-ms/tooling), with the job's token,
# and build and e2e never use the shared one. A server named none is a tenant without the bucket.
if [ "${GITHUB_ACTIONS:-}" != true ]; then
from=shared server=${PLX_TURBO_SHARED:-http://127.0.0.1:8585} token=${PLX_TURBO_SHARED_TOKEN:-local}
if [ "$server" != none ] && ! node -e '
fetch(process.argv[1], { signal: AbortSignal.timeout(2000) }).then(
(answer) => process.exit(answer.ok ? 0 : 1),
() => process.exit(1),
);' "$server/management/health"; then
reason="nothing answers at $server"
fi
elif [ "$cache" = trusted ]; then
if [ -z "${PLX_TURBO_TRUSTED:-}" ]; then
echo "turbow: in a job of the forge, build and e2e need the trusted cache server, and this job started none (PLX_TURBO_TRUSTED is unset); they never use the shared one" >&2
exit 1
fi
from=trusted server=$PLX_TURBO_TRUSTED token=${PLX_TURBO_TRUSTED_TOKEN:-local}
else
from=shared server=${PLX_TURBO_SHARED:-} token=${PLX_TURBO_SHARED_TOKEN:-local}
[ -n "$server" ] || reason="this job started no shared cache server (PLX_TURBO_SHARED is unset)"
fi
if [ "$server" = none ]; then
reason="the tenant has no $from bucket"
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_TOKEN='' TURBO_CACHE=local:rw
elif [ "$from" = trusted ]; then
echo "turbow: the trusted remote cache at $server, team $team" >&2
# Never the local cache, which a shared run of this checkout may have filled from the shared bucket.
export TURBO_API="$server" TURBO_TEAM="$team" TURBO_TOKEN="$token" TURBO_CACHE=remote:rw
else
echo "turbow: the shared remote cache at $server, team $team" >&2
export TURBO_API="$server" TURBO_TEAM="$team" TURBO_TOKEN="$token" TURBO_CACHE=local:rw,remote:rw
fi
exec turbo "$@"
Loading