본문 바로가기
Tips/Git

[Git] Github Actions + Test Coverage (jest)

by _S0_H2_ 2024. 4. 26.
728x90
반응형

현재 테스트 커버리지는 아직 많이 남아있는 test case로 인해 현저히 낮은 상태이다..ㅎ

 

 

git workflow에서 build, lint 등등이 성공하더라도

test coverage threshold보다 낮으면 fail을 내기 위해서 아래와 같은 설정을 추가하였다.

(이외에도 1, 2 방법들이 있는 듯)

 

- package.json

 "scripts": {
 	...
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    ...
  },
"coverageThreshold": {
      "./src/": {
        "statements": 50,
        "branches": 50,
        "functions": 50,
        "lines": 50
      }
    },
"coverageReporters": [
  "lcov",
  "text"
],

 

 

https://data-gardner.tistory.com/180

 

[Git] Github Actions CI 적용&Test

devel, main에서 각각의 workflow를 따를 예정인데 이를 github actions를 통해 진행해보고자 한다.feature branch에서 개발이 끝나고 devel로 PR이 생성될 때 또는 devel branch로 push가 일어났을 때자동으로 테스

data-gardner.tistory.com

이전에 yml로 test를 뒀었는데

이번에는 coverage까지 적용하기 위해 yml의 test 부분을 수정해주었다.

 

.github/workflows/ci.yml

      - name: Test
        env:
          CI: true
        run: npm run test:cov

 

 

그냥 npm run test로 하면 threshold보다 낮아도 다음 단계를 진행한다!!





추가로 slack으로 CI결과를 받을 수 있도록 다음과 같이 진행했다.

https://systorage.tistory.com/entry/Github-Actions-GitHub-Actions%EC%9D%84-%EC%9D%B4%EC%9A%A9%ED%95%9C-Slack-%EC%95%8C%EB%A6%BC-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0

 

[Github Actions] GitHub Actions을 이용한 Slack 알림 설정하기

GitHub Actions는 CI/CD를 위한 강력한 도구이다. 소프트웨어 개발 과정에서 다양한 작업들을 자동화할 수 있는데, 그 중 하나가 빌드나 테스트의 성공 및 실패를 Slack으로 알림 보내는 것이다. 이 글

systorage.tistory.com

 

728x90
반응형

'Tips > Git' 카테고리의 다른 글

[Git] worktree 사용하기  (0) 2024.07.18
[Git] Github Actions CI 적용&Test  (0) 2024.04.24
[Git] 04. cherry-pick  (0) 2021.06.10
[Git] 03. branch 생성, merge, rebase  (0) 2021.06.10
[Git] 02. add, commit, push 취소하기  (0) 2021.06.10