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

Set default branch to master if not set from git #1558

Merged
4 commits merged into from
Apr 20, 2021

Conversation

sima-zhu
Copy link
Contributor

@sima-zhu sima-zhu commented Apr 14, 2021

Two changes in PR:

  1. Set default branch to master if not set from git command. Add continueOnError: true to unblock any failed places.
    E.g. https://dev.azure.com/azure-sdk/internal/_build/results?buildId=838864&view=logs&j=b70e5e73-bbb6-5567-0939-8415943fadb9&t=bdeefc16-b669-5ebd-ad94-a2c19ade53b0

Testing pipeline right here: https://dev.azure.com/azure-sdk/playground/_build/results?buildId=845015&view=logs&j=38d918fc-df5a-5870-2b80-6c17fdb13baf&t=489baed9-6f06-5266-9d0d-079a130738b4
2. git-push-changes.yml checked whether local has changes. Make the changes so if we need to skip checking changes somehow, we are able to execute the scripts.
E.g: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=842830&view=logs&j=321fe29c-d6e3-5c98-996f-e7c628f12971&t=71fd3457-22c6-5475-4ae6-23dcf07ca155

@sima-zhu sima-zhu requested a review from a team as a code owner April 14, 2021 22:05
@sima-zhu sima-zhu requested review from weshaggard and removed request for a team April 14, 2021 22:05
@sima-zhu sima-zhu self-assigned this Apr 14, 2021
@sima-zhu sima-zhu added the Central-EngSys This issue is owned by the Engineering System team. label Apr 14, 2021
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@@ -41,7 +41,7 @@ steps:

- task: PowerShell@2
displayName: Push changes
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
condition: and(succeeded(), ne(variables['HasChanges'], 'false'))
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? We want to make sure we don't accidently start pushing these changes unless someone has explicitly set it to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Several cases here:

  1. Step Check for changes executes:
  • git diff success: Then HasChange=true, we run git push on purpose.
  • git diff fail: Then HasChange=false, we skip git push on purpose.
  1. Step Check for changes skips, then HasChanges not set, we will run git push step anyway:
  • If people intended to check in some commits to branch, then they have to literally put PushArgs: -f. (This is the purpose of the changes. In my case, I fetch some commits in master, and then merge the commits into live branch)
  • If PushArgs not set, then the script will fail. We have to take care of this case which not fail previously.

Copy link
Member

Choose a reason for hiding this comment

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

  1. That is has intended.
  2. If you set the value to skip the check for changes then you are in charge of setting HasChanges to true if there are changes that are interesting. We want to avoid blindly pushing changes in a case where someone doesn't set HasChanges at all.

As far as I'm aware this logic is working exactly has intended and if there is some scenario where you feel it is working please give me the specific case as I suspect that case needs to be address individually instead of changing the common template logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree with you as the changes here might breaking some feature. I removed it from this PR. Will open a new one if it is needed.

Write-Host "Setting DefaultBranch=$setDefaultBranch"
echo "##vso[task.setvariable variable=DefaultBranch]$setDefaultBranch"
displayName: "Setup Default Branch"
workingDirectory: ${{ parameters.workingDirectory }}
continueOnError: true
Copy link
Member

Choose a reason for hiding this comment

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

This will end up turning the pipeline yellow which we should try to avoid. Please do a test build on a private pipeline with this change and lets see how we can make this silent (i.e. no warnings/errors) only the write-host message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will have a pipeline on my private fork repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ok that looks better.

@sima-zhu sima-zhu requested a review from weshaggard April 15, 2021 19:00
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

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

The set-default-branch changes look good but I'd like to either undo or better understand why you need to change get-push-changes.

@sima-zhu sima-zhu requested a review from weshaggard April 19, 2021 19:11
@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@ghost
Copy link

ghost commented Apr 20, 2021

Hello @azure-sdk!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 0471218 into Azure:master Apr 20, 2021
@sima-zhu sima-zhu deleted the set_default_private branch April 20, 2021 23:28
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants