diff --git a/.github/workflows/cron-checks.yml b/.github/workflows/cron-checks.yml index e84661c09..d986e5ec5 100644 --- a/.github/workflows/cron-checks.yml +++ b/.github/workflows/cron-checks.yml @@ -12,6 +12,7 @@ concurrency: env: HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: build-test-app-and-frameworks: @@ -58,7 +59,6 @@ jobs: runs-on: ${{ matrix.os }} env: GITHUB_EVENT: ${{ toJson(github.event) }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} XCODE_VERSION: ${{ matrix.xcode }} IOS_SIMULATOR_DEVICE: "${{ matrix.device }} (${{ matrix.ios }})" # For the Allure report @@ -147,7 +147,6 @@ jobs: fail-fast: false runs-on: ${{ matrix.os }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} XCODE_VERSION: ${{ matrix.xcode }} STREAM_VIDEO_SECRET: ${{ secrets.STREAM_VIDEO_SECRET }} steps: @@ -213,6 +212,10 @@ jobs: env: XCODE_VERSION: "15.0.1" steps: + - name: Connect iOS Bot + uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} - uses: actions/checkout@v3.1.0 - uses: ./.github/actions/ruby-cache - name: List Xcode versions @@ -225,10 +228,6 @@ jobs: - name: Build UIKit run: bundle exec fastlane test_uikit device:"iPhone 15" build_for_testing:true timeout-minutes: 25 - - name: Install Bot SSH Key - uses: webfactory/ssh-agent@v0.7.0 - with: - ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} - name: Build XCFrameworks run: bundle exec fastlane build_xcframeworks timeout-minutes: 40 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 96e3080bf..93f1ad60f 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -13,7 +13,7 @@ jobs: runs-on: macos-13 if: github.event.pull_request.merged == true # only merged pull requests must trigger this job steps: - - name: Install Bot SSH Key + - name: Connect iOS Bot uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} diff --git a/.github/workflows/sdk-size-metrics.yml b/.github/workflows/sdk-size-metrics.yml index e88d63c67..16e1d1e1c 100644 --- a/.github/workflows/sdk-size-metrics.yml +++ b/.github/workflows/sdk-size-metrics.yml @@ -19,7 +19,7 @@ jobs: env: GITHUB_TOKEN: '${{ secrets.CI_BOT_GITHUB_TOKEN }}' steps: - - name: Install Bot SSH Key + - name: Connect iOS Bot uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} @@ -28,16 +28,10 @@ jobs: - uses: ./.github/actions/bootstrap - - name: Get branch name - id: get_branch_name - run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT - - name: Run SDK Size Metrics run: bundle exec fastlane show_frameworks_sizes timeout-minutes: 30 env: - BRANCH_NAME: ${{ steps.get_branch_name.outputs.branch }} GITHUB_PR_NUM: ${{ github.event.pull_request.number }} - GITHUB_EVENT_NAME: ${{ github.event_name }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }} diff --git a/.github/workflows/smoke-checks.yml b/.github/workflows/smoke-checks.yml index aa6978831..3dd502d91 100644 --- a/.github/workflows/smoke-checks.yml +++ b/.github/workflows/smoke-checks.yml @@ -29,6 +29,8 @@ concurrency: env: HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.4)" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_NUM: ${{ github.event.pull_request.number }} jobs: test-llc-debug: @@ -36,8 +38,6 @@ jobs: runs-on: macos-14 if: ${{ github.event.inputs.swiftui_snapshots != 'true' && github.event.inputs.uikit_snapshots != 'true' }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.number }} STREAM_VIDEO_SECRET: ${{ secrets.STREAM_VIDEO_SECRET }} steps: - uses: actions/checkout@v4.1.1 @@ -53,13 +53,9 @@ jobs: env: XCODE_VERSION: "15.2" # the most stable pair of Xcode IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.2)" # and iOS - - name: Get branch name - id: get_branch_name - run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT - name: Run Sonar analysis run: bundle exec fastlane sonar_upload env: - BRANCH_NAME: ${{ steps.get_branch_name.outputs.branch }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - uses: actions/upload-artifact@v4 @@ -97,7 +93,6 @@ jobs: if: ${{ github.event_name != 'push' && github.event.inputs.swiftui_snapshots != 'false' }} env: GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }} # to open a PR - GITHUB_PR_NUM: ${{ github.event.number }} steps: - uses: actions/checkout@v4.1.1 - uses: ./.github/actions/bootstrap @@ -129,7 +124,6 @@ jobs: if: ${{ github.event_name != 'push' && github.event.inputs.uikit_snapshots != 'false' }} env: GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }} # to open a PR - GITHUB_PR_NUM: ${{ github.event.number }} steps: - uses: actions/checkout@v4.1.1 - uses: ./.github/actions/bootstrap @@ -161,8 +155,6 @@ jobs: runs-on: macos-13 env: XCODE_VERSION: "15.0.1" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.number }} if: ${{ github.event_name != 'push' && github.event.inputs.swiftui_snapshots != 'true' && github.event.inputs.uikit_snapshots != 'true' }} steps: - uses: actions/checkout@v4.1.1 @@ -186,9 +178,11 @@ jobs: if: ${{ github.event_name != 'push' && github.event.inputs.snapshots != 'true' }} env: XCODE_VERSION: "15.0.1" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.number }} steps: + - name: Connect iOS Bot + uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} - uses: actions/checkout@v3.1.0 - uses: ./.github/actions/ruby-cache - name: List Xcode versions @@ -201,10 +195,6 @@ jobs: - name: Build UIKit run: bundle exec fastlane test_uikit device:"iPhone 15" build_for_testing:true timeout-minutes: 25 - - name: Install Bot SSH Key - uses: webfactory/ssh-agent@v0.7.0 - with: - ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} - name: Build XCFrameworks run: bundle exec fastlane build_xcframeworks timeout-minutes: 40 @@ -238,9 +228,6 @@ jobs: runs-on: macos-14 needs: build-test-app-and-frameworks if: ${{ github.event_name != 'push' && github.event.inputs.swiftui_snapshots != 'true' && github.event.inputs.uikit_snapshots != 'true' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.number }} steps: - uses: actions/checkout@v4.1.1 - uses: actions/download-artifact@v4 @@ -270,8 +257,6 @@ jobs: run: bundle exec fastlane allure_launch env: ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.number }} GITHUB_EVENT: ${{ toJson(github.event) }} - id: get_launch_id run: echo "launch_id=${{env.LAUNCH_ID}}" >> $GITHUB_OUTPUT @@ -286,8 +271,6 @@ jobs: - build-test-app-and-frameworks env: LAUNCH_ID: ${{ needs.allure_testops_launch.outputs.launch_id }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PR_NUM: ${{ github.event.number }} ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} strategy: matrix: diff --git a/.github/workflows/start-new-release.yml b/.github/workflows/start-new-release.yml index 1f434bee8..e66a1eac5 100644 --- a/.github/workflows/start-new-release.yml +++ b/.github/workflows/start-new-release.yml @@ -13,7 +13,7 @@ jobs: name: Start new release runs-on: macos-14 steps: - - name: Install Bot SSH Key + - name: Connect iOS Bot uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 820f0b501..7b4572c1a 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -1,10 +1,9 @@ name: Test Flight Deploy DemoApp on: - # TODO: commented until `develop` branch is in place - # pull_request: - # branches: - # - 'main' + pull_request: + branches: + - 'main' release: types: [published] @@ -32,7 +31,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_PR_NUM: ${{ github.event.number }} steps: - - name: Install Bot SSH Key + - name: Connect iOS Bot uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} diff --git a/fastlane/Allurefile b/fastlane/Allurefile index c40298403..6f7014b45 100755 --- a/fastlane/Allurefile +++ b/fastlane/Allurefile @@ -8,11 +8,10 @@ allure_results_path = 'allure-results' desc 'Upload test results to Allure TestOps' lane :allure_upload do |options| - branch = github_run_details['head_branch'] allure_args = "-e #{allure_url} --project-id #{allure_project_id} --launch-id #{options[:launch_id]}" sh("./xcresults export test_output/DemoApp.xcresult #{allure_results_path} || true") sh("./allurectl launch reopen #{options[:launch_id]} || true") # to prevent allure from uploading results to a closed launch - sh("env BRANCH_NAME='#{branch}' ./allurectl upload #{allure_args} #{allure_results_path} || true") + sh("env BRANCH_NAME='#{current_branch}' ./allurectl upload #{allure_args} #{allure_results_path} || true") UI.success("Check out test results in Allure TestOps: #{allure_url}/launch/#{options[:launch_id]} 🎉") end @@ -54,6 +53,6 @@ def github_run_details return nil unless is_ci github_path = "#{ENV.fetch('GITHUB_API_URL', nil)}/repos/#{ENV.fetch('GITHUB_REPOSITORY', nil)}/actions/runs/#{ENV.fetch('GITHUB_RUN_ID', nil)}" - output = sh(command: "curl -s -H 'authorization: Bearer #{ENV.fetch('GITHUB_TOKEN', nil)}' -X GET -G #{github_path}", log: false) + output = sh(command: "curl -s -H 'authorization: Bearer #{ENV.fetch('GITHUB_TOKEN', nil)}' -X GET -G #{github_path}") JSON.parse(output) end diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 20160808a..2108872a3 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -898,6 +898,13 @@ private_lane :create_pr_comment do |options| end end -private_lane :current_branch do - ENV['BRANCH_NAME'].to_s.empty? ? git_branch : ENV.fetch('BRANCH_NAME') +lane :current_branch do + branch = if ENV['GITHUB_PR_NUM'].to_s.empty? + git_branch + else + sh("gh pr view #{ENV.fetch('GITHUB_PR_NUM')} --json headRefName -q .headRefName").strip + end + + UI.important("Current branch: #{branch} 🕊️") + branch end