Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Paywalls: update snapshot generation with new separate git repo (#3116
Browse files Browse the repository at this point in the history
)

Follow up to #3115.

Note that this won't update the commit that the branch is pointing to.
But one all PRs are merged, one can easily update that one commit in
your local PR.

Example:
https://github.com/RevenueCat/purchases-ios-snapshots/pull/4/files
NachoSoto committed Sep 14, 2023

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
1 parent 94df42f commit a1477ac
Showing 3 changed files with 40 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -345,7 +345,7 @@ jobs:
steps:
- run:
name: Run create_snapshot_pr
command: bundle exec fastlane create_snapshot_pr version:"revenuecatui-15"
command: bundle exec fastlane create_snapshots_repo_pr version:"revenuecatui-15"
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
@@ -375,7 +375,7 @@ jobs:
steps:
- run:
name: Run create_snapshot_pr
command: bundle exec fastlane create_snapshot_pr version:"revenuecatui-16"
command: bundle exec fastlane create_snapshots_repo_pr version:"revenuecatui-16"
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
@@ -404,7 +404,7 @@ jobs:
steps:
- run:
name: Run create_snapshot_pr
command: bundle exec fastlane create_snapshot_pr version:"revenuecatui-17"
command: bundle exec fastlane create_snapshots_repo_pr version:"revenuecatui-17"
- compress_result_bundle:
directory: fastlane/test_output
bundle_name: revenuecatui
37 changes: 29 additions & 8 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -427,42 +427,63 @@ platform :ios do
# Make request
headers = {"Circle-Token": circle_token, "Content-Type": "application/json", "Accept": "application/json"}
data = {parameters: {options[:pipeline] => true}, branch: branch}
url = "https://circleci.com/api/v2/project/github/RevenueCat/purchases-ios/pipeline"
url = "https://circleci.com/api/v2/project/github/RevenueCat/#{repo_name}/pipeline"

resp = RestClient.post url, data.to_json, headers

# Print workflow url
number = JSON.parse(resp.body)["number"]
workflow_url = "https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/#{number}"
workflow_url = "https://app.circleci.com/pipelines/github/RevenueCat/#{repo_name}/#{number}"

UI.important "Workflow: #{workflow_url}"
end

desc "Creates a new PR after new snapshot files were generated"
lane :create_snapshot_pr do |options|
version = options[:version]
base_branch = ENV["CIRCLE_BRANCH"]
push_snapshot_pr(
version: options[:version],
repo: "revenuecat/#{repo_name}",
base_branch: ENV["CIRCLE_BRANCH"],
files_to_add: "../*/__Snapshots__/*"
)
end

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

private_lane :push_snapshot_pr do |options|
version = options[:version]
base_branch = options[:base_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
UI.important("No files to be committed")
else
sh("git", "commit", "-m", "[skip ci] Generating new test snapshots")
push_to_git_remote
sh("git", "push", "origin", branch_name)

circle_user = ENV["CIRCLE_USERNAME"]
branch_link = "https://github.com/RevenueCat/purchases-ios/tree/#{base_branch}"
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,
8 changes: 8 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
@@ -250,6 +250,14 @@ Trigger CircleCI job to generate snapshots for RevenueCatUI

Creates a new PR after new snapshot files were generated

### ios create_snapshots_repo_pr

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

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

### ios compile_autogenerated_header

```sh

0 comments on commit a1477ac

Please sign in to comment.