|
| 1 | +name: Coverage Badge |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + coverage: |
| 11 | + name: Update Coverage Badge |
| 12 | + runs-on: macos-15 |
| 13 | + environment: "Coverage Badge Env" # Use specified GitHub environment |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout Code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Cache Gems |
| 20 | + uses: actions/cache@v4 |
| 21 | + with: |
| 22 | + path: vendor/bundle |
| 23 | + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} |
| 24 | + restore-keys: | |
| 25 | + ${{ runner.os }}-gems- |
| 26 | + |
| 27 | + - name: Bundle Install |
| 28 | + run: | |
| 29 | + bundle config path vendor/bundle |
| 30 | + bundle install --jobs 4 --retry 3 |
| 31 | + |
| 32 | + - name: Run Tests with Coverage |
| 33 | + env: |
| 34 | + SWIFT_VERSION: "6.0" |
| 35 | + run: bundle exec fastlane sdk_tests_with_coverage |
| 36 | + |
| 37 | + - name: Extract Coverage |
| 38 | + id: coverage |
| 39 | + run: | |
| 40 | + ruby script/extract_coverage.rb |
| 41 | + |
| 42 | + - name: Update Coverage Badge |
| 43 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 44 | + uses: schneegans/[email protected] |
| 45 | + with: |
| 46 | + auth: ${{ secrets.GIST_SECRET }} |
| 47 | + gistID: ${{ secrets.GIST_ID }} |
| 48 | + filename: line-sdk-ios-coverage.json |
| 49 | + label: Coverage |
| 50 | + message: ${{ steps.coverage.outputs.coverage }} |
| 51 | + color: ${{ steps.coverage.outputs.color }} |
| 52 | + |
| 53 | + - name: Deploy Coverage Report to GitHub Pages |
| 54 | + if: github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 55 | + uses: peaceiris/actions-gh-pages@v3 |
| 56 | + with: |
| 57 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + publish_dir: ./coverage_output |
| 59 | + publish_branch: gh-pages |
| 60 | + enable_jekyll: false |
| 61 | + allow_empty_commit: false |
| 62 | + force_orphan: true |
| 63 | + user_name: 'github-actions[bot]' |
| 64 | + user_email: 'github-actions[bot]@users.noreply.github.com' |
| 65 | + commit_message: 'Deploy coverage report for ${{ github.sha }}' |
| 66 | + |
| 67 | + - name: Upload Coverage Artifacts |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: coverage-reports |
| 71 | + path: | |
| 72 | + ./coverage_output/ |
| 73 | + ./test_output/ |
| 74 | + retention-days: 30 |
0 commit comments