Skip to content

refactor: move utils.ts to utils/index.ts for coverage gate compatibility#18

Open
Longwt123 wants to merge 7 commits into
release/no_volumesfrom
feature/surface-errors-no-volumes-v2
Open

refactor: move utils.ts to utils/index.ts for coverage gate compatibility#18
Longwt123 wants to merge 7 commits into
release/no_volumesfrom
feature/surface-errors-no-volumes-v2

Conversation

@Longwt123

@Longwt123 Longwt123 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

描述

修改UT相关路径(门禁只检查特殊路径特殊名称的测试文件)

  • Rename utils.tsutils/index.ts in k8s, docker, hooklib packages so source files match CI coverage gate pattern **/utils/**
  • Add collectCoverageFrom: ['src/**/utils/**/*.ts'] to jest.config.js in k8s and docker packages to enable coverage reporting
  • All existing imports unchanged — TypeScript module resolution auto-resolves utils/index.ts

相关 Issue

resolve https://github.com/opensourceways/backlog/issues/1102

变更类型

  • Bug 修复
  • 新功能
  • 代码重构
  • 文档更新
  • 样式改进
  • 性能优化
  • 测试相关
  • 其他

…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>
@opensourceways-bot

Copy link
Copy Markdown

Welcome To opensourceways Community

Hey @Longwt123 , thanks for your contribution to the community.

Bot Usage Manual

I'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 Guide

If you have any questions, please contact the SIG: infratructure ,
and any of the maintainers: @GeorgeCao-hw, @TangJia025, @pkking, @zhongjun2 ,
and any of the committers: @GeorgeCao-hw, @Goalina, @Hourunze1997, @JavaPythonAIForBAT, @KadenZhang3321, @LiYanghang00, @ccijunk, @drizzlezyk, @githubliuyang777, @pkking, @rosecoffe, @tfhddd, @yao-xiaobai, @zhongjun2, @zkhzkhz .

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown

Linking Issue Notice

@Longwt123 , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread packages/docker/jest.config.js Outdated
Comment thread packages/k8s/jest.config.js Outdated
@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

- 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>
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@Longwt123

Copy link
Copy Markdown
Collaborator Author

/check-pr

@opensourceways-bot

Copy link
Copy Markdown

Merge Verification Failed

@Longwt123, this pr is not mergeable and the reasons are below:

Not Enough Labels
  • the pull request needs 1 approved labels, but now gets 0.
  • the pull request needs 1 gate_check_pass labels, but now gets 0.
  • the pull request needs 2 lgtm labels, but now gets 0.
Label Usage Tips
  • gate_check_pass: The code compilation/build/testcase check job is passed.

@Longwt123

Copy link
Copy Markdown
Collaborator Author

/retest

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

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>
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@socket-security

socket-security Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedjest@​30.4.21001007092100
Added@​babel/​preset-env@​7.29.7971007797100
Added@​babel/​core@​7.29.7971008096100
Addedbabel-jest@​30.4.11001008291100
Addedts-jest@​29.4.11971009491100

View full report

@socket-security

socket-security Bot commented Jun 30, 2026

Copy link
Copy Markdown

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.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm yargs is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/jest@30.4.2npm/yargs@17.7.3

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/yargs@17.7.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

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>
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT测试覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

…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>
@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

Longwt123, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown
检查项 状态
敏感信息扫描
安全编码扫描
漏洞扫描
开源license合规扫描
UT覆盖率
开发阶段设计文档检查
流水线链接 点击跳转查看日志

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants