diff --git a/.github/workflows/smoke-checks.yml b/.github/workflows/smoke-checks.yml index 68bf0de25e4..58e3b13cce4 100644 --- a/.github/workflows/smoke-checks.yml +++ b/.github/workflows/smoke-checks.yml @@ -52,9 +52,10 @@ jobs: if: ${{ github.event.inputs.record_snapshots != 'true' }} steps: - uses: actions/checkout@v4.1.1 - with: - fetch-depth: 100 - uses: ./.github/actions/bootstrap + env: + INSTALL_INTERFACE_ANALYZER: true + - run: bundle exec fastlane validate_public_interface - run: bundle exec fastlane lint_pr - run: bundle exec fastlane rubocop - run: bundle exec fastlane run_swift_format strict:true diff --git a/.gitignore b/.gitignore index c438b56b064..e68b3c1c297 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,12 @@ StreamChat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved build/ DerivedData/ +# Interface Analyser +stream-module-interface-analyser/ +interface-analyser-report.md +public_interface_current.* +public_interface_previous.* + ## Various settings *.pbxuser !default.pbxuser diff --git a/Githubfile b/Githubfile index a6ac5737af8..5fc7e9a3972 100644 --- a/Githubfile +++ b/Githubfile @@ -7,3 +7,4 @@ export GCLOUD_VERSION='464.0.0' export MINT_VERSION='0.17.5' export SONAR_VERSION='6.2.1.4610' export IPSW_VERSION='3.1.592' +export INTERFACE_ANALYZER_VERSION='1.0.7' diff --git a/Scripts/bootstrap.sh b/Scripts/bootstrap.sh index 75a1b07f87c..b84fca6aa86 100755 --- a/Scripts/bootstrap.sh +++ b/Scripts/bootstrap.sh @@ -93,3 +93,11 @@ if [[ ${INSTALL_IPSW-default} == true ]]; then chmod +x ipsw sudo mv ipsw /usr/local/bin/ fi + +if [[ ${INSTALL_INTERFACE_ANALYZER-default} == true ]]; then + puts "Install interface-analyser v${INTERFACE_ANALYZER_VERSION}" + FILE="interface-analyser" + wget "https://github.com/GetStream/stream-module-interface-analyser/releases/download/v${INTERFACE_ANALYZER_VERSION}/${FILE}" + chmod +x ${FILE} + sudo mv ${FILE} /usr/local/bin/ +fi diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 50c253cef96..065134d1741 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -830,6 +830,7 @@ lane :sources_matrix do ruby: ['fastlane', 'Gemfile', 'Gemfile.lock'], size: ['Sources', xcode_project], xcmetrics: ['Sources'], + public_interface: ['Sources'], swiftformat_include: ['Sources', 'DemoApp', 'Tests', 'Integration'], swiftformat_exclude: ['**/Generated', 'Sources/StreamChatUI/StreamNuke', 'Sources/StreamChatUI/StreamSwiftyGif', 'Sources/StreamChatUI/StreamDifferenceKit'] } @@ -845,6 +846,45 @@ lane :copyright do ) end +lane :validate_public_interface do + next unless is_check_required(sources: sources_matrix[:public_interface], force_check: @force_check) + + # Run the analysis on the current branch + original_branch = current_branch + sh('interface-analyser analysis ../Sources/ public_interface_current.json') + + # Checkout the target branch + target_branch = original_branch.include?('release/') ? 'main' : 'develop' + sh("git fetch origin #{target_branch}") + sh("git checkout #{target_branch}") + + # Run the analysis on the target branch + sh('interface-analyser analysis ../Sources/ public_interface_previous.json') + + # Run diff + report_path = 'interface-analyser-report.md' + sh("interface-analyser diff public_interface_current.json public_interface_previous.json #{report_path}") + + # Check if report exists and is non-zero in size + diff = + if File.exist?(report_path) && File.size(report_path) > 0 + File.read(report_path).strip + else + '🚀 No changes affecting the public interface.' + end + + # Generate markdown table for the PR comment + header = '## Public Interface' + content = "#{header}\n#{diff}" + + # Post PR comment if running in CI + pr_comment(text: content, edit_last_comment_with_text: header) if is_ci + + # Checkout the original branch + sh("git fetch origin #{original_branch}") + sh("git checkout #{original_branch}") +end + lane :show_frameworks_sizes do |options| next unless is_check_required(sources: sources_matrix[:size], force_check: @force_check)