From 93c35d7d05ccca6f3f58352bd617a7cd78325fe3 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Thu, 30 Jan 2025 10:11:24 +0000 Subject: [PATCH 1/2] [CI] Lock sonar scanner and mint versions and get rid of brew --- .github/actions/bootstrap/action.yml | 11 --- .github/workflows/cron-checks.yml | 2 +- .github/workflows/smoke-checks.yml | 3 +- .gitignore | 2 + Brewfile | 2 - Brewfile.lock.json | 124 --------------------------- Githubfile | 2 + Scripts/bootstrap.sh | 33 ++++--- fastlane/Fastfile | 12 +-- fastlane/Sonarfile | 5 +- 10 files changed, 30 insertions(+), 166 deletions(-) delete mode 100644 Brewfile delete mode 100644 Brewfile.lock.json diff --git a/.github/actions/bootstrap/action.yml b/.github/actions/bootstrap/action.yml index d2b17e7dd57..0430e575fd0 100644 --- a/.github/actions/bootstrap/action.yml +++ b/.github/actions/bootstrap/action.yml @@ -14,17 +14,6 @@ runs: path: ~/.mint key: ${{ env.IMAGE }}-mint-${{ hashFiles('**/Mintfile') }} restore-keys: ${{ env.IMAGE }}-mint- - - name: Cache brew - uses: actions/cache@v4 - id: brew-cache - with: - path: | - ~/Library/Caches/Homebrew/mint* - ~/Library/Caches/Homebrew/xcparse* - ~/Library/Caches/Homebrew/sonar-scanner* - ~/Library/Caches/Homebrew/google-cloud-sdk* - key: ${{ env.IMAGE }}-brew-${{ hashFiles('**/Brewfile.lock.json') }} - restore-keys: ${{ env.IMAGE }}-brew- - uses: ./.github/actions/ruby-cache - uses: ./.github/actions/xcode-cache - run: ./Scripts/bootstrap.sh diff --git a/.github/workflows/cron-checks.yml b/.github/workflows/cron-checks.yml index 035c9d86874..3a99939d179 100644 --- a/.github/workflows/cron-checks.yml +++ b/.github/workflows/cron-checks.yml @@ -80,7 +80,6 @@ jobs: INSTALL_ALLURE: true INSTALL_YEETD: true SKIP_MINT_BOOTSTRAP: true - SKIP_BREW_BOOTSTRAP: true - uses: ./.github/actions/setup-ios-runtime if: ${{ matrix.setup_runtime }} timeout-minutes: 60 @@ -157,6 +156,7 @@ jobs: - uses: ./.github/actions/bootstrap env: INSTALL_YEETD: true + INSTALL_SONAR: true - uses: ./.github/actions/setup-ios-runtime if: ${{ matrix.setup_runtime }} timeout-minutes: 60 diff --git a/.github/workflows/smoke-checks.yml b/.github/workflows/smoke-checks.yml index caa08f0521c..cda76969efa 100644 --- a/.github/workflows/smoke-checks.yml +++ b/.github/workflows/smoke-checks.yml @@ -99,6 +99,7 @@ jobs: - uses: ./.github/actions/bootstrap env: INSTALL_YEETD: true + INSTALL_SONAR: true - uses: ./.github/actions/python-cache - name: Run LLC Tests (Debug) run: bundle exec fastlane test device:"${{ env.IOS_SIMULATOR_DEVICE }}" skip_build:true @@ -147,7 +148,6 @@ jobs: env: INSTALL_YEETD: true SKIP_MINT_BOOTSTRAP: true - SKIP_BREW_BOOTSTRAP: true - name: Run UI Tests (Debug) run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}" skip_build:true record:${{ github.event.inputs.snapshots }} timeout-minutes: 120 @@ -209,7 +209,6 @@ jobs: INSTALL_ALLURE: true INSTALL_YEETD: true SKIP_MINT_BOOTSTRAP: true - SKIP_BREW_BOOTSTRAP: true - name: Run UI Tests (Debug) run: bundle exec fastlane test_e2e_mock device:"${{ env.IOS_SIMULATOR_DEVICE }}" batch:'${{ matrix.batch }}' test_without_building:true timeout-minutes: 100 diff --git a/.gitignore b/.gitignore index 3d34c5774fd..c438b56b064 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,8 @@ fastlane/allurectl fastlane/xcresults fastlane/recordings fastlane/performance +fastlane/sonar +fastlane/mint **/metrics/ StreamChatCore.framework.coverage.txt StreamChatCoreTests.xctest.coverage.txt diff --git a/Brewfile b/Brewfile deleted file mode 100644 index 5b81827e061..00000000000 --- a/Brewfile +++ /dev/null @@ -1,2 +0,0 @@ -brew 'mint' -brew 'sonar-scanner' diff --git a/Brewfile.lock.json b/Brewfile.lock.json deleted file mode 100644 index ab31da133d8..00000000000 --- a/Brewfile.lock.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "entries": { - "brew": { - "mint": { - "version": "0.17.5", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:ada351985ef562807e7460f869c527bb314600311738a944219225226f43addf", - "sha256": "ada351985ef562807e7460f869c527bb314600311738a944219225226f43addf" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:250948fe6fc14179d7c381d084a90d6796861ba9a8456617cadda9ac62cbc2b8", - "sha256": "250948fe6fc14179d7c381d084a90d6796861ba9a8456617cadda9ac62cbc2b8" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:6546b80b980a45036415162189dd340b1f8d3f4e82a80d40a24e7b5dd672eb04", - "sha256": "6546b80b980a45036415162189dd340b1f8d3f4e82a80d40a24e7b5dd672eb04" - }, - "arm64_big_sur": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:39f9d254b248a44bb44e399081b7e50a6c598834e2bf86bb7de3ebc349f11e0d", - "sha256": "39f9d254b248a44bb44e399081b7e50a6c598834e2bf86bb7de3ebc349f11e0d" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:154b8b94602d6d38249cfa936f7d071d9113935b3756d5781021fe04c3971e29", - "sha256": "154b8b94602d6d38249cfa936f7d071d9113935b3756d5781021fe04c3971e29" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:068f9984e81b578f2ed6cef4cc9659835a689bdecf121651ea24ebcfefd49339", - "sha256": "068f9984e81b578f2ed6cef4cc9659835a689bdecf121651ea24ebcfefd49339" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:f8b09a640942548a151c7450c85f33d40162c7540049666131740d49c68e61e6", - "sha256": "f8b09a640942548a151c7450c85f33d40162c7540049666131740d49c68e61e6" - }, - "big_sur": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:528ea907912e8002cd3a769e8ddda4556cf2482122c3f848a7d923146df37101", - "sha256": "528ea907912e8002cd3a769e8ddda4556cf2482122c3f848a7d923146df37101" - }, - "x86_64_linux": { - "cellar": "/home/linuxbrew/.linuxbrew/Cellar", - "url": "https://ghcr.io/v2/homebrew/core/mint/blobs/sha256:7c8dd63f0310a46f67550f92ee48a370fadfc1a4d884b8a3904a36b7b610b3f2", - "sha256": "7c8dd63f0310a46f67550f92ee48a370fadfc1a4d884b8a3904a36b7b610b3f2" - } - } - } - }, - "sonar-scanner": { - "version": "6.1.0.4477", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c", - "sha256": "3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c", - "sha256": "3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c", - "sha256": "3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c", - "sha256": "3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c", - "sha256": "3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c", - "sha256": "3a4a993d143f125bf902bfaea4e8a69c064f944eb682c4f2a311d765a8fa0b8c" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sonar-scanner/blobs/sha256:50f629e9d25548f2d0eb31cf42a16edcc5f4f94a4acfa649834949ebbc8fcaa2", - "sha256": "50f629e9d25548f2d0eb31cf42a16edcc5f4f94a4acfa649834949ebbc8fcaa2" - } - } - } - } - } - }, - "system": { - "macos": { - "ventura": { - "HOMEBREW_VERSION": "4.2.3", - "HOMEBREW_PREFIX": "/usr/local", - "Homebrew/homebrew-core": "api", - "CLT": "15.1.0.0.1.1700200546", - "Xcode": "14.3.1", - "macOS": "13.6.3" - }, - "sonoma": { - "HOMEBREW_VERSION": "4.3.8", - "HOMEBREW_PREFIX": "/opt/homebrew", - "Homebrew/homebrew-core": "api", - "CLT": "15.3.0.0.1.1708646388", - "Xcode": "15.0.1", - "macOS": "14.5" - } - } - } -} diff --git a/Githubfile b/Githubfile index 15496f60a56..95a4bae9b64 100644 --- a/Githubfile +++ b/Githubfile @@ -4,3 +4,5 @@ export ALLURECTL_VERSION='2.15.1' export XCRESULTS_VERSION='1.16.3' export YEETD_VERSION='1.0' export GCLOUD_VERSION='464.0.0' +export MINT_VERSION='0.17.5' +export SONAR_VERSION='6.2.1.4610' diff --git a/Scripts/bootstrap.sh b/Scripts/bootstrap.sh index f30d495effe..9498c54f14d 100755 --- a/Scripts/bootstrap.sh +++ b/Scripts/bootstrap.sh @@ -3,10 +3,9 @@ # Usage: ./bootstrap.sh # This script will: # - install Mint and bootstrap its dependencies -# - install Vale # - link git hooks # - install allure dependencies if `INSTALL_ALLURE` environment variable is provided -# You should have homebrew installed. +# - install sonar-scanner if `INSTALL_SONAR` environment variable is provided # If you get `zsh: permission denied: ./bootstrap.sh` error, please run `chmod +x bootstrap.sh` first function puts { @@ -14,12 +13,6 @@ function puts { echo -e "👉 ${1}" } -# Check if Homebrew is installed -if [[ $(command -v brew) == "" ]]; then - echo "Homebrew not installed. Please install." - exit 1 -fi - # Set bash to Strict Mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/) set -Eeuo pipefail @@ -37,17 +30,29 @@ ln -sf ../../hooks/pre-commit.sh .git/hooks/pre-commit chmod +x .git/hooks/pre-commit chmod +x ./hooks/git-format-staged - -if [ "${SKIP_BREW_BOOTSTRAP:-}" != true ]; then - puts "Install brew dependencies" - brew bundle -d -fi - if [ "${SKIP_MINT_BOOTSTRAP:-}" != true ]; then puts "Bootstrap Mint dependencies" + git clone https://github.com/yonaskolb/Mint.git fastlane/mint + root=$(pwd) + cd fastlane/mint + swift run mint install "yonaskolb/mint@${MINT_VERSION}" + cd $root + rm -rf fastlane/mint mint bootstrap --link fi +if [[ ${INSTALL_SONAR-default} == true ]]; then + puts "Install sonar scanner" + DOWNLOAD_URL="https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_VERSION}-macosx-x64.zip" + curl -sL "${DOWNLOAD_URL}" -o ./fastlane/sonar.zip + cd fastlane + unzip sonar.zip + rm sonar.zip + cd .. + mv "fastlane/sonar-scanner-${SONAR_VERSION}-macosx-x64/" fastlane/sonar/ + chmod +x ./fastlane/sonar/bin/sonar-scanner +fi + # Copy internal Xcode scheme to the right folder for puts "Adding DemoApp-StreamDevelopers.xcscheme to the Xcode project" cp Scripts/DemoApp-StreamDevelopers.xcscheme StreamChat.xcodeproj/xcshareddata/xcschemes/DemoApp-StreamDevelopers.xcscheme diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 90b2f01fc38..b201a1c25be 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -332,18 +332,10 @@ lane :test do |options| devices: options[:device], skip_build: true, xcargs: buildcache_xcargs, - number_of_retries: options[:cron] ? 3 : nil + number_of_retries: options[:cron] ? 3 : 2 } - begin - scan(scan_options) - rescue StandardError => e - UI.user_error!(e) unless options[:cron] - - failed_tests = retreive_failed_tests - UI.important("Re-running #{failed_tests.size} failed tests ⌛️") - scan(scan_options.merge(only_testing: failed_tests)) - end + scan(scan_options) end desc 'Starts Sinatra web server' diff --git a/fastlane/Sonarfile b/fastlane/Sonarfile index 1e2fd6facf0..e35d69086fd 100755 --- a/fastlane/Sonarfile +++ b/fastlane/Sonarfile @@ -22,8 +22,9 @@ lane :sonar_upload do '-Dsonar.swift.lizard.report="reports/lizard.xml"' end - options = sonar_options(sonar_args: sonar_args, version_number: version_number) - sonar(options) + Dir.chdir('..') do + sh("./fastlane/sonar/bin/sonar-scanner -Dsonar.projectVersion=#{version_number} -Dproject.settings=sonar-project.properties #{sonar_args}") + end next if sonar_args.empty? || ENV['GITHUB_EVENT_NAME'] == 'pull_request' || current_branch !~ /main|develop/ From 7cc3563f572ca8d3398435997dcd8123c1c1a5c4 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Thu, 30 Jan 2025 16:55:28 +0000 Subject: [PATCH 2/2] Extract LLC tests to a separate workflow --- .github/workflows/smoke-checks-llc.yml | 66 ++++++++++++++++++++++++++ .github/workflows/smoke-checks.yml | 50 ------------------- 2 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/smoke-checks-llc.yml diff --git a/.github/workflows/smoke-checks-llc.yml b/.github/workflows/smoke-checks-llc.yml new file mode 100644 index 00000000000..47a6378b54f --- /dev/null +++ b/.github/workflows/smoke-checks-llc.yml @@ -0,0 +1,66 @@ +name: Smoke Checks LLC + +on: + push: + branches: + - develop + - main + + pull_request: + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI + IOS_SIMULATOR_DEVICE: "iPhone 16 Pro (18.1)" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PR_NUM: ${{ github.event.pull_request.number }} + +jobs: + test-llc-debug: + name: Test LLC (Debug) + runs-on: macos-15 + steps: + - uses: actions/checkout@v4.1.1 + with: + fetch-depth: 100 + - uses: ./.github/actions/bootstrap + env: + INSTALL_YEETD: true + INSTALL_SONAR: true + - uses: ./.github/actions/python-cache + - name: Run LLC Tests (Debug) + run: bundle exec fastlane test device:"${{ env.IOS_SIMULATOR_DEVICE }}" + timeout-minutes: 60 + - name: Run Sonar analysis + run: bundle exec fastlane sonar_upload + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + PR_NUMBER: ${{ github.event.number }} + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + text: "You shall not pass!" + job_name: "Test LLC (Debug)" + fields: message,commit,author,action,workflow,job,took + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + MATRIX_CONTEXT: ${{ toJson(matrix) }} + if: ${{ github.event_name == 'push' && failure() }} + - name: Parse xcresult + if: failure() + run: | + brew install chargepoint/xcparse/xcparse + xcparse logs fastlane/test_output/StreamChat.xcresult fastlane/test_output/logs/ + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: Test Data LLC + path: | + fastlane/test_output/logs/*/Diagnostics/**/*.txt + fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/* diff --git a/.github/workflows/smoke-checks.yml b/.github/workflows/smoke-checks.yml index cda76969efa..57c03555546 100644 --- a/.github/workflows/smoke-checks.yml +++ b/.github/workflows/smoke-checks.yml @@ -83,56 +83,6 @@ jobs: run: bundle exec fastlane test_ui device:"iPhone 13" build_for_testing:true timeout-minutes: 25 - test-llc-debug: - name: Test LLC (Debug) - runs-on: macos-15 - if: ${{ github.event.inputs.snapshots != 'true' }} - needs: build-test-app-and-frameworks - steps: - - uses: actions/checkout@v4.1.1 - with: - fetch-depth: 100 - - uses: actions/download-artifact@v4 - with: - name: cache-derived-data - path: derived_data/Build/ - - uses: ./.github/actions/bootstrap - env: - INSTALL_YEETD: true - INSTALL_SONAR: true - - uses: ./.github/actions/python-cache - - name: Run LLC Tests (Debug) - run: bundle exec fastlane test device:"${{ env.IOS_SIMULATOR_DEVICE }}" skip_build:true - timeout-minutes: 60 - - name: Run Sonar analysis - run: bundle exec fastlane sonar_upload - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - PR_NUMBER: ${{ github.event.number }} - - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - text: "You shall not pass!" - job_name: "Test LLC (Debug)" - fields: message,commit,author,action,workflow,job,took - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - MATRIX_CONTEXT: ${{ toJson(matrix) }} - if: ${{ github.event_name == 'push' && failure() }} - - name: Parse xcresult - if: failure() - run: | - brew install chargepoint/xcparse/xcparse - xcparse logs fastlane/test_output/StreamChat.xcresult fastlane/test_output/logs/ - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: Test Data LLC - path: | - fastlane/test_output/logs/*/Diagnostics/**/*.txt - fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/* - test-ui-debug: name: Test UI (Debug) runs-on: macos-15