-
Notifications
You must be signed in to change notification settings - Fork 86
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
[eas-cli] add --auto flag to publish #549
[eas-cli] add --auto flag to publish #549
Conversation
ENG-1490 Automatically create branches on publish if branch does not exist
It is required to run The use case is when you're using a CI action to publish, you'd want to be able to publish each time you push a new branch/open a PR, so that you don't have to remember to create the branch before pushing your code to GitHub (for example). This is also nice locally, since when you get your code ready, it's nice to run one command. Possibly the solution is to create |
Size Change: +108 B (0%) Total Size: 37.8 MB
|
case 'Robot': { | ||
const { firstName, id } = actor as Pick<Robot, 'firstName' | 'id'>; | ||
actorName = firstName ?? `robot: ${id.slice(0, 4)}...`; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not strictly related to the --auto
addition. Noticed we missed a case when fixing up the typing. Curious if this will fix that robot issue @jonsamp was having?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should do it! Thanks for adding this along the way
|
||
const { id: branchId, updates } = await viewUpdateBranchAsync({ | ||
assert(branchName, 'branch name must be specified.'); | ||
const { id: branchId, updates } = await ensureBranchExists({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer throw if branch doesn't exist. Create it instead.
@@ -107,13 +137,19 @@ export default class BranchPublish extends Command { | |||
description: `return a json with the new update group.`, | |||
default: false, | |||
}), | |||
auto: flags.boolean({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider sth more descriptive, meaning of the auto in context of publishing is not really obvious
--auto-branch
/--auto-message
--managed
or use --non-interactive
flag and if values are not provided via --message
/--branch
us those defaults
Also if you are considering adding updates config to eas.json, options like this would be a good candidate for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with --non-interactive
is that is not clear that this means "apply an opinionated default" instead of "throw if essential args are not provided"
--auto-branch/--auto-message
are nice, but maybe too verbose?
Also if you are considering adding updates config to eas.json, options like this would be a good candidate for it
Interesting idea, I'm a bit hesitant to engage there right now as it is in such flux that things tend to get reverted. Maybe once things get more established?
@jonsamp curious what you think about these other flag suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that --auto-branch
and --auto-message
are more verbose, and therefore not as developer-friendly. I also suggested --non-interactive
or --ci
previously, but I agree with JJ that --auto
is more correct here since we're applying an opinionated default.
I like --auto
. Also, this is pretty low-stakes, since we can always change this flag if our beta users are confused by it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the discussion, will go with --auto
for now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some questions and suggestions but this code looks good to me. Excited to use this feature!
@@ -107,13 +137,19 @@ export default class BranchPublish extends Command { | |||
description: `return a json with the new update group.`, | |||
default: false, | |||
}), | |||
auto: flags.boolean({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that --auto-branch
and --auto-message
are more verbose, and therefore not as developer-friendly. I also suggested --non-interactive
or --ci
previously, but I agree with JJ that --auto
is more correct here since we're applying an opinionated default.
I like --auto
. Also, this is pretty low-stakes, since we can always change this flag if our beta users are confused by it.
if (!name) { | ||
if (!branchName && autoFlag) { | ||
branchName = | ||
(await vcs.getBranchNameAsync()) || `branch-${Math.random().toString(36).substr(2, 4)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create another task to make the getBranchNameAsync
work inside GitHub Actions. The command this runs is git rev-parse --abbrev-ref HEAD
, which works locally, but results in this error during a GitHub Action:
This is not a blocker for this PR, and this should generally not be a problem for CI, since we can pass in the branch name/message programmatically. But it'd be great to run eas branch:publish --auto
locally, and then write the same command for the CI action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.git repository should exist after checkout, if it doesn't then I think it's bug in github action.
Seems like it might be cause by old git version in the image
actions/checkout#335
actions/checkout#126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonsamp let me know if @wkozyra95 suggestions for the github action don't work out.
@@ -271,6 +311,10 @@ export default class BranchPublish extends Command { | |||
} | |||
} | |||
|
|||
if (!message && autoFlag) { | |||
message = (await vcs.getLastCommitMessageAsync())?.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case 'Robot': { | ||
const { firstName, id } = actor as Pick<Robot, 'firstName' | 'id'>; | ||
actorName = firstName ?? `robot: ${id.slice(0, 4)}...`; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should do it! Thanks for adding this along the way
if (!name) { | ||
if (!branchName && autoFlag) { | ||
branchName = | ||
(await vcs.getBranchNameAsync()) || `branch-${Math.random().toString(36).substr(2, 4)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.git repository should exist after checkout, if it doesn't then I think it's bug in github action.
Seems like it might be cause by old git version in the image
actions/checkout#335
actions/checkout#126
Co-authored-by: Jon Samp <sampjon@gmail.com>
Checklist
[EAS BUILD API]
if it's a part of a breaking change to EAS Build API (only possible when updating@expo/eas-build-job
package).Why
We want a flag to automatically set the branch name and update message to the git branch and commit message.
Also made command create a branch if it doesn't already exist.
Test Plan
Tested in demo repo.