Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate prepare hotfix #21

Merged
merged 26 commits into from
Nov 25, 2024
Merged

Migrate prepare hotfix #21

merged 26 commits into from
Nov 25, 2024

Conversation

kshann
Copy link
Contributor

@kshann kshann commented Nov 21, 2024

Task/Issue URL: https://app.asana.com/0/0/1208793082476405/f

Description:

  • Migrates prepare_hotfix lane and accompanying logic
  • Bugfix for extra tasks being retrieved by get_task_ids_from_git_log

@kshann kshann requested a review from ayoy November 21, 2024 13:02
kshann and others added 2 commits November 22, 2024 00:16
it needs ^{} at the end in order to extract a tagged commit from an annotated tag.
Using bare ^ makes it return the parent commit of a tagged commit.
Copy link
Contributor

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

Looks good overall! I added a small change to fix the usage of git rev-parse.

I'd like us to do something with the gh cli tool call for creating a branch - either replace it with Octokit API call, or, if possible, remove the is_ci condition and stick to git calls.

@@ -416,7 +416,7 @@ def self.get_task_ids_from_git_log(from_ref, to_ref = "HEAD")

git_log
.gsub("\n", " ")
.scan(%r{\bTask/Issue URL:.*?https://app\.asana\.com[/0-9f]+\b})
.scan(%r{\bTask/Issue URL:\s*https://app\.asana\.com[/0-9f]+\b})
Copy link
Contributor

Choose a reason for hiding this comment

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

👨‍🍳 💋

if Helper.is_ci?
sha = Actions.sh("git", "rev-parse", "#{source_version}^{}").strip
repo = Helper::GitHelper.repo_name(platform)
Actions.sh("gh", "api", "--method", "POST", "/repos/#{repo}/git/refs", "-f", "ref=refs/heads/#{branch_name}", "-f", "sha=#{sha}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather not use gh CLI tool directly in fastlane:

  • It requires GitHub token to be set (which needs to be done manually in the GHA step environment)
  • some of our actions (including start_new_release), already take GH token as parameter so it would require extra setup to have this work.

We have Octokit to access GitHub API. Can we create a helper function in git_helper to create a branch? Similar to existing merge_branch and delete_branch? Maybe called create_branch.

Alternatively, may be it's worth considering dropping the entire is_ci thing and just sticking to git fetch & checkout & push?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed is_ci, it forced me to update this seemed simplest approach, then it's just 3 simple git commands and no API interaction. This required me to check the branch out in macos workflow with the elevated token, which seems fine, see here .

Without this it is unable to push the branch due to workflow changes. See workflow if you're interested.

@@ -131,6 +131,138 @@ def load_file(file)
end
end

describe ".create_hotfix_branch" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder about using # in place of . :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, updated

Copy link
Contributor

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @kshann!

@kshann kshann merged commit f8f3d4d into main Nov 25, 2024
2 checks passed
@kshann kshann deleted the kieran/hotfix-release branch January 17, 2025 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants