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

Bail publish job before packaging and upload (passing tests) #14338

Closed
wants to merge 4 commits into from

Conversation

torhovland
Copy link
Contributor

Builds on #13501 with a fix that makes the tests pass. Fixes #3662.

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2024

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-interacts-with-crates.io Area: interaction with registries Command-login Command-owner Command-publish Command-search Command-yank S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2024
@torhovland
Copy link
Contributor Author

torhovland commented Aug 1, 2024

@hi-rustin, you recently refactored away the return tuple in fn cargo::ops::registry::registry(). Any thoughts about reintroducing a return tuple here?

@epage
Copy link
Contributor

epage commented Aug 1, 2024

@hi-rustin, you recently refactored away the return tuple in fn cargo::ops::registry::registry(). Any thoughts about reintroducing a return tuple here?

The goal with that refactor is less about removing the tuple and more about pulling work out of that function for reuse, like @jneem's recent transmit -> prepare_transmit + transmit refactor. Adding back in a tuple to access some of the other state is reasonable.


if !duplicate_query.is_empty() {
bail!(
"crate {} already has version {}. Aborting publish.",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what do you think of

"cannot publish {}@{} as that version already exists on {registry}",

or

"a {}@{} already exists on {registry}",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 139 to 148
.add_responder("/index/3/f/foo", move |req, server| {
let mut lock = arc.lock().unwrap();
*lock += 1;
if *lock <= 1 {
server.not_found(req)
} else {
server.index(req)
}
})
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't remember, was there a reason we couldn't publish the package like we normally do in tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was initially added because publish during tests did not have any memory of previously uploaded packages by default. Not sure if that changed, but test-publish works fine without this responder now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And it's updated.

@stupendoussuperpowers
Copy link
Contributor

As for the 2 failing tests -

credential_process::token_caching - This is failing because the test case tries to upload a package twice to test out two different scenarios. However it does it with the same version number and therefore our new code changes mean that the second test publish job bails. I have verified a fix for this locally where we just need to change the version and expected stdout.

registry_auth::token_not_logged - Here, we are logging the token 8 times instead of the previous 7. I wonder if this is because of the extra check we make to confirm whether the crate@version exists already? If so, we can either change the test to expect 8 logs (if that is the new accepted behaviour), or check why there's an extra log.

Let me know how I should proceed if we are okay with continuing with this solution.

CC: @torhovland

@epage
Copy link
Contributor

epage commented Aug 5, 2024

I think this approach, rather than set_quiet(true) makes more sense.

@stupendoussuperpowers
Copy link
Contributor

stupendoussuperpowers:dupl

@torhovland - all tests are passing with this. you can apply this patch and we should be good to go.

@torhovland
Copy link
Contributor Author

Good job!

@epage This is ready for another look.

@stupendoussuperpowers Will you follow up any feedback, please?

@stupendoussuperpowers
Copy link
Contributor

I'm assuming I'll have to rebase to be 2 commits - first with the test and second with the updates. Will get to it.

@torhovland
Copy link
Contributor Author

For simplicity, feel free to reopen #13501 and finish the work there.

@Rustin170506
Copy link
Member

@hi-rustin, you recently refactored away the return tuple in fn cargo::ops::registry::registry(). Any thoughts about reintroducing a return tuple here?

I think you are attempting to return a different type. What I removed from it is RegistrySourceIds, but what you actually want to return here is RegistrySource. So, I believe it is okay to add it.

Comment on lines +568 to +572
// 5. /index/3/f/foo for checking duplicate version
// 6. /api/v1/crates/new
// 7. config.json for the "wait for publish"
// 8. /index/3/f/foo for the "wait for publish"
assert_eq!(authorizations.len(), 8);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be squashed into the appropriate commit? Ideally all commits pass tests


p.cargo("publish")
.replace_crates_io(registry_dupl.index_url())
.with_stderr(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this commit be updated to be using the current testing style, rather than deferring that to later commits?

}
})
.build();
let registry_dupl = RegistryBuilder::new().http_api().http_index().build();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we update the original test with these changes?

@epage
Copy link
Contributor

epage commented Aug 7, 2024

It'd be a big help for the commits to be cleaned up

Either

  1. Add tests with them passing
  2. Bail early
  3. Fix double-message

or

  1. Add tests with them passing
  2. Change return type of registry
  3. Bail early

@bors
Copy link
Contributor

bors commented Sep 6, 2024

☔ The latest upstream changes (presumably #14433) made this pull request unmergeable. Please resolve the merge conflicts.

bors added a commit that referenced this pull request Sep 6, 2024
bail before packaging on same version

Fixes #3662. Cleaned up commits from #14338.
@stupendoussuperpowers
Copy link
Contributor

#14448 was merged with these fixes. I believe we can close this.

@epage epage closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interacts-with-crates.io Area: interaction with registries Command-login Command-owner Command-publish Command-search Command-yank S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail fast when package version is already published
7 participants