[jsweep] Clean action_setup_otlp.cjs — add comprehensive test coverage#26986
[jsweep] Clean action_setup_otlp.cjs — add comprehensive test coverage#26986
Conversation
35 test cases covering: - OTEL endpoint set/unset logging behavior - sendJobSetupSpan call and propagation - SETUP_START_MS parsing (valid, missing, non-numeric) - INPUT_TRACE_ID handling (lowercase normalization, hyphen form, precedence) - INPUT_JOB_NAME normalization to underscore form - GITHUB_OUTPUT file writing (valid/invalid trace IDs) - GITHUB_ENV file writing (trace ID, span ID, job start ms) - Error propagation from sendJobSetupSpan Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds comprehensive Vitest coverage for action_setup_otlp.cjs, ensuring the setup OTLP span workflow and trace/span propagation behaviors are exercised across key environment-variable and output-writing scenarios.
Changes:
- Introduces
action_setup_otlp.test.cjswith broad coverage of logging, input normalization, and file propagation (GITHUB_OUTPUT/GITHUB_ENV). - Uses a shared CJS-module export patching pattern to mock
sendJobSetupSpanwhile validating the wrapper’s behavior. - Verifies behavior across endpoint configured/unconfigured paths and error propagation.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/action_setup_otlp.test.cjs | Adds a dedicated test suite covering env/input normalization, logging, and output/env file writes for action_setup_otlp.cjs. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
| it("should pass NaN when SETUP_START_MS is not a number", async () => { | ||
| process.env.SETUP_START_MS = "not-a-number"; | ||
|
|
||
| await run(); | ||
|
|
||
| const [options] = /** @type {[{startMs: number}]} */ mockSendJobSetupSpan.mock.calls[0]; | ||
| expect(isNaN(options.startMs)).toBe(true); |
| // Provide fresh temp files so GITHUB_OUTPUT and GITHUB_ENV writes are isolated | ||
| const ts = Date.now(); | ||
| outputFile = join(tmpdir(), `test_github_output_${ts}`); | ||
| envFile = join(tmpdir(), `test_github_env_${ts}`); | ||
| writeFileSync(outputFile, ""); | ||
| writeFileSync(envFile, ""); |
🧪 Test Quality Sentinel ReportTest Quality Score: 69/100
Test Classification DetailsView all 35 test classifications
Flagged Tests — Requires Review
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 69/100. Test quality is acceptable — 9% of new tests are implementation tests (threshold: 30%). Strong behavioral coverage with real file-write, env-var, and error-propagation assertions. Three minor low-value tests flagged (see comment); no coding-guideline violations.
|
@copilot review all comments https://github.com/github/gh-aw/actions/runs/24597469960/job/71930196552 |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/f020d8a6-e359-445a-986e-1fd168d560ee Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This reverts commit 086d612. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…etup tests Agent-Logs-Url: https://github.com/github/gh-aw/sessions/f020d8a6-e359-445a-986e-1fd168d560ee Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Reviewed all comments and applied both actionable fixes in 6a49a3a: invalid Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
Added a comprehensive test file for
action_setup_otlp.cjs, which had no test coverage despite being a critical Node.js utility used in both action mode and script mode.File:
action_setup_otlp.cjsContext: Pure Node.js (not github-script). Sends a
gh-aw.<jobName>.setupOTLP span and propagates trace/span IDs viaGITHUB_OUTPUTandGITHUB_ENV.Code quality: Already clean with
@ts-check, modern JavaScript, and clear comments. No code changes needed — only test coverage was missing.Test file:
action_setup_otlp.test.cjs35 tests added across 8 describe blocks:
SETUP_START_MSpropagationINPUT_TRACE_IDhandlingINPUT_JOB_NAMEnormalizationGITHUB_OUTPUTwritingGITHUB_ENVwritingTesting approach: Uses the same CJS module-patching pattern as
action_conclusion_otlp.test.cjs— loadssend_otlp_span.cjsfirst, patches its exports, then loads the module under test. Uses real temp files forGITHUB_OUTPUT/GITHUB_ENVwrites (no filesystem mocking needed).✅ Validation Checks
npm run format:cjs): ✓ Passednpm run lint:cjs): ✓ All files use Prettier code stylenpm run typecheck): ✓ No new errors (4 pre-existing errors in unrelated files)npm run test:js -- --no-file-parallelism): ✓ 35/35 passed (4 pre-existing failures in unrelated files unaffected)Warning
The following domain was blocked by the firewall during workflow execution:
invalid.example.invalidTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.