microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.94k stars 598 forks source link

[rush] 'publish' exits with error code when remote branch has changes - but packages and tags are pushed as expected #2049

Open crhaglun opened 4 years ago

crhaglun commented 4 years ago

Is this a feature or a bug?

Please describe the actual behavior.

We have a dedicated build pipeline for "rush publish", scheduled weekly + occasional manual runs.

Fairly often this pipeline fails when pushing git tags because of updates on the target branch happening while "rush publish" is running.

The git tags are actually pushed, but the update of HEAD fails causing the whole operation to fail;

Invoking "rush publish --publish --include-all -b master --registry https://instance.pkgs.visualstudio.com/_packaging/project/npm/registry/ -n ***"
---------------------------------------------------------------------------------------------------------------------------------------------------

Rush Multi-Project Build Tool 5.23.2 - https://rushjs.io
Node.js version is 10.15.3 (LTS)

Starting "rush publish"

Validating package manager shrinkwrap file.

Rush publish starts with includeAll and version policy undefined

* EXECUTING: D:\a\1\s\common\temp\pnpm-local\node_modules\.bin\pnpm publish --//instance.pkgs.visualstudio.com/_packaging/project/npm/registry/:_authToken=<<SECRET>> (packages\components\component)

<npm output omitted>

* EXECUTING: git tag -a @namespace/component_v1.2.79 -m @namespace/component_v1.2.79 

* EXECUTING: git push origin HEAD:master --follow-tags --verbose --no-verify 
POST git-receive-pack (245289 bytes)
Pushing to https://instance.visualstudio.com/Project/_git/repo
To https://instance.visualstudio.com/Project/_git/repo
 * [new tag]             @namespace/component_v1.2.79 -> @namespace/component_v1.2.79
 ! [rejected]            HEAD -> master (fetch first)
error: failed to push some refs to 'https://instance.visualstudio.com/Project/_git/repo'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ERROR: The command failed with exit code 1

If the issue is a bug, how can we reproduce it? Please provide detailed steps and include a GitHub branch if applicable. Your issue will get resolved faster if you can make it easy to investigate.

Run "rush publish" on a commit that's not the most recent commit on a branch (like master~1)

A very similar problem was reported on semantic-release: https://github.com/semantic-release/semantic-release/issues/993 Fixed in that project by omitting 'HEAD:branchname' from the "git push" command. Is that a plausible fix here as well?

What is the expected behavior?

Since this is not a functional problem -- NPM packages are pushed and git tags are indeed updated correctly -- it's a bit unexpected that the command exits with an error code.

If this is a bug, please provide the tool version, Node.js version, and OS.

apostolisms commented 4 years ago

This is an issue with the current functionality. We eventually want to redesign publish. In the meantime to mitigate this you can try bumping in the beginning of the pipeline.

crhaglun commented 4 years ago

Ah, we're already doing 'rush bump' just before 'rush publish' :-) This is a Microsoft internal project, let me know if it would be meaningful to give you a direct link to the repo and build pipeline.

How do you intend to redesign 'rush publish'? Are there other changes needed than the one described here?

Since my team is affected, I'd be happy to help out expedite this work instead of spending time implementing some workaround.

dabelt-msft commented 3 years ago

Hi @apostolisms, any update on this?