Skip to content

feat!: v3 uploads with the trunk CLI and analytics-cli 1.x (TRUNK-23151) - #158

Merged
acatxnamedvirtue merged 4 commits into
mainfrom
tylerbeebe/trunk-23151-uploader-v3
Nov 19, 2026
Merged

acatxnamedvirtue merged 4 commits into
mainfrom
tylerbeebe/trunk-23151-uploader-v3

Conversation

@acatxnamedvirtue

@acatxnamedvirtue acatxnamedvirtue commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Part of TRUNK-23151

Ready to merge. Everything v3 depends on has shipped: trunk CLI 0.0.14 is on prod, and analytics-cli 1.0.0 is promoted to channel-1.json. Rebased onto main after #159.

v3 installs the trunk CLI and runs it. It no longer downloads trunk-analytics-cli itself. v2 maintenance moves to the new v2.x branch, cut at v2.1.8 (9886de7), and main becomes v3.

What v3 does

  1. Installs the trunk CLI. It downloads trunk-<v>-<platform> from trunk.io/releases/trunk-cli/prod, checks its sha256 against the version's manifest.json, and caches it with @actions/cache.
    • trunk-cli-version: latest reads channel.json. Pinned or latest, the version must be 0.0.14 or later.
  2. Stores the key. It runs trunk auth api-key set, with the key only in TRUNK_ORG_API_KEY.
    • The key is masked and never in argv.
    • It goes into a credential store for that step only (TRUNK_CREDENTIALS_FILE under RUNNER_TEMP), which is removed afterwards.
    • token must be a v2 API key (trunk_v2_...). Organization tokens are refused; they stay on @v2.
  3. Runs trunk flakytests upload or test.
    • Arguments go as an argv array (execFileSync, no shell), as --flag=value.
    • run becomes -- /bin/sh -c "<run>", or cmd.exe /d /s /c on Windows. Those are the shells v2 used, so shell syntax keeps working.
    • The trunk CLI hands analytics-cli 1.x a JWT for upload and the key for test (trunk2#8432).
  4. Picks analytics-cli. cli-version: latest reads only channel-1.json and fails clearly rather than falling back to 0.x. The version goes to the trunk CLI as TRUNK_ANALYTICS_CLI_VERSION. A leading v is dropped.
  5. Keeps from v2:
    • fork pull requests (--allow-forked-pr-uploads with the job's GITHUB_TOKEN, no key);
    • exit code 70 vs passthrough;
    • previous-step-outcome;
    • the summary file;
    • github-annotations, now through trunk flakytests github-annotations.
  6. Every trunk CLI call runs with TRUNK_NO_AUTO_UPDATE=1, and without an inherited TRUNK_API_TOKEN or TRUNK_ORG_API_KEY.

Inputs

  • Removed: public-repo-id, hide-banner, gh-action-ref.
  • Changed:
    • test-collection-id is required.
    • quarantine: false → --disable-quarantining.
    • use-uncloned-repo's broken type: true is now boolean.
  • Added: trunk-cli-version.

The action's own telemetry (protobuf to trunk1 with x-api-token) is removed, along with protobufjs and @actions/github. The trunk CLI reports each run with the stored key (trunk2#8469, in 0.0.14).

Workflows

  • release.yml offers v3. v2 patches are cut from v2.x.
  • pr.yml's staging step sets TRUNK_API_URL for api-key set.
  • pr.yml uploads with the new TRUNK_PROD_API_V2_TOKEN and TRUNK_STAGING_API_V2_TOKEN secrets, v2 API keys with Upload test results. The v2.x branch keeps the organization-token secrets, which analytics-cli 0.17.x needs.

Before releasing (all done)

  • trunk CLI 0.0.14 on prod, cut from trunk2 main with #8432, #8469 and #8640. It is MIN_TRUNK_CLI_VERSION, and the first release with a windows-x64 build.
  • analytics-cli 1.0.0 promoted to channel-1.json. channel.json and GitHub's latest stay on 0.17.0, so @v2 and older pins are unaffected.
  • v2 API key secrets added and used by pr.yml (above).

Testing

  • CI on this head passes against the released versions. On ubuntu, macOS and Windows, v3 resolved trunk CLI latest to 0.0.14, which ran analytics-cli 1.0.0 from channel-1.json. Both the prod and staging uploads succeeded on every leg with the v2 keys, including Windows, whose leg is allowed to fail but didn't. The dry-run job read quarantine with the prod key.
  • pnpm test: 5 suites, 97 tests pass. msw stays at onUnhandledRequest: "error".
  • pnpm build is clean and dist/ is current. trunk check and fmt report no new issues.
  • Earlier, before 0.0.14 existed, I ran the built dist/index.js locally as a dry run against trunk CLI 0.0.13 and analytics-cli 0.17.0. Install, the sha check, the cache layout, the ft upload argv, ft test through /bin/sh -c, and credential cleanup behaved as intended.

Known limit: on Windows, Rust escapes " inside run as \", which cmd.exe may not read as intended. The README says so.

🤖 Generated with Claude Code

acatxnamedvirtue added a commit to trunk-io/flake-farm-staging-fork-prs that referenced this pull request Nov 16, 2026
@main becomes v3 when trunk-io/analytics-uploader#158 merges, which needs a
v2 API key, analytics-cli 1.x and trunk CLI 0.0.14 or later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue added a commit to trunk-io/flake-farm-staging-fork-prs that referenced this pull request Nov 16, 2026
0.17.0 is the release of the 0.17.0-beta.3 the workflows ran. @main becomes
analytics-uploader v3 when trunk-io/analytics-uploader#158 merges, which needs
a v2 API key, analytics-cli 1.x and trunk CLI 0.0.14 or later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
acatxnamedvirtue and others added 3 commits November 18, 2026 19:09
The action installs the trunk CLI from trunk.io/releases/trunk-cli (sha256
checked against the version's manifest), stores the token with
`trunk auth api-key set` (key in TRUNK_ORG_API_KEY only, masked) and runs
`trunk flakytests upload|test` with an argv array, so the trunk CLI hands
analytics-cli 1.x its credential.

- cli-version `latest` resolves from channel-1.json and is passed as
  TRUNK_ANALYTICS_CLI_VERSION; no 0.x fallback.
- New trunk-cli-version input; test-collection-id is required; public-repo-id,
  hide-banner and gh-action-ref are removed.
- quarantine: false maps to --disable-quarantining; true passes nothing.
- run is wrapped as `-- /bin/sh -c <run>` (cmd.exe /d /s /c on Windows).
- The trunk CLI and analytics-cli binaries are cached separately; a per-step
  credential store under RUNNER_TEMP is removed when the step ends; an
  inherited TRUNK_API_TOKEN is dropped.
- github-annotations runs through `trunk flakytests github-annotations`.
- The action's own telemetry, protobufjs and @actions/github are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…UNK-23151)

README and CONTRIBUTING describe the trunk CLI install, the v2 API key
token, the required test collection and the removed inputs. The release
workflow can move v3; the PR smoke test points the staging upload's key
exchange at the staging API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-prefixed versions (TRUNK-23151)

- token must be a v2 API key. An organization token would still upload
  through the gateway's JWT exchange, but analytics-cli 1.x refuses it and
  Trunk is retiring it on v2 (TRUNK-21105); v2 users keep it on @v2.
- trunk-cli-version, pinned or latest, must be 0.0.14 or later: 0.0.13 and
  older store the key unchecked and hand analytics-cli no credential.
- A leading v on cli-version or trunk-cli-version is dropped, since the
  trunk CLI takes plain semver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@acatxnamedvirtue
acatxnamedvirtue force-pushed the tylerbeebe/trunk-23151-uploader-v3 branch from 30e017d to 377f742 Compare November 18, 2026 19:09
v3 refuses organization tokens, so its CI uploads with
TRUNK_PROD_API_V2_TOKEN and TRUNK_STAGING_API_V2_TOKEN. The v2.x branch
keeps the organization token secrets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@dfrankland dfrankland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not asking for this to change, just lamenting) we should switch to vitest 😭

Comment thread src/args.ts
Comment on lines +135 to +136
(entry): entry is [string, string] =>
!dropped.has(entry[0]) && entry[1] !== undefined,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I'm a total dork about this: using is is an unsafe type assertion, you can use flatMap instead to transform the type while filtering

@acatxnamedvirtue
acatxnamedvirtue merged commit 6bc623e into main Nov 19, 2026
8 checks passed
@acatxnamedvirtue
acatxnamedvirtue deleted the tylerbeebe/trunk-23151-uploader-v3 branch November 19, 2026 14:56
trunk-io Bot pushed a commit to trunk-io/toolbox that referenced this pull request Nov 19, 2026
Pins `trunk-io/analytics-uploader` from `@main` to `@v2`.

analytics-uploader's `main` became v3 on 2026-11-19
(trunk-io/analytics-uploader#158). v3 runs analytics-cli 1.x and accepts
only a v2 API key, so every upload here that passes an organization
token now fails with:

> token must be a v2 API key (trunk_v2_...) … or stay on
analytics-uploader@v2 to keep using the organization token.

`@v2` (currently v2.1.8) is the same action this repo ran before the
merge. It still takes the organization token and analytics-cli 0.17.x.
Moving to `@v3` later needs a v2 API key with the Upload test results
permission as the `token`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
trunk-io Bot pushed a commit to trunk-io/toolbox that referenced this pull request Nov 19, 2026
Moves both test-result uploads (`pr.yaml`, `main.yaml`) from the `@v2`
pin back to `trunk-io/analytics-uploader@main`, which is v3 since
trunk-io/analytics-uploader#158.

- **Credentials:** `token: ${{ secrets.TRUNK_PROD_V2_TEST_UPLOAD_TOKEN
}}`, a `trunk` v2 API key with Upload test results. This repo is
**public**, so the org-level secret doesn't reach it: it needs a
**repo-level** secret with this name. v3 refuses the organization token
in `TRUNK_PROD_ORG_API_TOKEN`.
- **Test collection:** `test-collection-id: HilUwBm9`. v3 requires one.
- **CLI version:** unset, so v3 runs the latest analytics-cli 1.x from
`channel-1.json` (1.0.0 today). This repo uploads to production, so it
needs no `TRUNK_API_URL`.

**Merge after the repo secret is added.** Until then the upload fails
with "Missing token". The steps have `continue-on-error`, so the jobs
still pass, but nothing uploads.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants