ci: sonar coverage #2231
Workflow file for this run
This file contains 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
name: Build app | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
concurrency: | |
group: ${{ github.ref }}-tests | |
cancel-in-progress: true | |
jobs: | |
debug-app-unit-tests: | |
runs-on: macos-13-large | |
timeout-minutes: 30 | |
name: Debug App - Unit Tests | |
steps: | |
- name: Git - Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
ref: ${{ github.ref }} | |
- name: Select Xcode Version | |
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd | |
with: | |
xcode-version: "15.2" | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
name: id_rsa_github_actions | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 | |
with: | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
- uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 | |
with: | |
ruby-version: "3.2" | |
bundler-cache: true | |
- name: Run Unit Tests | |
shell: bash | |
run: | | |
bundle exec fastlane tests | |
env: | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
MATCH_GIT_PRIVATE_KEY: ${{ secrets.SSH_KEY }} | |
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }} | |
FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }} | |
MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} | |
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} | |
SOURCE_BRANCH: ${{ github.head_ref }} | |
sdk-unit-tests: | |
runs-on: macos-13-large | |
timeout-minutes: 20 | |
name: SDK - Unit Tests | |
steps: | |
- name: Cancel previous jobs | |
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa | |
with: | |
access_token: ${{ github.token }} | |
- name: Git - Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
ref: ${{ github.ref }} | |
- name: Select Xcode Version | |
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd | |
with: | |
xcode-version: "15.2" | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
name: id_rsa_github_actions | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
- uses: webfactory/ssh-agent@dc588b651fe13675774614f8e6a936a468676387 | |
with: | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
- uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 | |
with: | |
ruby-version: "3.2" | |
bundler-cache: true | |
- name: Run SDK Unit Tests | |
run: | | |
bundle exec fastlane test_spm | |
env: | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
MATCH_GIT_PRIVATE_KEY: ${{ secrets.SSH_KEY }} | |
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }} | |
FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }} | |
MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }} | |
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} | |
SOURCE_BRANCH: ${{ github.head_ref }} | |
- name: Prepare coverage reports | |
run: | | |
bash Scripts/xccov-to-sonarqube-generic.sh fastlane/test_output/PrimerSDKTests.xcresult/ > coverage.xml | |
sed "s#$PWD/##g" coverage.xml > coverage_cleaned.xml | |
cat coverage_cleaned.xml | |
- name: Install Sonar-Scanner | |
run: | | |
brew install sonar-scanner | |
- name: Run Sonar scanner | |
run: | | |
git fetch --unshallow --no-tags | |
sonar-scanner -Dsonar.token=${{ secrets.SONAR_TOKEN }} -Dsonar.coverageReportPaths=coverage_cleaned.xml -Dsonar.verbose=true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build-and-upload-to-appetize: | |
needs: | |
- debug-app-unit-tests | |
- sdk-unit-tests | |
runs-on: macos-13 | |
timeout-minutes: 45 | |
name: Build and upload app to Appetize | |
steps: | |
- name: Cancel previous jobs | |
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa | |
with: | |
access_token: ${{ github.token }} | |
- name: Git - Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
ref: ${{ github.ref }} | |
- name: Upload preview to Appetize | |
id: appetize-upload | |
uses: ./.github/actions/appetize-build | |
with: | |
build_type: preview | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
known-hosts: ${{ secrets.KNOWN_HOSTS }} | |
match-password: ${{ secrets.MATCH_PASSWORD }} | |
match-git-private-key: ${{ secrets.FASTLANE_PASSWORD }} | |
fastlane-session: ${{ secrets.FASTLANE_SESSION }} | |
fastlane-password: ${{ secrets.FASTLANE_PASSWORD }} | |
match-keychain-name: ${{ secrets.MATCH_KEYCHAIN_NAME }} | |
match-keychain-password: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }} | |
appetize-api-token: ${{ secrets.APPETIZE_API_TOKEN }} | |
source-branch: ${{ github.head_ref || github.ref_name }} | |
pr-number: ${{ github.event.pull_request.number }} | |
slack-channel: ${{ secrets.SLACK_MOBILE_SDK_CHANNEL }} | |
slack-reporter-token: ${{ secrets.SLACK_REPORTER_BOT_TOKEN }} | |
github-run-id: ${{ github.run_id }} | |
- uses: peter-evans/find-comment@d5fe37641ad8451bdd80312415672ba26c86575e | |
if: ${{ success() }} | |
id: find_comment | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body-includes: Appetize link | |
- uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 | |
if: ${{ success() }} | |
with: | |
body: | | |
Appetize link: ${{ env.APPETIZE_APP_URL }} | |
edit-mode: replace | |
comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
token: ${{ secrets.GITHUB_TOKEN }} |