refactor: move utils.ts to utils/index.ts for coverage gate compatibility#18
refactor: move utils.ts to utils/index.ts for coverage gate compatibility#18Longwt123 wants to merge 7 commits into
Conversation
…lity Rename utils.ts → utils/index.ts in k8s, docker, and hooklib packages so source files match the CI coverage gate pattern '**/utils/**'. Add collectCoverageFrom config to jest.config.js in k8s and docker packages to enable coverage reporting. All existing imports resolve unchanged via TS module resolution. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Welcome To opensourceways CommunityHey @Longwt123 , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Linking Issue Notice@Longwt123 , the pull request must be linked to at least one issue. |
There was a problem hiding this comment.
Code Review
This pull request configures Jest test coverage for the docker and k8s packages, and corrects relative import paths in hooklib and k8s. The review feedback suggests improving the Jest configuration by avoiding hardcoded collectCoverage: true to prevent slowing down local test runs, and expanding the coverage scope to include all source files rather than just utility files.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|||||||||||||||||
- Remove collectCoverage: true from jest.config.js (avoid forced coverage on every local run); coverage now opt-in via --coverage flag - Expand collectCoverageFrom to src/**/*.ts (was src/**/utils/**/*.ts) to prevent blind spots in coverage reporting - Add test:coverage script to package.json for explicit CI/local use Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
|||||||||||||||||
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
/check-pr |
Merge Verification Failed@Longwt123, this pr is not mergeable and the reasons are below: Not Enough Labels
Label Usage Tips
|
|
/retest |
|
|||||||||||||||||
|
|||||||||||||||||
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
|||||||||||||||||
k8s/tests/k8s-utils-test.ts: - Add writeContainerStepScript: path return, env escaping, invalid workdir, invalid env key - Add prepareJobScript: path return, mkdir content, empty mounts - Add fixArgs: quoted args, single-quoted shell, plain args - Add sleep: resolves after given ms - Add listDirAllCommand: find command content, shell-quoting - Add mergeObjectMeta: label/annotation merge, throws on undefined metadata - Add useKubeScheduler: true/false/unset env var cases docker/tests/utils-test.ts: - Add checkEnvironment: passes with GITHUB_WORKSPACE set, throws when unset hooklib: add jest infrastructure (jest.config.js, jest.setup.js, tsconfig.test.json) and devDependencies (jest, ts-jest, babel-jest) hooklib/tests/utils-test.ts: - Add writeToResponseFile: string/object/null/undefined values, empty path, missing file, sequential appends - Add getInputFromStdin: mock readline, parse JSON from emitted line root package.json: include hooklib in test script Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
|||||||||||||||||
Add index.spec.ts alongside each utils/index.ts so the CI coverage gate
(vitest, include: **/*.{test,spec}.ts) can discover and run them:
- packages/k8s/src/k8s/utils/index.spec.ts: generateContainerName, fixArgs,
sleep, listDirAllCommand, useKubeScheduler, mergeObjectMeta, writeRunScript,
writeContainerStepScript, prepareJobScript, readExtensionFromFile,
mergeContainerWithOptions, mergePodSpecWithOptions
- packages/docker/src/utils/index.spec.ts: sanitize, fixArgs,
optionsWithDockerEnvs, checkEnvironment
- packages/hooklib/src/utils/index.spec.ts: writeToResponseFile
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
|||||||||||||||||
…inerStepScript
'/too-short'.split('/').slice(-2) yields ['', 'too-short'] (length 2),
which does not trigger the throw. Use 'tooshort' (no slash) instead:
'tooshort'.split('/').slice(-2) = ['tooshort'] (length 1) → throws.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
CLA Signature PassLongwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
|||||||||||||||||
描述
修改UT相关路径(门禁只检查特殊路径特殊名称的测试文件)
utils.ts→utils/index.tsin k8s, docker, hooklib packages so source files match CI coverage gate pattern**/utils/**collectCoverageFrom: ['src/**/utils/**/*.ts']to jest.config.js in k8s and docker packages to enable coverage reportingutils/index.ts相关 Issue
resolve https://github.com/opensourceways/backlog/issues/1102
变更类型