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
9 changes: 9 additions & 0 deletions .github/workflows/emulator-freshness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ jobs:
TITLE: 'chore: Fly emulator image pin(s) behind latest release'
BODY: ${{ steps.freshness.outputs.body }}
run: |
# The repo has no `chore` label by default, and `gh issue create
# --label chore` hard-fails ("could not add label: 'chore' not
# found") WITHOUT opening the issue — so every run since the pins
# went stale died here and the advisory issue was never filed.
# Create it up front; --force makes this idempotent.
gh label create chore \
--description "Routine maintenance — pin bumps, chores" \
--color ededed --force

existing=$(gh issue list --state open --search "in:title $TITLE" --json number --jq '.[0].number // empty')
if [ -n "$existing" ]; then
gh issue edit "$existing" --body "$BODY"
Expand Down
156 changes: 35 additions & 121 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ on:
workflow_dispatch:

jobs:
# Which packages can actually publish over OIDC, answered in seconds. No
# `needs:`, so it does not wait on the test gate — dispatch this workflow and
# the coverage table is in the run summary before the suite finishes.
#
# It lives here rather than in its own workflow because npm matches a
# trusted-publisher record against the workflow FILENAME: probing from
# anywhere else reports every package as missing and proves nothing.
#
# Informational, never gating. The publish job is what fails a bad release.
audit:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- run: bash scripts/audit-trusted-publishers.sh

test:
# Full validation gate for tag releases and manual dispatch. Skipped on the
# publish-on-merge (branch) path: that code already passed PR CI, and each
Expand Down Expand Up @@ -86,124 +104,20 @@ jobs:
# publish token via the trusted-publisher record.
- run: npm install

# Each package publishes independently: `if: !cancelled()` so one package's
# publish failure (e.g. a missing trusted-publisher record) does not SKIP
# every package after it — before this, a single failure left the release
# half-published (core bumped, lexicons stranded a version behind). The
# per-step `[ "$V" = "$P" ] && skip` guard makes a re-run idempotent, so a
# partial release is recovered by re-running or dispatching this workflow.
- name: Publish @intentius/chant
if: ${{ !cancelled() }}
working-directory: packages/core
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

# The k8s lexicon declares this as an optional dependency (#1074). npm
# tolerates an optional dependency that fails to resolve, so publishing it
# ahead of the lexicon is what keeps `chant lifecycle diff --live` working
# for a registry install rather than silently degrading to holes.
- name: Publish @intentius/chant-k8s-client
if: ${{ !cancelled() }}
working-directory: packages/k8s-client
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-k8s-client version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-gitlab
if: ${{ !cancelled() }}
working-directory: lexicons/gitlab
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-gitlab version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-aws
if: ${{ !cancelled() }}
working-directory: lexicons/aws
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-aws version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-github
if: ${{ !cancelled() }}
working-directory: lexicons/github
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-github version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-forgejo
if: ${{ !cancelled() }}
working-directory: lexicons/forgejo
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-forgejo version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-k8s
if: ${{ !cancelled() }}
working-directory: lexicons/k8s
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-k8s version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-gcp
if: ${{ !cancelled() }}
working-directory: lexicons/gcp
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-gcp version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-helm
if: ${{ !cancelled() }}
working-directory: lexicons/helm
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-helm version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-azure
if: ${{ !cancelled() }}
working-directory: lexicons/azure
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-azure version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-docker
if: ${{ !cancelled() }}
working-directory: lexicons/docker
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-docker version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-temporal
if: ${{ !cancelled() }}
working-directory: lexicons/temporal
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-temporal version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-fly
if: ${{ !cancelled() }}
working-directory: lexicons/fly
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-fly version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance

- name: Publish @intentius/chant-lexicon-fountain
if: ${{ !cancelled() }}
working-directory: lexicons/fountain
run: |
V=$(node -e "process.stdout.write(require('./package.json').version)")
P=$(npm view @intentius/chant-lexicon-fountain version 2>/dev/null || echo "none")
[ "$V" = "$P" ] && echo "Already at $V, skipping" || npm publish --access public --provenance
# One script publishes every non-private workspace package, in
# dependency-safe order, continuing past a failure so one bad package
# cannot strand the rest of the release (it exits non-zero at the end
# if any failed). It enumerates the workspace rather than naming
# packages here: #1177 (k8s-client) and #1253 (fountain) each added a
# package whose publish step was wrong, and every release since
# chant-v0.33.0 went red. The skip-if-unchanged check makes re-running
# idempotent, so a partial release is recovered by re-running or
# dispatching this workflow.
- name: Publish workspace packages
env:
# Fallback only. Packages with an npm trusted-publisher record
# publish over OIDC and never touch this; a package that has no
# record yet (a newly added one) uses it instead of failing the
# release. See scripts/publish-packages.sh.
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: bash scripts/publish-packages.sh
2 changes: 1 addition & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ How confident can we be that published npm packages actually work for end users?
| Smoke tests disabled in CI | Accepted | Docker builds are slow (~10min). Publish workflow runs `prepack` + `npx vitest run` as a gate. Run `just smoke` locally before releases. |
| `integrity.json` never verified at runtime | Low | `verifyIntegrity()` exists in `lexicon-integrity.ts` but `loadPlugin()` in `cli/plugins.ts` doesn't call it. Defense-in-depth, not a correctness issue. |
| Lexicon tarballs include entire `src/` | Low | Ships codegen scripts, fetch utilities, and test files. Bloats tarballs but doesn't break anything. Could narrow `"files"` in package.json. |
| Sequential publish — partial failure risk | Low | If npm goes down mid-publish, some packages may be at different versions. Retry with `--tolerate-republish` fixes this. Acceptable at current scale. |
| Sequential publish — partial failure risk | Low | If npm goes down mid-publish, some packages may be at different versions. `scripts/publish-packages.sh` skips any package already at its version, so re-running the workflow republishes only the stragglers. (There is no `--tolerate-republish` flag; that was never implemented.) |

## Troubleshooting

Expand Down
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default defineConfig({
badge: { text: 'Plugin Dev', variant: 'tip' },
items: [
{ label: 'Overview', slug: 'lexicon-authoring/overview' },
{ label: 'Onboarding Skill (for agents)', slug: 'lexicon-authoring/onboarding-skill' },
{ label: 'Scaffold a Lexicon', slug: 'lexicon-authoring/scaffold' },
{ label: 'Implement Generate', slug: 'lexicon-authoring/generate' },
{ label: 'Add a Third-Party CRD', slug: 'lexicon-authoring/crd-sources' },
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/cli/onboard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The command modifies 5 files:
|------|--------|
| `package.json` (root) | Adds `@intentius/chant-lexicon-<name>: "workspace:*"` to dependencies |
| `.github/workflows/chant.yml` | Adds prepack lines to check/test jobs + a validate step |
| `.github/workflows/publish.yml` | Adds prepack line to test job + a publish step |
| `.github/workflows/publish.yml` | Adds prepack line to test job (publishing needs no per-lexicon step — `scripts/publish-packages.sh` enumerates the workspace) |
| `test/Dockerfile.smoke` | Adds `RUN npm run --prefix lexicons/<name> prepack` |
| `test/Dockerfile.smoke-node` | Same prepack line for Node.js smoke test |

Expand Down
67 changes: 59 additions & 8 deletions docs/src/content/docs/lexicon-authoring/ci-integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import { Aside, Steps } from '@astrojs/starlight/components';

After building your lexicon (see [Package & Publish](/chant/lexicon-authoring/package/)), you need to wire it into the monorepo's CI pipeline, smoke tests, and publish workflow. The `chant dev onboard` command automates most of this.

:::tip[Working with an AI agent? Point it at the onboarding skill.]
This page explains what each patched file does and why. If you just need the ordered
checklist — scaffold through first npm publish, including the npm trusted-publisher
record that nothing here can create for you — hand your agent
[Lexicon Onboarding Skill](/chant/lexicon-authoring/onboarding-skill/) instead.
:::

## Quick start

```bash
Expand All @@ -19,7 +26,7 @@ This patches 5 files:
|------|-------------|
| `package.json` (root) | `@intentius/chant-lexicon-<name>: "workspace:*"` dependency |
| `.github/workflows/chant.yml` | Prepack lines in check/test jobs + validate step |
| `.github/workflows/publish.yml` | Prepack line in test job + publish step |
| `.github/workflows/publish.yml` | Prepack line in test job (no publish step needed — `scripts/publish-packages.sh` enumerates the workspace) |
| `test/Dockerfile.smoke` | Prepack validation line for workspace smoke test |
| `test/Dockerfile.smoke-npm` | Prepack validation line for npm tarball smoke test |

Expand Down Expand Up @@ -103,14 +110,48 @@ The command is idempotent — running it twice skips already-configured files.

## First npm publish

All packages are published together via the publish workflow, triggered by pushing a `v*` tag:
<Aside type="danger" title="Do this before the first release, or the release breaks">
A new package needs an npm **trusted publisher** record, and nothing in the
repo can create one for you. Without it the publish workflow authenticates
over OIDC, the registry has no record to match, and `npm publish` reports a
bare `ENEEDAUTH` — indistinguishable from having no credentials at all.

On [npmjs.com](https://www.npmjs.com), open the package, then Settings →
Trusted Publisher, and add:

| Field | Value |
|------|-------|
| Organization / repository | `INTENTIUS/chant` |
| Workflow filename | `publish.yml` |
| Environment | *leave empty* — the publish job declares none, and a value here will not match |

The record is per package. It is not inherited from the org and not shared
with the other packages, so every new lexicon needs its own. This step was
missing from these docs, and both `@intentius/chant-k8s-client` and
`@intentius/chant-lexicon-fountain` shipped without a record and could not be
published at all until it was added.
</Aside>

Releases go out through `just release`, which bumps every package in lockstep,
commits, and pushes the tag the workflow actually listens for:

```bash
git tag v<version>
git push origin v<version>
just release patch # or: minor / major
```

The workflow runs `npm publish --access public` for each package with `--tolerate-republish` so existing packages are a no-op.
To move a single lexicon without a full release:

```bash
just release-lexicon <name> patch
```

The workflow triggers on `chant-v*` and `lexicon-*-v*` tags. A bare `v<version>`
tag matches neither and silently does nothing.

Publishing itself is `scripts/publish-packages.sh`. It enumerates every
non-private workspace package, so a new lexicon is picked up with no workflow
edit. A package already at its version on the registry is skipped, which makes
re-running the workflow a safe way to recover a partial release.

<Aside type="caution" title="First-time scoped packages">
`npm publish --access public` may land as **private** on the first publish of a scoped package. After the workflow completes, check [npmjs.com/org/intentius](https://www.npmjs.com/org/intentius) and toggle the package to public if needed. Subsequent publishes will stay public.
Expand All @@ -126,15 +167,25 @@ The workflow runs `npm publish --access public` for each package with `--tolerat

With 0.x semver, `^0.0.13` pins to **exactly** `0.0.13` (not `>=0.0.13 <0.1.0`). This means your lexicon version must match the core version at publish time. All packages in the monorepo are versioned together — bump them in lockstep before tagging.

## Why the root dependency matters
## Why the root dependency exists

npm workspace resolution only installs packages that have at least one dependent in the workspace graph. The root `package.json` dependency ensures that `packages/core` can dynamically import your lexicon via:
`chant dev onboard` adds your lexicon to the root `package.json` dependencies so
that `packages/core` can dynamically import it:

```typescript
import(`@intentius/chant-lexicon-${name}`)
```

Without this, the lexicon resolves fine during its own tests but fails when loaded by the CLI.
Resolution does not actually depend on that entry. The root
`workspaces: ["lexicons/*"]` glob symlinks every lexicon into `node_modules`
whether or not it is listed, which is why three lexicons sat unlisted for
months without anything breaking. The entry is an explicit declaration of what
core may import, not the mechanism that makes the import work.

It is kept complete anyway, and
`packages/core/src/codegen/lexicon-wiring.test.ts` fails if a lexicon is
missing from it — a hand-maintained list with no gate is how this drifted in
the first place.

## Why prepack steps are needed in Docker

Expand Down
Loading
Loading