Skip to content

Commit

Permalink
[CI] Lock sonar scanner and mint versions and get rid of brew
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple committed Jan 31, 2025
1 parent 29091e3 commit a57c98c
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 180 deletions.
11 changes: 0 additions & 11 deletions .github/actions/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/vale*
~/Library/Caches/Homebrew/xcparse*
~/Library/Caches/Homebrew/sonar-scanner*
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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/cron-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/smoke-checks-swiftui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Smoke Checks SwiftUI

on:
push:
branches:
- develop
- main

pull_request:
paths-ignore:
- 'README.md'
- 'CHANGELOG.md'

workflow_dispatch:
inputs:
snapshots:
description: 'Should Snapshots be recorded on CI?'
type: boolean
required: false
default: false

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-ui-debug:
name: Test SwiftUI (Debug)
runs-on: macos-15
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/bootstrap
env:
INSTALL_YEETD: true
INSTALL_SONAR: true
- uses: ./.github/actions/python-cache
- name: Run UI Tests (Debug)
run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}" record:${{ github.event.inputs.snapshots }}
timeout-minutes: 120
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }} # to open a PR
- name: Run Sonar analysis
if: ${{ github.event.inputs.snapshots != 'true' }}
run: bundle exec fastlane sonar_upload
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: "You shall not pass!"
job_name: "Test (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/StreamChatSwiftUI.xcresult fastlane/test_output/logs/
xcparse screenshots fastlane/test_output/StreamChatSwiftUI.xcresult fastlane/test_output/snapshots --test
- uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Data UI
path: |
fastlane/recordings
fastlane/sinatra_log.txt
fastlane/test_output/snapshots
fastlane/test_output/logs/*/Diagnostics/**/*.txt
fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/*
64 changes: 3 additions & 61 deletions .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ name: Smoke Checks

on:
pull_request:
branches:
- '**'
paths-ignore:
- 'README.md'
- 'CHANGELOG.md'

workflow_dispatch:
inputs:
snapshots:
description: 'Should Snapshots be recorded on CI?'
type: boolean
required: false
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -89,58 +84,6 @@ jobs:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}

test-ui-debug:
name: Test SwiftUI (Debug)
runs-on: macos-15
needs: build-test-app-and-frameworks
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v4
with:
name: cache-derived-data
path: derived_data/Build/
- uses: ./.github/actions/bootstrap
env:
INSTALL_YEETD: true
- uses: ./.github/actions/python-cache
- 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
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }} # to open a PR
- name: Run Sonar analysis
if: ${{ github.event.inputs.snapshots != 'true' }}
run: bundle exec fastlane sonar_upload
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: "You shall not pass!"
job_name: "Test (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/StreamChatSwiftUI.xcresult fastlane/test_output/logs/
xcparse screenshots fastlane/test_output/StreamChatSwiftUI.xcresult fastlane/test_output/snapshots --test
- uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Data UI
path: |
fastlane/recordings
fastlane/sinatra_log.txt
fastlane/test_output/snapshots
fastlane/test_output/logs/*/Diagnostics/**/*.txt
fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/*
allure_testops_launch:
name: Launch Allure TestOps
runs-on: macos-13
Expand Down Expand Up @@ -184,7 +127,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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ fastlane/screenshots
fastlane/test_output
fastlane/allurectl
fastlane/xcresults
fastlane/sonar
fastlane/mint
**/metrics/
fastlane/recordings
StreamChatCore.framework.coverage.txt
Expand Down
2 changes: 0 additions & 2 deletions Brewfile

This file was deleted.

91 changes: 0 additions & 91 deletions Brewfile.lock.json

This file was deleted.

2 changes: 2 additions & 0 deletions Githubfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
export ALLURECTL_VERSION='2.15.1'
export XCRESULTS_VERSION='1.16.3'
export YEETD_VERSION='1.0'
export MINT_VERSION='0.17.5'
export SONAR_VERSION='6.2.1.4610'
31 changes: 19 additions & 12 deletions Scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
# - 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 {
echo
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

Expand All @@ -37,16 +31,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

if [[ ${INSTALL_ALLURE-default} == true ]]; then
puts "Install allurectl"
DOWNLOAD_URL="https://github.com/allure-framework/allurectl/releases/download/${ALLURECTL_VERSION}/allurectl_darwin_amd64"
Expand Down
5 changes: 3 additions & 2 deletions fastlane/Sonarfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down

0 comments on commit a57c98c

Please sign in to comment.