Repository navigation
test: enforce the Bun coverage threshold - #800
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #683. main 기준의 독립 PR이며, 먼저 병합되어야 하는 PR은 없습니다.
요약
main의 Bun 커버리지 100% 게이트가 실제로는 동작하지 않았습니다.
bunfig.toml의coverageThreshold가 단수형 키(line,function,statement)로 적혀 있는데, Bun은 모르는 키를 경고 없이 무시합니다. 그래서bun test는 커버리지와 관계없이 exit 0으로 끝났고, pre-commit hook과 CI의 Bun 단계는 커버리지 때문에 실패한 적이 없습니다. 지금 main은 실제로 함수·줄 모두 100%지만, 앞으로 커버리지가 줄어도 잡지 못하는 상태였습니다.재현 (Bun 1.4.3)
함수 2개 중 1개만 실행하는 fixture(함수 50%, 줄 66.67%)에서
bun test를 실행했습니다.coverageThreshold{ line = 1.0, function = 1.0, statement = 1.0 }(main){ lines = 1.0, functions = 1.0, statements = 1.0 }1.0Bun 문서(https://bun.com/docs/test/code-coverage)도 복수형 키를 씁니다.
변경
bunfig.toml: 기준을{ lines = 1.0, functions = 1.0, statements = 1.0 }로 고쳤습니다.bunfig.toml에서coverage = true를 빼고, 루트test스크립트의 Bun 단계를bun test --coverage로 바꿨습니다. 기준이 실제로 적용되면coverage = true상태에서는 파일 하나만 실행하는bun test <file>도 저장소 전체 기준에 걸려 항상 실패합니다. 예를 들어bun test packages/__tests__/changepack-paths.test.ts는 17개 테스트가 모두 통과해도 함수 18.13%, 줄 33.49%로 exit 1이 됩니다. 그래서 커버리지는 hook과 CI가 실행하는bun run test에서만 켭니다.packages/__tests__/coverage-threshold.test.ts에 테스트 5개를 추가했습니다.bunfig.toml의 기준이 복수형 키이고 값이 모두 1인지 확인합니다.test스크립트가 실행하는 모든bun test에--coverage가 붙어 있는지 확인합니다. 중간에bun run으로 부르는 스크립트도 따라갑니다.bunfig.toml의 설정을 그대로(저장소 파일을 가리키는root,preload만 빼고) 임시 프로젝트에 넣고bun test --coverage를 실제로 실행합니다. 덮이지 않은 줄이 있으면 exit 1, 덮이지 않은 함수가 있으면 exit 1, 모두 덮이면 exit 0이어야 합니다.CI workflow는 바꾸지 않았습니다. CI는 그대로
bun run test를 실행하므로 새 스크립트가 적용됩니다. 패키지 동작은 바뀌지 않고, 관리 패키지를 바꾸지 않으므로 changepack은 없습니다.남는 한계
statements는 Bun이 받기만 하고 아직 검사하지 않습니다(Bun 문서에 명시). 실제로 검사되는 것은 줄과 함수입니다.bun test --coverage <file>로 볼 수 있으며, 이때 전체 기준에 걸려 실패하는 것은 정상입니다.다른 PR과의 관계
bunfig.toml을 바꿉니다. 이 PR이 먼저 병합되면preload줄 바로 아래에서 충돌하므로, 두 변경을 모두 유지하면 됩니다.All files행으로 확인하도록 작업자들에게 알렸습니다.검증 (Windows, Bun 1.4.3, Node 26.12.0, main 770aaac 기준)
coverage = true,bun test)에서 새 테스트를 실행하면 5개 중 4개가 실패합니다(기준 키,--coverage, 덮이지 않은 줄, 덮이지 않은 함수).test가bun run으로 부르는 스크립트 안의 두 번째bun test에--coverage가 없으면 실패하고, 붙이면 통과합니다.All files | 100.00 | 100.00.