Skip to content

[CI] Implement public interface validation#3740

Merged
testableapple merged 1 commit intodevelopfrom
ci/public-interface-analyser
Jul 24, 2025
Merged

[CI] Implement public interface validation#3740
testableapple merged 1 commit intodevelopfrom
ci/public-interface-analyser

Conversation

@testableapple
Copy link
Contributor

@testableapple testableapple commented Jul 23, 2025

🎯 Goal

Implement public interface validation

Summary by CodeRabbit

  • New Features
    • Introduced automated validation of the public interface in pull requests, generating a detailed report and posting it as a comment.
  • Chores
    • Updated environment variables and scripts to support the new interface analysis tool.
    • Added new ignore rules to exclude interface analysis artifacts from version control.

@testableapple testableapple added the 🤖 CI/CD Any work related to CI/CD label Jul 23, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 23, 2025

Walkthrough

The changes introduce an automated workflow for validating the public interface using a new tool, "interface-analyser". This involves updating the CI pipeline, adding installation logic for the tool, updating ignore rules, defining a Fastlane lane for interface validation, and setting relevant environment variables.

Changes

File(s) Change Summary
.github/workflows/smoke-checks.yml Updated CI workflow: removed fetch-depth, added env var for bootstrap, inserted Fastlane interface validation.
.gitignore Added ignore rules for interface-analyser tool files and reports.
Githubfile Added INTERFACE_ANALYZER_VERSION environment variable.
Scripts/bootstrap.sh Added logic to install interface-analyser based on env var and version.
fastlane/Fastfile Added public_interface source group and new lane validate_public_interface for interface diff and reporting.

Sequence Diagram(s)

sequenceDiagram
    participant CI as GitHub Actions
    participant Bootstrap as bootstrap.sh
    participant Fastlane as Fastfile
    participant InterfaceAnalyzer as interface-analyser

    CI->>Bootstrap: Run with INSTALL_INTERFACE_ANALYZER=true
    Bootstrap->>InterfaceAnalyzer: Download & install (version from env)
    CI->>Fastlane: Run validate_public_interface lane
    Fastlane->>InterfaceAnalyzer: Analyze current branch (output: current.json)
    Fastlane->>Git: Determine target branch (main/develop), checkout
    Fastlane->>InterfaceAnalyzer: Analyze target branch (output: previous.json)
    Fastlane->>InterfaceAnalyzer: Diff current.json vs previous.json (output: report.md)
    Fastlane->>CI: Post markdown report as PR comment
    Fastlane->>Git: Checkout original branch
Loading

Estimated code review effort

3 (~40 minutes)

Suggested labels

🤖 CI/CD

Suggested reviewers

  • laevandus
  • nuno-vieira

Poem

A rabbit hops through interface fields,
Checking changes that each commit yields.
With analyzers new and Fastlane’s might,
Reports are posted, clear and bright.
Ignore those files, let CI run free—
Hooray for automation, from burrow to tree! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

Public Interface

🚀 No changes affecting the public interface.

@testableapple testableapple force-pushed the ci/public-interface-analyser branch from 1a33770 to da27dae Compare July 23, 2025 16:01
@testableapple testableapple marked this pull request as ready for review July 23, 2025 16:01
@testableapple testableapple requested a review from a team as a code owner July 23, 2025 16:01
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
Scripts/bootstrap.sh (1)

97-103: Consider adding security measures for binary installation.

The installation follows the established pattern but could benefit from additional security measures:

  1. Checksum verification: Consider verifying the binary's integrity
  2. Error handling: Add error handling for failed downloads
  3. Binary validation: Verify the downloaded file is executable

Example improvement:

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}"
+ wget "https://github.com/GetStream/stream-module-interface-analyser/releases/download/v${INTERFACE_ANALYZER_VERSION}/${FILE}" || { echo "Failed to download interface-analyser"; exit 1; }
+ # Verify it's a valid executable
+ file ${FILE} | grep -q "executable" || { echo "Downloaded file is not executable"; exit 1; }
  chmod +x ${FILE}
  sudo mv ${FILE} /usr/local/bin/
fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71984a5 and da27dae.

📒 Files selected for processing (5)
  • .github/workflows/smoke-checks.yml (1 hunks)
  • .gitignore (1 hunks)
  • Githubfile (1 hunks)
  • Scripts/bootstrap.sh (1 hunks)
  • fastlane/Fastfile (2 hunks)
🔇 Additional comments (5)
Githubfile (1)

10-10: Version 1.0.7 exists, but security-advisory endpoint returned 404 – please confirm manually

  • Confirmed v1.0.7 is published in GetStream/stream-module-interface-analyser GitHub releases.
  • The download URL (…/releases/download/v1.0.7/interface-analyser) correctly redirects to the asset.
  • The GitHub REST API for security advisories returned a 404 (“Not Found”), indicating the endpoint isn’t available.

Please manually verify in your organization’s GitHub Security Advisories (GHAS) dashboard or via a third-party scanner (e.g. Snyk, Dependabot) that no known vulnerabilities affect interface-analyser@1.0.7.

.gitignore (1)

17-22: LGTM! Comprehensive ignore patterns for interface analyser artifacts.

The ignore patterns properly exclude all generated files and directories from the interface analysis process, preventing them from being tracked in version control.

.github/workflows/smoke-checks.yml (2)

56-58: Well-integrated interface validation setup.

The environment variable configuration and lane execution are properly integrated into the CI workflow.


54-54: No action required: interface validation lane explicitly fetches the target branch.

The validate_public_interface lane in your Fastfile sets

target_branch = original_branch.include?('release/') ? 'main' : 'develop'
sh("git fetch origin #{target_branch}")
sh("git checkout #{target_branch}")

so even with the default shallow clone (fetch-depth: 1), the script will fetch and checkout the full target branch history at runtime. The removal of fetch-depth: 100 does not block interface validation.

fastlane/Fastfile (1)

833-833: LGTM! Proper sources matrix configuration.

The public_interface source group correctly points to the Sources directory for interface analysis.

Comment on lines +849 to +886
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
Copy link

@coderabbitai coderabbitai bot Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling and tool verification to the interface validation lane.

The lane implementation is well-structured but needs improvements for robustness:

  1. Missing error handling: Git operations can fail if branches don't exist or network issues occur
  2. Tool availability: No verification that interface-analyser is installed
  3. Branch restoration: Should use ensure block to guarantee branch restoration even if errors occur

Consider these improvements:

lane :validate_public_interface do
  next unless is_check_required(sources: sources_matrix[:public_interface], force_check: @force_check)

+  # Verify tool is available
+  begin
+    sh('which interface-analyser')
+  rescue
+    UI.user_error!('interface-analyser tool is not installed. Please run bootstrap with INSTALL_INTERFACE_ANALYZER=true')
+  end

  # Run the analysis on the current branch
  original_branch = current_branch
-  sh('interface-analyser analysis ../Sources/ public_interface_current.json')
+  
+  begin
+    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}")
+    sh("git fetch origin #{target_branch}") rescue UI.user_error!("Failed to fetch #{target_branch}")
+    sh("git checkout #{target_branch}") rescue UI.user_error!("Failed to 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

+  ensure
    # Checkout the original branch
-    sh("git fetch origin #{original_branch}")
-    sh("git checkout #{original_branch}")
+    begin
+      sh("git fetch origin #{original_branch}")
+      sh("git checkout #{original_branch}")
+    rescue => e
+      UI.error("Failed to restore original branch #{original_branch}: #{e}")
+    end
+  end
end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 :validate_public_interface do
next unless is_check_required(sources: sources_matrix[:public_interface], force_check: @force_check)
# Verify tool is available
begin
sh('which interface-analyser')
rescue
UI.user_error!('interface-analyser tool is not installed. Please run bootstrap with INSTALL_INTERFACE_ANALYZER=true')
end
# Run the analysis on the current branch
original_branch = current_branch
begin
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}") rescue UI.user_error!("Failed to fetch #{target_branch}")
sh("git checkout #{target_branch}") rescue UI.user_error!("Failed to 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
ensure
# Checkout the original branch
begin
sh("git fetch origin #{original_branch}")
sh("git checkout #{original_branch}")
rescue => e
UI.error("Failed to restore original branch #{original_branch}: #{e}")
end
end
end
🤖 Prompt for AI Agents
In fastlane/Fastfile lines 849 to 886, add error handling around git commands to
catch failures like missing branches or network issues by wrapping them in
begin-rescue blocks. Before running interface-analyser commands, verify the tool
is installed by checking its availability and aborting with a clear message if
not found. Use an ensure block to guarantee that the original branch is checked
out again even if any errors occur during the lane execution, ensuring branch
restoration happens reliably.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error handlings are not required because the script will fail anyways on those lines and print an error message.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@testableapple You're absolutely right! Fastlane's default behavior will handle the failures and provide clear error messages when shell commands fail. Keeping the implementation simple and relying on fastlane's built-in error reporting makes sense for your use case. Thanks for the clarification!


✏️ Learnings added
Learnt from: testableapple
PR: GetStream/stream-chat-swift#3740
File: fastlane/Fastfile:849-886
Timestamp: 2025-07-23T16:14:40.239Z
Learning: The team prefers simpler error handling in fastlane scripts and relies on fastlane's default error reporting mechanisms rather than adding explicit begin-rescue blocks around shell commands.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Contributor

@laevandus laevandus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool ✅

@testableapple testableapple merged commit 4d0b1d1 into develop Jul 24, 2025
14 checks passed
@testableapple testableapple deleted the ci/public-interface-analyser branch July 24, 2025 09:05
This was referenced Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 CI/CD Any work related to CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants