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: 7 additions & 2 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ workspaces:
assert_match version.to_s, shell_output("#{bin}/sentry --version").chomp
end
end
# No preReleaseCommand: Craft bumps package.json through the npm target.
packages/logger:
# Standalone npm libraries. Each is released on its own, with
# `<name>@<version>` tags and `release/<name>/<version>` branches, and
# `merge-jobs.yml` packs every one of them. To publish another package
# from `packages/`, add its directory name here and to release.yml's
# `product` options. No preReleaseCommand:
# Craft bumps package.json through the npm target.
packages/{http,logger}:
changelog:
policy: auto
releaseBranchPrefix: "release/{{workspaceName}}"
Expand Down
78 changes: 57 additions & 21 deletions .github/workflows/merge-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,51 @@ name: Post-merge tasks

on:
push:
branches: ["main", "release/*", "release/logger/**"]
branches: ["main", "release/**"]
workflow_dispatch:

permissions:
contents: read
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

jobs:
build-publish:
# Every Craft workspace without its own artifact provider is an npm
# library whose tarball this workflow builds.
discover-packages:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.packages.outputs.matrix }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: "package.json"

# The same major version as release.yml's getsentry/craft@v3.
- name: Install Craft
run: npm install --global @sentry/craft@3 # zizmor: ignore[adhoc-packages]

- name: List packages
id: packages
run: node scripts/npm-library-workspaces.mjs

package:
Comment thread
sentry-junior[bot] marked this conversation as resolved.
Resolved
needs: discover-packages
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.discover-packages.outputs.matrix) }}
name: Package ${{ matrix.name }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
Expand All @@ -20,34 +55,35 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: "package.json"
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm --filter '@sentry/mcp-core...' --filter @sentry/logger --if-present run build
env:
WORKSPACE: ${{ matrix.workspace }}
run: pnpm --filter "{./$WORKSPACE}..." --if-present run build

- name: Run linter
run: pnpm lint

- name: Run tests
run: pnpm test:ci

- name: Package logger
working-directory: packages/logger
- name: Package
working-directory: ${{ matrix.workspace }}
run: pnpm pack --pack-destination dist

- name: Archive artifacts
- name: Upload tarball
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/packages/logger/dist/*.tgz
name: npm-${{ matrix.name }}
path: ${{ matrix.workspace }}/dist/*.tgz
if-no-files-found: error

# Craft reads every tarball from one artifact named after the commit.
archive:
needs: package
runs-on: ubuntu-latest

- name: Publish Test Report
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857
if: ${{ !cancelled() }}
steps:
- name: Archive artifacts
uses: actions/upload-artifact/merge@v4
with:
report_paths: "**/*.junit.xml"
comment: false
name: ${{ github.sha }}
pattern: npm-*
delete-merged: true
31 changes: 7 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ on:
workflow_dispatch:
inputs:
product:
description: Product to release
description: Package to release, by its directory under packages/
required: true
type: choice
default: cli
# One per .craft.yml workspace; scripts/workflow-policy.test.mjs
# checks that they match.
options:
- cli
- http
- logger
bump:
description: "Version bump: auto (from commits), pre (next prerelease), or an explicit bump type"
Expand Down Expand Up @@ -61,34 +64,14 @@ jobs:
with:
run_install: false

- name: Resolve release workspace
id: release
env:
PRODUCT: ${{ inputs.product }}
run: |
# Each product maps to a `.craft.yml` workspace. The `cli` release
# also publishes @sentry/mcp-server at the same version.
case "$PRODUCT" in
cli)
workspace=packages/cli
;;
logger)
workspace=packages/logger
;;
*)
echo "::error::Unsupported product: $PRODUCT"
exit 1
;;
esac

echo "workspace=$workspace" >> "$GITHUB_OUTPUT"

- name: Prepare release
uses: getsentry/craft@v3
env:
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
with:
workspace: ${{ steps.release.outputs.workspace }}
# The `cli` release also publishes @sentry/mcp-server at the same
# version.
workspace: packages/${{ inputs.product }}
# An exact version wins over the bump. Craft bumps from the
# workspace's latest release tag, or from its package.json version
# before the first tag.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Test

on:
push:
branches: [main]
# Release branches too, so Craft finds the checks on a release commit.
branches: [main, "release/**"]
pull_request:
merge_group:

Expand Down
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ toolkit/
├── packages/
│ ├── cli/ # Sentry CLI (see packages/cli/AGENTS.md)
│ ├── codemod-cli3to4/ # @getsentry/cli3to4 codemod: CLI v3 → v4 (Codemod Registry)
│ ├── http/ # HTTP response cache, body codec, and retries (@sentry/http on npm)
│ ├── logger/ # Structured logger (@sentry/logger on npm)
│ ├── toolkit-core/ # Shared CLI/MCP primitives
│ ├── mcp-core/ # Core MCP implementation (private)
Expand Down
4 changes: 3 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ For package-specific rules, see the root [AGENTS.md](../AGENTS.md) and the
[CLI AGENTS.md](../packages/cli/AGENTS.md). `packages/toolkit-core/` contains
shared primitives used by both products. `packages/logger/` is the structured
logger the CLI uses, published to npm as `@sentry/logger`; see its
[README](../packages/logger/README.md).
[README](../packages/logger/README.md). `packages/http/` is the HTTP response
cache, body codec, and retry logic, published to npm as `@sentry/http`; see
its [README](../packages/http/README.md).

## Ownership

Expand Down
1 change: 1 addition & 0 deletions docs/architecture/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The project is a pnpm monorepo with clear separation of concerns:
```
packages/
├── cli/ # Sentry CLI, including the `sentry mcp` stdio server
├── http/ # HTTP response cache, body codec, and retries (@sentry/http on npm)
├── toolkit-core/ # Shared CLI/MCP primitives
├── mcp-core/ # Core MCP implementation (private package)
├── mcp-server/ # stdio transport (@sentry/mcp-server on npm)
Expand Down
24 changes: 23 additions & 1 deletion docs/operations/github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ and docs when `SENTRY_CLIENT_ID` is available.

### test.yml

Runs on pushes to `main`, pull requests, and merge queue entries. Discovery
Runs on pushes to `main` and release branches, pull requests, and merge queue
entries. Discovery
reads pnpm workspace projects and their package scripts. Pull requests check
changed projects, their workspace consumers, and semantic dependencies (the CLI
docs depend on `sentry`). Root-level changes and non-PR events check every
Expand Down Expand Up @@ -154,6 +155,27 @@ token pushes the branch and opens the PR, so `test.yml` runs on it.
branch by hand are lost.
- The PR is never merged automatically.

### release.yml and merge-jobs.yml

`release.yml` prepares a release of one package with Craft. Its `product`
choice is a directory under `packages/`, such as `cli`, `http`, or `logger`.
GitHub cannot fill a choice from `.craft.yml`, so
`scripts/workflow-policy.test.mjs` fails when the options and the `packages/`
workspaces in `.craft.yml` differ.

`merge-jobs.yml` runs on `main` and on every release branch. It lists the
Craft workspaces that use the default artifact provider with
`scripts/npm-library-workspaces.mjs`, packs each one in a parallel matrix job,
and merges the tarballs into the artifact named after the commit, where Craft
reads them. `test.yml` runs the tests on the same commits. The CLI sets its own
artifact provider: it ships platform binaries, a Homebrew formula, the docs
site, and `@sentry/mcp-server` along with its npm package, all built by
`cli-build.yml`.

To publish another package from `packages/`, add its directory name to the
`packages/{...}` workspace key in `.craft.yml` and to `release.yml`'s
`product` options.

## Package CI checks

Add a check for one workspace package to that package's `package.json`, not to
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"scripts": {
"docs:check": "node scripts/check-doc-links.mjs",
"test:ci-projects": "node --test scripts/ci-projects.test.mjs scripts/check-workspace-deps.test.mjs scripts/cli-nightly-version.test.mjs scripts/cli-nightly-watchdog.test.mjs scripts/platform-setup-pr.test.mjs scripts/codemod-version-changed.test.mjs scripts/cloudflare-deployment.test.mjs scripts/deploy-workflow.test.mjs scripts/migrate-cloudflare-token.test.mjs scripts/oxc-config.test.mjs scripts/cli-lint-rules.test.mjs scripts/workflow-policy.test.mjs scripts/tsconfig-policy.test.mjs",
"test:ci-projects": "node --test scripts/ci-projects.test.mjs scripts/check-workspace-deps.test.mjs scripts/cli-nightly-version.test.mjs scripts/cli-nightly-watchdog.test.mjs scripts/platform-setup-pr.test.mjs scripts/codemod-version-changed.test.mjs scripts/npm-library-workspaces.test.mjs scripts/cloudflare-deployment.test.mjs scripts/deploy-workflow.test.mjs scripts/migrate-cloudflare-token.test.mjs scripts/oxc-config.test.mjs scripts/cli-lint-rules.test.mjs scripts/workflow-policy.test.mjs scripts/tsconfig-policy.test.mjs",
"dev": "pnpm --filter '@sentry/mcp-cloudflare...' --if-present run build && dotenv -e .env -e .env.local -- pnpm --parallel --filter @sentry/mcp-cloudflare --filter @sentry/mcp-core --filter @sentry/mcp-server-mocks --if-present run dev",
"dev:stdio": "pnpm --filter '@sentry/mcp-core...' --if-present run build 1>&2 && dotenv -e .env -e .env.local -- pnpm --silent --dir packages/cli run cli mcp",
"build": "dotenv -e .env -e .env.local -- pnpm -r --filter '!sentry' --filter '!sentry-cli-docs' --if-present run build",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"@hono/node-server": "^2.1.6",
"@sentry/api": "catalog:",
"@sentry/core": "catalog:",
"@sentry/http": "workspace:*",
"@sentry/logger": "workspace:*",
"@sentry/mcp-core": "workspace:*",
"@sentry/node": "catalog:",
Expand Down
14 changes: 3 additions & 11 deletions packages/cli/src/lib/response-cache-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Filesystem {@link CacheStore} for the CLI's response cache.
*
* Each entry is one JSON file, `<key>.v2.json`, written atomically. Its body
* holds the bytes from the toolkit-core codec (zstd, or brotli on Node < 22.15)
* holds the bytes from the `@sentry/http` codec (zstd, or brotli on Node < 22.15)
* as base64. A byte budget over file sizes is enforced by a cleanup sweep that
* runs on a share of writes: it deletes expired entries, then evicts the least
* recently used ones. A cache hit touches the file's mtime, so mtime is the
Expand Down Expand Up @@ -30,13 +30,8 @@ import {
writeFile,
} from "node:fs/promises";
import { join } from "node:path";
import {
type CacheEntry,
type CacheStore,
classifyUrl,
FALLBACK_TTL_MS,
} from "@sentry/api/client";
import type { BodyEncoding } from "@sentry/toolkit-core/response-cache/codec";
import { classifyUrl, FALLBACK_TTL_MS } from "@sentry/api/client";
import type { BodyEncoding, CacheEntry, CacheStore } from "@sentry/http";
import pLimit from "p-limit";

import { logger } from "./logger.js";
Expand Down Expand Up @@ -107,8 +102,6 @@ export type FileStoreOptions = {
};

export type FileStore = CacheStore & {
/** Remove the entry under `key`, in either format. */
delete(key: string): Promise<void>;
/** Remove every entry. */
clear(): Promise<void>;
/** Delete expired entries, then evict until within the byte budget. */
Expand Down Expand Up @@ -199,7 +192,6 @@ function fromLegacy(legacy: LegacyEntry): ParsedEntry {
entry: {
url: legacy.url,
identity: legacy.identity ?? "",
tier: classifyUrl(legacy.url),
status: legacy.status,
headers: legacy.headers,
body: { bytes, encoding: "identity", rawSize: bytes.byteLength },
Expand Down
Loading
Loading