Skip to content

chore: SW-1779 migrate Zephyr scripts to internal ts-lib-zephyr-nodejs#161

Open
owilliams-tetrascience wants to merge 5 commits into
mainfrom
claude/gifted-babbage-b7b42e
Open

chore: SW-1779 migrate Zephyr scripts to internal ts-lib-zephyr-nodejs#161
owilliams-tetrascience wants to merge 5 commits into
mainfrom
claude/gifted-babbage-b7b42e

Conversation

@owilliams-tetrascience

@owilliams-tetrascience owilliams-tetrascience commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Tech-debt migration (SW-1779): replaces the repo's bespoke Zephyr Scale integration — ~1,350 lines of hand-rolled fetch, auth, timeouts, pagination, and error handling across the Zephyr scripts — with the shared internal ts-lib-zephyr-nodejs library (ZephyrClient + helpers). Net −310 lines.

This repo is unlike the reference migration (a Playwright/private repo): Storybook stories run as Vitest browser tests, opt in via parameters.zephyr.testCaseId (kept — 108 stories untouched), and reporting stays JUnit-XML-based. So the approach is incremental adoption — the thin wrapper scripts keep all repo-specific logic and only the HTTP layer moves to the library.

What changed

  • scripts/zephyr/report-zephyr-results.ts / sync-storybook-zephyr.ts — all Zephyr HTTP now routes through the library's ZephyrClient. Repo-specific logic stays local: JUnit parsing, story parsing/write-back, the testCaseId schema, per-branch cycle find-or-create (SW-R33 for main), folder mapping, and reusable-test-case selection.
  • Per-step screenshots — the reporter now embeds each story's screenshot as a base64 <img> into every step of the execution (buildStepsPayload + putExecutionSteps), replacing the old S3-upload + URL-in-comment path.
  • Screenshot transport — deleted scripts/upload-test-screenshots.ts; storybook-tests.yml now ships test-results/screenshots/** in the storybook-junit-results artifact and the S3 upload + AWS OIDC steps (and id-token permission) are removed. Dropped the now-unused @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner devDependencies.
  • Dependency wiring — the library is published only to the internal registry, so it is kept out of package.json/yarn.lock to preserve this repo's public-registry invariant (external contributors keep installing from npmjs). It is installed as a leaf tarball inside the two Zephyr workflows (npm pack + extract — deliberately not npm install --no-save, which corrupts the Yarn node_modules).
  • Docs updated in AGENTS.md and CONTRIBUTING.md (referenced as an internal library, no links).

Reviewer notes / before merge

  • New repo secrets required: JFROG_ARTIFACTORY_NPM_VIRTUAL_URL and JFROG_ARTIFACTORY_READ_NPM_AUTH. The CI auth line is written as npm _auth (base64 identity) — please confirm the secret's format matches, or the pack step needs a one-line _authToken tweak.
  • Live validation pending: verified locally via yarn typecheck, full yarn lint, all 70 zephyr unit tests, and an offline buildStepsPayload check (base64 <img> on every step). An end-to-end run against a real Zephyr cycle (per-step screenshots visible in the UI) should be done via the zephyr_sync label + a Storybook Tests run.
  • No src/ (published library) code changed — this is dev-tooling only, so no version bump is expected.

🤖 Generated with Claude Code

Replace the repo's bespoke Zephyr Scale integration (hand-rolled fetch,
auth, timeouts, pagination, error handling) with the shared internal
ts-lib-zephyr-nodejs library, per SW-1779 (tech debt).

- report-zephyr-results.ts / sync-storybook-zephyr.ts now route all
  Zephyr HTTP through the library's ZephyrClient. Repo-specific logic
  (JUnit parsing, story parsing/write-back, testCaseId schema, cycle
  find-or-create, folder mapping, reuse selection) stays local.
- Reporter now embeds each story's screenshot as a base64 <img> into
  every step of the execution (buildStepsPayload + putExecutionSteps),
  replacing the previous S3-upload + URL-in-comment path.
- Screenshot transport: delete upload-test-screenshots.ts; ship
  test-results/screenshots/** in the storybook-junit-results artifact;
  drop the S3 upload + AWS OIDC steps from storybook-tests.yml. Remove
  the now-unused @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner
  devDependencies.
- The library is published only to the internal registry, so it is kept
  out of package.json/yarn.lock (preserving the public-registry
  invariant) and installed as a leaf tarball inside the two Zephyr
  workflows. Requires JFROG_ARTIFACTORY_NPM_VIRTUAL_URL and
  JFROG_ARTIFACTORY_READ_NPM_AUTH secrets.
- Docs updated in AGENTS.md and CONTRIBUTING.md.

Refs: SW-1779

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 1, 2026 18:48
@owilliams-tetrascience owilliams-tetrascience requested review from a team as code owners July 1, 2026 18:48
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ts-lib-ui-kit-storybook Ready Ready Preview, Comment Jul 1, 2026 7:52pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the repository’s Zephyr Scale CI tooling from bespoke fetch-based HTTP calls (and S3-hosted screenshot links) to the shared internal ts-lib-zephyr-nodejs (ZephyrClient + helpers), while keeping repo-specific Storybook/JUnit parsing and story write-back logic in place.

Changes:

  • Refactored Zephyr provisioning + reporting scripts to use ZephyrClient and helper utilities, reducing custom HTTP/auth/pagination logic.
  • Replaced S3 screenshot upload/linking with embedding per-story screenshots directly into Zephyr execution steps (base64 <img>).
  • Updated GitHub Actions workflows to package/extract the internal Zephyr library from JFrog at runtime and to ship screenshots in the test-results artifact; removed AWS OIDC + S3 upload path and related dependencies.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Removes/updates AWS SDK lock entries consistent with dropping S3 screenshot upload deps.
scripts/zephyr/sync-storybook-zephyr.ts Routes Zephyr API calls through ZephyrClient and uses library folder/steps helpers.
scripts/zephyr/report-zephyr-results.ts Reports executions via ZephyrClient and embeds screenshots into each execution step.
scripts/upload-test-screenshots.ts Deleted (S3 upload + screenshot URL mapping no longer used).
package.json Drops S3-related AWS SDK devDependencies.
CONTRIBUTING.md Documents the new internal-library-based Zephyr integration at a high level.
AGENTS.md Adds detailed guidance for CI/local installation strategy for ts-lib-zephyr-nodejs and the new screenshot flow.
.github/workflows/zephyr-sync-storybook.yml Adds JFrog leaf-tarball install step for ts-lib-zephyr-nodejs before running sync.
.github/workflows/zephyr-report-results.yml Adds JFrog leaf-tarball install step for ts-lib-zephyr-nodejs before reporting.
.github/workflows/storybook-tests.yml Removes AWS OIDC/S3 upload and uploads screenshots in the JUnit artifact instead.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/zephyr-report-results.yml Outdated
Comment thread .github/workflows/zephyr-sync-storybook.yml Outdated
Comment thread scripts/zephyr/sync-storybook-zephyr.ts Outdated
Resolve CodeQL actions/untrusted-checkout (critical): the workflow_run-
triggered report job is privileged (ZEPHYR_TOKEN + JFrog secrets) and
checks out workflow_run.head_sha. Require the triggering run to come from
this repository so the checked-out ref is always trusted, never untrusted
fork code. Mirrors the same-repo guard already used in
zephyr-sync-storybook.yml.

Refs: SW-1779

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- JFrog npmrc auth: normalize the registry host (strip trailing slash)
  and always emit `//<host>/:_auth=...` so authentication works whether
  or not the secret URL ends with a slash.
- Root-folder detection in sync-storybook-zephyr now matches
  `parentId === null` instead of a falsy check, so a folder id of 0 is
  never mistaken for a root folder.

Refs: SW-1779

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The unit vitest project includes scripts/**/*.test.ts, and those tests
import the Zephyr scripts. With a static import of the JFrog-only
ts-lib-zephyr-nodejs (which is not installed in the publish/CI jobs, only
in the two Zephyr workflows), Vite's import-analysis failed to resolve it
at test-collection time and broke the publish/build jobs.

Load the library through a runtime dynamic import whose specifier is held
in a variable (so bundlers/Vitest can't statically resolve it) and keep
only type-only imports at module scope. The pure parsing/cache helpers the
unit tests exercise never reach the client code path, so the suite now
loads without the package installed; the library is loaded only when a real
Zephyr run reaches the reporting/provisioning code.

Also drop the `#!/usr/bin/env tsx` shebangs (the scripts run via `npx tsx`,
not directly) — Vite prepended its client import onto the shebang line,
causing a parse error once resolution succeeded.

Refs: SW-1779

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
JFROG_ARTIFACTORY_NPM_VIRTUAL_URL is an environment-scoped secret
(artifactory-prod), so it does not resolve in the Zephyr jobs (which do
not bind that environment). The virtual registry URL is infra info, not a
credential, so hardcode it and keep only the org-level
JFROG_ARTIFACTORY_READ_NPM_AUTH token as a secret.

Refs: SW-1779

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 94.84% (🎯 83%)
🟰 ±0%
20964 / 22104
🟢 Statements 94.84% (🎯 83%)
🟰 ±0%
20964 / 22104
🟢 Functions 93.59% (🎯 74%)
🟰 ±0%
920 / 983
🟢 Branches 89.4% (🎯 81%)
🟰 ±0%
3933 / 4399
File CoverageNo changed files found.
Generated in workflow #893 for commit 817a82c by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants