Skip to content
Merged
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
56 changes: 39 additions & 17 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).
# 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:
Expand All @@ -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
53 changes: 38 additions & 15 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).
# 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:
Expand All @@ -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-<tag>-<timestamp>) 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
41 changes: 29 additions & 12 deletions .github/workflows/plx-update.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
4 changes: 3 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.137.0
templates: [repo-turbo, updates]
ci_strategy: github
package_registry: npm
Expand All @@ -8,6 +8,8 @@ private_packages_scope: ''
publishes_packages: true
tenant: plexus-ms
update_max_age: 7
postgres: "18.6"
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).
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
89 changes: 55 additions & 34 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ 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.
"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.
"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 }
# The database of test and e2e: a real server from a binary, never a container or an emulation.
"conda:postgresql" = "18.6"

[settings]
Expand All @@ -23,8 +24,10 @@ postinstall = "if command -v hk >/dev/null; then hk install --mise; fi && npx co

[env]
_.path = ["{{config_root}}/node_modules/.bin"]
# 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_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() }}"
PLX_POSTGRES_MAJOR = "18"

[tasks.dev]
Expand All @@ -45,37 +48,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 +66,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=
Expand All @@ -104,5 +82,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 "<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 "$@"'
27 changes: 24 additions & 3 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,38 @@
"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/**"],
"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/**"],
"passThroughEnv": ["CI", "DATABASE_URL", "E2E_*", "PLAYWRIGHT_*", "PW_TEST_*"]
"env": ["PLX_POSTGRES_MAJOR"],
"passThroughEnv": ["CI", "PLAYWRIGHT_BROWSERS_PATH"]
},
"dev": {
"cache": false,
Expand Down
Loading