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

Improve npm publishing infra #7287

Merged
merged 36 commits into from
Jan 24, 2023

Conversation

mattsoulanille
Copy link
Member

@mattsoulanille mattsoulanille commented Jan 19, 2023

The current npm publishing infra is more manual than necessary. This PR makes the following improvements:

  1. Publish all packages in a release unit with one command. Publishing no longer involves running yarn publish-npm multiple times.
  2. Stage all packages to a local verdaccio repository before publishing. This catches any compatibility issues that may appear when publishing to npm and allows us to build all packages before publishing any to npm.
  3. Publish with a single OTP. The previous infra required an OTP per package to publish to npm. This new infra publishes all packages sequentially after they're built, so it can use a single OTP for all of them. If another OTP is required due to the first one timing out, it asks for another.

A future PR will move our nightly verdaccio e2e tests to use this infra, which will allow us to avoid setting the npm registry globally. This will let us run verdaccio tests in parallel with the rest of nightly tests, which should reduce the time taken.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

mattsoulanille and others added 28 commits May 11, 2022 15:35
@@ -19,7 +19,7 @@ packages:
'@tensorflow/**':
access: $all
publish: $all
# Don't set proxy to avoid accidentally publishing to npm.
Copy link
Member Author

@mattsoulanille mattsoulanille Jan 19, 2023

Choose a reason for hiding this comment

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

This should not be possible without an OTP, so it's okay to set proxy to npm.

Copy link

@juanpicado juanpicado Jan 19, 2023

Choose a reason for hiding this comment

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

I think this statement is incorrect, the proxy property does not allow publishing on npmjs, in fact only works in one way, from npmjs to your local cache. If you set proxy: npmjs what is gonna happens is when you publish a package that match @tensorflow/** will ask first npmjs if already exist there or not, if you are publishing a snapshot with a random version probably will goes through allow yo to publish otherwise you will have 409 publish conflict. That's the unique thing the proxy does, but never never verdaccio publish on npmjs, this never happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the clarification. I was wondering if this comment was correct, and I couldn't find any description of this publishing behavior in the docs.

Choose a reason for hiding this comment

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

Thanks I'll try to highlight it better 👍🏼

@@ -25,108 +25,150 @@
import * as argparse from 'argparse';
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to reviewer: Just review this as a new file. It shares very little logic with the previous implementation.

@mattsoulanille
Copy link
Member Author

It may be worth writing tests for some parts of this PR, but we don't have any tests for our scripts directory yet. What do reviewers think about testing this code?

@mattsoulanille
Copy link
Member Author

mattsoulanille commented Jan 19, 2023

Nightly tests run with yarn nightly-cloudbuild, since this affects the verdaccio config file.

@mattsoulanille mattsoulanille marked this pull request as ready for review January 19, 2023 01:47
@mattsoulanille
Copy link
Member Author

Nightly tests 2

@mattsoulanille
Copy link
Member Author

Nightly tests 3

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 approvals obtained (waiting on @Linchenn and @mattsoulanille)


scripts/publish-npm.ts line 86 at r2 (raw file):

});

parser.addArgument(['--auto', '--guess-version'], {

the argument name does not seem to match the description, maybe auto-publish-local-newer?


scripts/publish-npm.ts line 180 at r2 (raw file):

          run(`${login}yarn --registry '${registry}' publish-npm ${dashes} ${otpFlag} --tag=${tag} --force`));
    } else {
      if (registry === NPM_REGISTRY && pkg.startsWith('tfjs-node')) {

should this be done after the publish is succeeded?


scripts/release-util.ts line 229 at r1 (raw file):

/**
 * A wrapper around shell.exec for readability.
 * @param cmd The bash commaond to execute.

command


scripts/release-util.ts line 243 at r1 (raw file):

export function $async(cmd: string,
		       env: Record<string, string> = {}): Promise<string> {

are there tabs on this line?


scripts/release-util.ts line 488 at r1 (raw file):

 * Get the next minor update version for the given version.
 *
 * i.e. given a.b.c, return a.b+1.0

a.b + 0.1.0 ?


e2e/scripts/local-registry.sh line 34 at r1 (raw file):

  # Set registry to local registry
  #npm set registry "$custom_registry_url"

remove these commented out lines?

Copy link
Member Author

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 approvals obtained (waiting on @Linchenn and @pyu10055)


scripts/publish-npm.ts line 86 at r2 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

the argument name does not seem to match the description, maybe auto-publish-local-newer?

Done.


scripts/publish-npm.ts line 180 at r2 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

should this be done after the publish is succeeded?

Good point. Done.


scripts/release-util.ts line 229 at r1 (raw file):

command
I'm not sure what you mean. I think the @param matches the argument name.


scripts/release-util.ts line 243 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

are there tabs on this line?

Not sure how that happened. Fixed.


scripts/release-util.ts line 488 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

a.b + 0.1.0 ?

This is saying the first part of the new version is a, the second part is b+1, and the third part is 0, so a . b+1 . 0. I replaced it with an example, which should be more clear.


e2e/scripts/local-registry.sh line 34 at r1 (raw file):

Previously, pyu10055 (Ping Yu) wrote…

remove these commented out lines?

I don't see them in the diff on github.

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 10 files at r1, 2 of 4 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @Linchenn)

Copy link
Collaborator

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

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

LGTM! Sorry for the late review.

@mattsoulanille
Copy link
Member Author

Nightly tests 4 (hopefully these don't have any weird connection issues like the last ones)

@mattsoulanille
Copy link
Member Author

Nightly tests 5

@mattsoulanille mattsoulanille merged commit 0a32b67 into tensorflow:master Jan 24, 2023
@mattsoulanille mattsoulanille deleted the release_automation branch January 24, 2023 00:27
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.

4 participants