Skip to content

Commit

Permalink
Paywalls: update snapshot generation with submodule
Browse files Browse the repository at this point in the history
Follow up to #3115.
Note that this won't update the submodule commit that the branch is pointing to. But one all PRs are merged, one can easily update that one commit in your local PR.
  • Loading branch information
NachoSoto committed Aug 28, 2023
1 parent 305c26b commit 36239f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ jobs:
steps:
- run:
name: Run create_snapshot_pr
command: bundle exec fastlane create_snapshot_pr version:"revenuecatui-15"
command: bundle exec fastlane create_snapshot_submodule_pr version:"revenuecatui-15"
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
steps:
- run:
name: Run create_snapshot_pr
command: bundle exec fastlane create_snapshot_pr version:"revenuecatui-16"
command: bundle exec fastlane create_snapshot_submodule_pr version:"revenuecatui-16"
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
Expand Down Expand Up @@ -420,7 +420,7 @@ jobs:
steps:
- run:
name: Run create_snapshot_pr
command: bundle exec fastlane create_snapshot_pr version:"revenuecatui-17"
command: bundle exec fastlane create_snapshot_submodule_pr version:"revenuecatui-17"
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
Expand Down
27 changes: 23 additions & 4 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,34 @@ platform :ios do

desc "Creates a new PR after new snapshot files were generated"
lane :create_snapshot_pr do |options|
push_snapshot_pr(
version: options[:version],
repo: "revenuecat/purchases-ios",
files_to_add: "../*/__Snapshots__/*"
)
end

desc "Creates a new PR on purchases-ios-snapshots after new snapshot files were generated"
lane :create_snapshot_submodule_pr do |options|
Dir.chdir("../purchases-ios-snapshots") { |dir|
push_snapshot_pr(
version: options[:version],
repo: "revenuecat/purchases-ios-snapshots",
files_to_add: "."
)
}
end

private_lane :push_snapshot_pr do |options|
version = options[:version]
base_branch = ENV["CIRCLE_BRANCH"]

build_number = ENV["CIRCLE_BUILD_NUM"]

branch_name = "generated_snapshots/#{base_branch}-#{build_number}-#{version}"
sh("git", "checkout", "-b", branch_name)

sh("git", "add", "../*/__Snapshots__/*")
sh("git", "checkout", "-b", :branch_name)
sh("git", "add", options[:files_to_add])

file_count = sh("git diff --cached --numstat | wc -l").strip.to_i

if file_count == 0
Expand All @@ -447,7 +466,7 @@ platform :ios do
body = "Requested by @#{circle_user} for [#{base_branch}](#{branch_link})"

create_pull_request(
repo: "revenuecat/purchases-ios",
repo: options[:repo],
title: "Generating new test snapshots for `#{base_branch}` - #{version}",
body: body,
base: base_branch,
Expand Down

0 comments on commit 36239f0

Please sign in to comment.