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 30, 2023
1 parent e5b53e3 commit 53518d5
Show file tree
Hide file tree
Showing 3 changed files with 34 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 @@ -353,7 +353,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 @@ -383,7 +383,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 @@ -412,7 +412,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 @@ -428,15 +428,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 @@ -450,7 +469,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
8 changes: 8 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ Trigger CircleCI job to generate snapshots for RevenueCatUI

Creates a new PR after new snapshot files were generated

### ios create_snapshot_submodule_pr

```sh
[bundle exec] fastlane ios create_snapshot_submodule_pr
```

Creates a new PR on purchases-ios-snapshots after new snapshot files were generated

### ios compile_autogenerated_header

```sh
Expand Down

0 comments on commit 53518d5

Please sign in to comment.