Skip to content

Commit

Permalink
Diff Swift interface classes
Browse files Browse the repository at this point in the history
  • Loading branch information
porter-stripe committed Apr 12, 2024
1 parent 099eb0d commit 9f992cf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/verify-public-interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ jobs:
-output "./StripePaymentSheet-new.xcframework"
echo "Generating public interface diff..."
xcrun swift-api-digester \
-diagnose-sdk \
-input-paths StripePaymentSheet-master.xcframework/ios-arm64_x86_64-simulator/StripePaymentSheet.framework/Modules/StripePaymentSheet.swiftmodule/x86_64-apple-ios-simulator.abi.json \
-input-paths StripePaymentSheet-new.xcframework/ios-arm64_x86_64-simulator/StripePaymentSheet.framework/Modules/StripePaymentSheet.swiftmodule/x86_64-apple-ios-simulator.abi.json
export API_DIFF=$(ruby ci_scripts/diff_pubilc_interface.rb \
StripePaymentSheet-master.xcframework/ios-arm64_x86_64-simulator/StripePaymentSheet.framework/Modules/StripePaymentSheet.swiftmodule/x86_64-apple-ios-simulator.abi.json \
StripePaymentSheet-new.xcframework/ios-arm64_x86_64-simulator/StripePaymentSheet.framework/Modules/StripePaymentSheet.swiftmodule/x86_64-apple-ios-simulator.abi.json)
echo "API_DIFF=$API_DIFF" >> $GITHUB_ENV
- name: Check for modified or added APIs
id: check-api
Expand All @@ -96,7 +97,7 @@ jobs:
body: |
⚠️ Change in public APIs detected:
```
```diff
${{ env.API_DIFF }}
```
Expand Down
20 changes: 20 additions & 0 deletions ci_scripts/diff_public_interface.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'open3'

def diff(old_path, new_path)
stdout, _stderr, _status = Open3.capture3("diff", "-u", old_path, new_path)

stdout.lines.map do |line|
case line[0..1]
when "+ " then "+ #{line[2..-1].strip}"
when "- " then "- #{line[2..-1].strip}"
else nil
end
end.compact.join("\n")
end

if ARGV.length < 2
puts "Please provide two files to diff."
exit
end

puts diff(ARGV[0], ARGV[1])

0 comments on commit 9f992cf

Please sign in to comment.