fix: adds coverage #59
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
| name: SonarQube | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| merge_group: | |
| jobs: | |
| build-and-analyze: | |
| runs-on: macos-15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for better SonarQube analysis | |
| # Install Ruby (for Slather) and Slather itself | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.4.3 | |
| - name: Install slather | |
| run: gem install slather | |
| - name: Install Dependencies | |
| run: swift package resolve | |
| - name: Build for testing | |
| run: | | |
| xcodebuild build-for-testing \ | |
| -scheme 'FormbricksSDK' \ | |
| -sdk iphonesimulator \ | |
| -config Debug \ | |
| -destination 'platform=iOS Simulator,name=iPhone SE (3rd generation),OS=18.2' \ | |
| -derivedDataPath build \ | |
| -enableCodeCoverage YES | |
| - name: Verify test bundle | |
| run: | | |
| ls -la build/Build/Products/ | |
| ls -la build/Build/Products/Debug-iphonesimulator/ | |
| ls -la build/Build/Products/Debug-iphonesimulator/FormbricksSDKTests.xctest || echo "Test bundle not found" | |
| - name: Run tests | |
| run: | | |
| xcodebuild test-without-building \ | |
| -scheme 'FormbricksSDK' \ | |
| -sdk iphonesimulator \ | |
| -config Debug \ | |
| -destination 'platform=iOS Simulator,name=iPhone SE (3rd generation),OS=18.2' \ | |
| -derivedDataPath build \ | |
| -enableCodeCoverage YES | |
| # Generate Cobertura XML from that Xcode-derived coverage | |
| - name: Generate Cobertura XML | |
| run: | | |
| slather coverage \ | |
| --scheme FormbricksSDK \ | |
| --cobertura-xml \ | |
| --output-directory coverage \ | |
| . | |
| # Run SonarCloud scan, pointing at the Cobertura report | |
| - name: SonarCloud Scan | |
| uses: SonarSource/sonarcloud-github-action@ffc3010689be73b8e5ae0c57ce35968afd7909e8 # v5.0.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |