Skip to content

Commit 0cbe66f

Browse files
committed
[CI] Implement public interface validation
1 parent dcc3d87 commit 0cbe66f

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

.github/workflows/smoke-checks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
steps:
5454
- uses: actions/checkout@v4.1.1
5555
- uses: ./.github/actions/bootstrap
56+
env:
57+
INSTALL_INTERFACE_ANALYZER: true
58+
- run: bundle exec fastlane validate_public_interface
5659
- run: bundle exec fastlane lint_pr
5760
- run: bundle exec fastlane rubocop
5861
- run: bundle exec fastlane run_swift_format strict:true

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ StreamChatSwiftUI.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.res
1414
build/
1515
DerivedData/
1616

17+
# Interface Analyser
18+
stream-module-interface-analyser/
19+
interface-analyser-report.md
20+
public_interface_current.*
21+
public_interface_previous.*
22+
1723
## Various settings
1824
*.pbxuser
1925
!default.pbxuser

Githubfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export YEETD_VERSION='1.0'
66
export MINT_VERSION='0.17.5'
77
export SONAR_VERSION='6.2.1.4610'
88
export IPSW_VERSION='3.1.592'
9+
export INTERFACE_ANALYZER_VERSION='1.0.7'

Scripts/bootstrap.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ if [[ ${INSTALL_IPSW-default} == true ]]; then
7979
chmod +x ipsw
8080
sudo mv ipsw /usr/local/bin/
8181
fi
82+
83+
if [[ ${INSTALL_INTERFACE_ANALYZER-default} == true ]]; then
84+
puts "Install interface-analyser v${INTERFACE_ANALYZER_VERSION}"
85+
FILE="interface-analyser"
86+
wget "https://github.com/GetStream/stream-module-interface-analyser/releases/download/v${INTERFACE_ANALYZER_VERSION}/${FILE}"
87+
chmod +x ${FILE}
88+
sudo mv ${FILE} /usr/local/bin/
89+
fi

fastlane/Fastfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ lane :sources_matrix do
530530
ruby: ['fastlane', 'Gemfile', 'Gemfile.lock'],
531531
size: ['Sources', xcode_project],
532532
sonar: ['Sources'],
533+
interface_analyser: ['Sources'],
533534
swiftformat_include: ['Sources', 'DemoAppSwiftUI', 'StreamChatSwiftUITests'],
534535
swiftformat_exclude: ['**/Generated', 'Sources/StreamChatSwiftUI/StreamNuke', 'Sources/StreamChatSwiftUI/StreamSwiftyGif']
535536
}
@@ -545,6 +546,45 @@ lane :copyright do
545546
)
546547
end
547548

549+
lane :validate_public_interface do
550+
next unless is_check_required(sources: sources_matrix[:public_interface], force_check: @force_check)
551+
552+
# Run the analysis on the current branch
553+
original_branch = current_branch
554+
sh('interface-analyser analysis ../Sources/ public_interface_current.json')
555+
556+
# Checkout the target branch
557+
target_branch = original_branch.include?('release/') ? 'main' : 'develop'
558+
sh("git fetch origin #{target_branch}")
559+
sh("git checkout #{target_branch}")
560+
561+
# Run the analysis on the target branch
562+
sh('interface-analyser analysis ../Sources/ public_interface_previous.json')
563+
564+
# Run diff
565+
report_path = 'interface-analyser-report.md'
566+
sh("interface-analyser diff public_interface_current.json public_interface_previous.json #{report_path}")
567+
568+
# Check if report exists and is non-zero in size
569+
diff =
570+
if File.exist?(report_path) && File.size(report_path) > 0
571+
File.read(report_path).strip
572+
else
573+
'🚀 No changes affecting the public interface.'
574+
end
575+
576+
# Generate markdown table for the PR comment
577+
header = '## Public Interface'
578+
content = "#{header}\n#{diff}"
579+
580+
# Post PR comment if running in CI
581+
pr_comment(text: content, edit_last_comment_with_text: header) if is_ci
582+
583+
# Checkout the original branch
584+
sh("git fetch origin #{original_branch}")
585+
sh("git checkout #{original_branch}")
586+
end
587+
548588
lane :show_frameworks_sizes do |options|
549589
next unless is_check_required(sources: sources_matrix[:size], force_check: @force_check)
550590

0 commit comments

Comments
 (0)