|
| 1 | +name: Benchmarking |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + # test changes to Sentry SDK sources |
| 10 | + - "Sources/**" |
| 11 | + |
| 12 | + # test changes to benchmarking implementation |
| 13 | + - "Samples/iOS-Swift/**" |
| 14 | + - ".github/workflows/benchmarking.yml" |
| 15 | + - ".sauce/benchmarking-config.yml" |
| 16 | + - "fastlane/**" |
| 17 | + - "scripts/ci-select-xcode.sh" |
| 18 | + - "Samples/iOS-Swift/iOS-Swift.yml" |
| 19 | + - "Samples/iOS-Swift/iOS-Swift.xcconfig" |
| 20 | + - "Samples/iOS-Swift/iOS-SwiftClilp.xcconfig" |
| 21 | + - "Samples/iOS-Swift/iOS-Benchmarking.xcconfig" |
| 22 | + - "scripts/build-xcframework-slice.sh" |
| 23 | + - "scripts/assemble-xcframework.sh" |
| 24 | + - ".github/workflows/build-xcframework-variant-slices.yml" |
| 25 | + - ".github/workflows/assemble-xcframework-variant.yml" |
| 26 | + |
| 27 | +# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value |
| 28 | +concurrency: |
| 29 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 30 | + cancel-in-progress: true |
| 31 | + |
| 32 | +jobs: |
| 33 | + build-benchmark-test-target: |
| 34 | + name: Build app and test runner |
| 35 | + runs-on: macos-13 |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - run: ./scripts/ci-select-xcode.sh 15.2 |
| 39 | + - uses: ruby/setup-ruby@v1 |
| 40 | + with: |
| 41 | + bundler-cache: true |
| 42 | + - run: make init-ci-build |
| 43 | + - run: make xcode-ci |
| 44 | + - name: Install SentryCli |
| 45 | + run: brew install getsentry/tools/sentry-cli |
| 46 | + - name: Cache iOS-Swift App and dSYM build products |
| 47 | + id: ios-swift-cache |
| 48 | + uses: actions/cache@v4 |
| 49 | + with: |
| 50 | + path: | |
| 51 | + DerivedData/Build/Products/Debug-iphoneos/iOS-Swift.app.dSYM |
| 52 | + DerivedData/Build/Products/Debug-iphoneos/iOS-Swift.app |
| 53 | + key: ios-swift-for-ui-testing-cache-key-${{ hashFiles('Samples/iOS-Swift/**') }}-${{ hashFiles('Sources/Sentry/**') }} |
| 54 | + - name: Cache iOS-Swift UI Test Runner App build product |
| 55 | + id: ios-swift-benchmark-runner-cache |
| 56 | + uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + path: | |
| 59 | + DerivedData/Build/Products/Debug-iphoneos/iOS-Benchmarking-Runner.app |
| 60 | + key: ios-swift-for-ui-testing-cache-key-${{ hashFiles('Samples/iOS-Benchmarking/**') }} |
| 61 | + - run: bundle exec fastlane build_ios_swift_for_tests |
| 62 | + env: |
| 63 | + APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} |
| 64 | + APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} |
| 65 | + APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_KEY }} |
| 66 | + FASTLANE_KEYCHAIN_PASSWORD: ${{ secrets.FASTLANE_KEYCHAIN_PASSWORD }} |
| 67 | + MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }} |
| 68 | + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} |
| 69 | + MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }} |
| 70 | + - run: bundle exec fastlane build_ios_benchmark_test |
| 71 | + env: |
| 72 | + APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }} |
| 73 | + APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }} |
| 74 | + APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_KEY }} |
| 75 | + FASTLANE_KEYCHAIN_PASSWORD: ${{ secrets.FASTLANE_KEYCHAIN_PASSWORD }} |
| 76 | + MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }} |
| 77 | + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} |
| 78 | + MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }} |
| 79 | + - name: Upload dSYMs |
| 80 | + run: | |
| 81 | + sentry-cli --auth-token ${{ secrets.SENTRY_AUTH_TOKEN }} upload-dif --org sentry-sdks --project sentry-cocoa DerivedData/Build/Products/Debug-iphoneos/iOS-Swift.app.dSYM |
| 82 | + - name: Archiving DerivedData |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: DerivedData-Xcode |
| 86 | + path: | |
| 87 | + **/Debug-iphoneos/iOS-Swift.app |
| 88 | + **/Debug-iphoneos/iOS-Benchmarking-Runner.app |
| 89 | +
|
| 90 | + run-ui-tests-with-sauce: |
| 91 | + name: Run benchmarks on Sauce Labs |
| 92 | + runs-on: ubuntu-latest |
| 93 | + needs: build-benchmark-test-target |
| 94 | + strategy: |
| 95 | + fail-fast: false |
| 96 | + matrix: |
| 97 | + suite: ["High-end device", "Mid-range device", "Low-end device"] |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + - uses: actions/download-artifact@v4 |
| 101 | + with: |
| 102 | + name: DerivedData-Xcode |
| 103 | + - run: npm install -g [email protected] |
| 104 | + - name: Run Benchmarks in SauceLab |
| 105 | + id: run-benchmarks-in-sauce-lab |
| 106 | + env: |
| 107 | + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} |
| 108 | + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} |
| 109 | + # Note: We are not setting continue-on-error here, because we want the step to be marked as failed. |
| 110 | + run: | |
| 111 | + set -o pipefail && saucectl run \ |
| 112 | + --select-suite "${{matrix.suite}}" \ |
| 113 | + --config .sauce/benchmarking-config.yml \ |
| 114 | + --tags benchmark \ |
| 115 | + --verbose \ |
| 116 | + 2>&1 | tee output.log |
| 117 | +
|
| 118 | + - name: Recovery - Extract Test ID from output |
| 119 | + id: should-retry-test |
| 120 | + # Note: We need to use always() here, because the previous run step might be marked as failed. |
| 121 | + if: ${{ always() && steps.run-benchmarks-in-sauce-lab.outcome == 'failure' }} |
| 122 | + uses: actions/github-script@v7 |
| 123 | + env: |
| 124 | + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} |
| 125 | + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} |
| 126 | + with: |
| 127 | + script: | |
| 128 | + const fs = require('fs'); |
| 129 | + const { execSync } = require('child_process'); |
| 130 | +
|
| 131 | + console.log("Extracting test ID from output log"); |
| 132 | + const outputLog = fs.readFileSync('output.log', 'utf8'); |
| 133 | +
|
| 134 | + // Lookup for the test ID in the output log |
| 135 | + // Note: The CLI output might change over time, so this might need to be updated. |
| 136 | + const match = outputLog.match(/https:\/\/app\.saucelabs\.com\/tests\/([^\s]+)/); |
| 137 | + const testId = match?.[1] ?? ''; |
| 138 | +
|
| 139 | + if (!testId) { |
| 140 | + core.warning("No SauceLabs test ID found in CLI output, it might have changed, retrying..."); |
| 141 | + core.setOutput('RETRY_TEST', 'true'); |
| 142 | +
|
| 143 | + return; |
| 144 | + } |
| 145 | +
|
| 146 | + try { |
| 147 | + console.log(`Checking if the test exists in SauceLabs: ${testId}`); |
| 148 | + execSync(`saucectl jobs get ${testId}`, { |
| 149 | + env: process.env, |
| 150 | + stdio: 'inherit' |
| 151 | + }); |
| 152 | +
|
| 153 | + console.log("Test exists but failed, not retrying."); |
| 154 | + core.setFailed('Test exists but failed'); |
| 155 | + } catch (error) { |
| 156 | + console.log("Failed to get job, retrying..."); |
| 157 | + core.setOutput('RETRY_TEST', 'true'); |
| 158 | + } |
| 159 | +
|
| 160 | + - name: Run Benchmarks in SauceLab - Retry 1 |
| 161 | + id: run-benchmarks-in-sauce-lab-retry-1 |
| 162 | + # Note: We need to use always() here, because the previous run step might be marked as failed. |
| 163 | + if: ${{ always() && steps.should-retry-test.outputs.RETRY_TEST == 'true' }} |
| 164 | + env: |
| 165 | + SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} |
| 166 | + SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }} |
| 167 | + run: | |
| 168 | + echo "::warning SauceLabs benchmark tests need to be retried" |
| 169 | + saucectl run \ |
| 170 | + --select-suite "${{matrix.suite}}" \ |
| 171 | + --config .sauce/benchmarking-config.yml \ |
| 172 | + --tags benchmark \ |
| 173 | + --verbose |
0 commit comments