티스토리 뷰

반응형

[하고 싶은 것]

Jest reporter action 처럼 PR하면 이렇게 테스트 커버리지가 코멘트로 달리는 것을 하고 싶습니다.

 

 

(참고로 Jest는 페이스북에서  유지 관리하는 JavaScript 테스트 프레임 워크입니다. Babel, TypeScript, Node.js, React, Angular 및 Vue.js를 사용하는 프로젝트에서 작동합니다.)

 

그러면 PR할때마다 테스트 커버리지가 보이니까

내가 추가한 피쳐에 테스트를 달고 싶은 동기부여가 더 되지 않을 까 해서요-! 

 

[1]  Slather  페이지 열어주기

 

- cocoapod 써서 xcworkspace 쓰는 플젝 

name: PR

# workflow run이 언제 triggered 될 것인지에 대한 설정.
on:
  # master랑 develop 브랜치에 풀리퀘하면 workflow를 돌리겠음.
  pull_request:
    branches: [ master, develop ]

# workflow 정의.
jobs:
  build-and-test:

    runs-on: self-hosted
    env:
      XCWORKSPACE: MyApp.xcworkspace
      PROJECT: MyApp.xcodeproj
      SCHEME: Model
      CONFIGURATION: Debug
      DESTINATION: platform=iOS Simulator,name=iPad Pro (9.7-inch),OS=latest
      
    steps:
    # step 1
    - name: Checkout source code
      uses: actions/checkout@v2
    
    # step 2
    - name: CocoaPod Install
      run: pod install
      
    # step 3
    - name: Select Xcode
      run: sudo xcode-select -switch /Applications/Xcode.app

    # step 4
    - name: Build and Test
      run: xcodebuild clean build test
           -workspace "$XCWORKSPACE" 
           -scheme "$SCHEME"
           -configuration "$CONFIGURATION" 
           -destination "$DESTINATION" 
           -enableCodeCoverage YES | xcpretty --color
    
  
   # step 5
    - name: Show Test Coverage
      run: slather coverage 
           --html --show
           --workspace "$XCWORKSPACE"
           --scheme "$SCHEME" 
           --configuration "$CONFIGURATION"
           "$PROJECT"

 

 

 - xcodeproj 쓰는 플젝 

name: PR

# workflow run이 언제 triggered 될 것인지에 대한 설정.
on:
  # master랑 develop 브랜치에 풀리퀘하면 workflow를 돌리겠음.
  pull_request:
    branches: [ master, develop ]

# workflow 정의.
jobs:
  build-and-test:

    runs-on: self-hosted
    env:
      PROJECT: Gorgonzola.xcodeproj
      SCHEME: Gorgonzola (iOS)
      CONFIGURATION: Debug
      DESTINATION: platform=iOS Simulator,name=iPad Pro (9.7-inch),OS=latest
      
    steps:
    # step 1
    - name: Checkout source code
      uses: actions/checkout@v2
      
    # step 2
    - name: Select Xcode
      run: sudo xcode-select -switch /Applications/Xcode.app

    # step 3
    - name: Build and Test
      run: xcodebuild clean build test
           -project "$PROJECT" 
           -scheme "$SCHEME"
           -configuration "$CONFIGURATION" 
           -destination "$DESTINATION" 
           -enableCodeCoverage YES | xcpretty --color
    
  
   # step 4
    - name: Show Test Coverage
      run: slather coverage 
           --html --show
           --scheme "$SCHEME" 
           --configuration "$CONFIGURATION"
           "$PROJECT"

 

## 

만약 워크플로우 돌리는 서버에 slather가 설치 안되어있다면 

install slather를 스텝에 추가해주면 됩니다! 

name: PR

# workflow run이 언제 triggered 될 것인지에 대한 설정.
on:
  # master랑 develop 브랜치에 풀리퀘하면 workflow를 돌리겠음.
  pull_request:
    branches: [ master, develop ]
    
# workflow 정의.
jobs:
  build-and-test:
    
    runs-on: macos-latest
    
    steps:
    ...
    # step 4
    - name: Install Slather
      run: sudo gem install slather
     
    # step 5
    - name: Show Test Coverage
      run: slather coverage ....

 

 

[추가] 마켓플레이스에 있는 액션스

 

github.com/marketplace/actions/swift-codecov

 

swift-codecov - GitHub Marketplace

Runs simple analysis on swift test codecov output

github.com


github.com/marketplace/actions/swift-coverage-report

 

Swift Coverage Report - GitHub Marketplace

Report SPM test coverage summary and lcov file

github.com

 

반응형
댓글