113 Commits

Author SHA1 Message Date
hi-rustin
0b06a456f2 Make blocking tests non blocking 2023-02-23 09:11:52 +08:00
Arlo Siemsen
7dc5506756 Stabilize sparse-registry 2023-01-05 11:04:52 -06:00
Weihang Lo
3d862d8d8b
by default saves credentials to .cargo/credentials.toml 2023-01-04 16:25:52 +00:00
Jacob Finkelman
83387da305 put some RFC text into documentation 2022-12-13 17:09:53 +00:00
Jacob Finkelman
2ac15086fb end-to-end tests 2022-12-12 21:50:08 +00:00
Arlo Siemsen
9827412fee Implement RFC 3139: alternative registry authentication support 2022-11-16 14:36:19 -06:00
Arlo Siemsen
90c6b5854d Fix waiting for publishing to complete when publishing to a sparse registry 2022-11-08 18:14:52 -06:00
Ed Page
d87966b466 test(publish): Require extra waits 2022-11-02 16:42:14 -05:00
Ed Page
6998fb3896 test(publish): Verify updating existing entries works 2022-11-02 10:39:21 -05:00
Ed Page
4dc2e405e6 test(publish): Don't pre-publish 2022-11-02 10:37:28 -05:00
Anton Lazarev
9333b8f5ba
update package, publish, and publish_lockfile tests 2022-10-28 17:13:25 -07:00
bors
7e484fc1a7 Auto merge of #11062 - epage:wait, r=weihanglo
fix(publish): Block until it is in index

Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension.  When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates.  I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check.  In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.

This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
  into
- crates-index has re-implemented index support incorrectly in the past,
  currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
  workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
  delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
  might not be sufficient
- Once the sparse registry is available, crates-index users will find
  out when the package is ready in git but it might not be ready through
  the sparse registry because of CDNs

So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
  are propagation delays.  This has the side effect of being noisy
  because of all of the "Updating index" messages.
- This blocks by default but there is an unstable `publish.timeout` config field that will disable blocking when set to 0.  See #11222 for stablization

Blocking is opt-out as that is the less error prone case for casual users while those doing larger integrations are also likely to do the testing needed to make more complicated scenarios work where blocking is disabled.

Right now we block after the publish.  An alternative would be to block until all dependencies are in the index which makes the blocking only happen when needed
- Blocking on dependencies can be imprecise to detect when to block vs propagate an error up
- This is the less error prone case for users.  For example I recently publish a crate in one tab and immediately switched to another tab to use it and this only worked because `cargo-release` blocked until it was ready to use

In reviewing this change, be sure to look at the individual commits
- The first makes it possible to write the tests for this
- The second adds a test that shows the current behavior
- The third updates the test to the expected behavior, showing all of this works

In addition to the publish tests:
- We want to maximize the nightly-to-stable time to collect feedback
- We will put this in TWiR's testing section to raise visibility

Fixes #9507
2022-10-27 15:20:57 +00:00
bors
da63337681 Auto merge of #11283 - arlosi:sparse-error, r=weihanglo
Fix confusing error messages when using -Zsparse-registry

Built-in replacements of crates.io have confusing a description:
> crates.io index (which is replacing registry `crates-io`)

This adds a special case for built-in source replacements of `crates-io`. User-defined replacements of crates.io continue to use the existing description.

Also fixes the test framework `__CARGO_TEST_CRATES_IO_URL_DO_NOT_USE_THIS` variable to strip the `sparse+` prefix when checking if a url `is_crates_io`.

Fixes #11277
2022-10-26 04:09:55 +00:00
Arlo Siemsen
40293266b2 Fix confusing error messages when using -Zsparse-registry 2022-10-25 13:51:43 -05:00
hi-rustin
6c9f36d99b Update not in list error message
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-10-24 22:50:25 +08:00
hi-rustin
66a8488cf6 Update error messages for tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-10-24 21:25:47 +08:00
Ed Page
f2fc5ca86d fix(publish): Block until it is in index
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension.  When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates.  I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check.  In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.

This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
  into
- crates-index has re-implemented index support incorrectly in the past,
  currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
  workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
  delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
  might not be sufficient
- Once the sparse registry is available, crates-index users will find
  out when the package is ready in git but it might not be ready through
  the sparse registry because of CDNs

So now `cargo` will block until it sees the package in the index.
- This is checking via the index instead of server APIs in case there
  are propagation delays.  This has the side effect of being noisy
  because of all of the "Updating index" messages.
- This is done unconditionally because cargo used to block and that
  didn't seem to be a problem, blocking by default is the less error
  prone case, and there doesn't seem to be enough justification for a
  "don't block" flag.

The timeout was 5min but I dropped it to 1m.  Unfortunately, I don't
have data from `cargo-release` to know what a reasonable timeout is, so
going ahead and dropping to 60s and assuming anything more is an outage.

Fixes #9507
2022-10-13 12:56:40 -05:00
Ed Page
04d836fa71 feat(publish): Support 'publish.timeout' config behind '-Zpublish-timeout'
Originally, crates.io would block on publish requests until the publish
was complete, giving `cargo publish` this behavior by extension.  When
crates.io switched to asynchronous publishing, this intermittently broke
people's workflows when publishing multiple crates.  I say interittent
because it usually works until it doesn't and it is unclear why to the
end user because it will be published by the time they check.  In the
end, callers tend to either put in timeouts (and pray), poll the
server's API, or use `crates-index` crate to poll the index.

This isn't sufficient because
- For any new interested party, this is a pit of failure they'll fall
  into
- crates-index has re-implemented index support incorrectly in the past,
  currently doesn't handle auth, doesn't support `git-cli`, etc.
- None of these previous options work if we were to implement
  workspace-publish support (#1169)
- The new sparse registry might increase the publish times, making the
  delay easier to hit manually
- The new sparse registry goes through CDNs so checking the server's API
  might not be sufficient
- Once the sparse registry is available, crates-index users will find
  out when the package is ready in git but it might not be ready through
  the sparse registry because of CDNs

This introduces unstable support for blocking by setting
`publish.timeout` to non-zero value.

A step towards #9507
2022-10-13 08:53:36 -05:00
Scott Schafer
66b62d2745 test(publish): Demonstrate the impact of non-blocking publish 2022-10-13 08:40:26 -05:00
Scott Schafer
8fadfe7f33 test(registry): Allow custom_responders to call normal responders 2022-10-13 08:40:26 -05:00
Ed Page
487d7e5268 refactor(tests): Publish using a real registry 2022-10-11 15:24:54 -05:00
Ed Page
33ba607783 refactor(tests): Hack publish to balance testing/wait_for_publish 2022-10-10 13:10:29 -05:00
Ed Page
8995e84124 docs(tests): Clarify why a local registry is preferred 2022-10-10 13:05:56 -05:00
Ed Page
08df53ba48 refactor(tests): Be explicit about publish stderr 2022-10-10 13:03:20 -05:00
Ed Page
5e5b5325be refactor(tests): Be more explicit about publish stderr
This will help find tests timing out due to #11062
2022-10-10 12:54:32 -05:00
Ed Page
5e1a647924 refactor(tests): Consistent predicate ordering 2022-10-10 12:50:54 -05:00
Ed Page
af82aa0b68 refactor(tests): Remove redundant with_status(0) 2022-10-10 12:45:46 -05:00
Ed Page
0846b8eba4 refactor(tests): Document case outside the test, rather than in
This will make it easier to document some of the lines of code
2022-10-10 12:42:53 -05:00
Arlo Siemsen
dd5134c7a5 Implement RFC 3289: source replacement ambiguity 2022-10-07 22:30:59 -05:00
Arlo Siemsen
dcc512b317 Add retry support to sparse registries 2022-10-07 12:00:24 -05:00
Scott Schafer
ab18bd40d5 refactor(testsuite): Replace [project] with [package] 2022-09-26 09:51:16 -06:00
Scott Schafer
251a2c7915 cargo-test-support: Make publish http api write to file system 2022-09-22 10:00:49 -06:00
Wim Looman
492358a19f
Only override published resolver when the workspace is different 2022-08-10 09:26:50 +02:00
Wim Looman
d953c3b2d7
Override to resolver=1 in published package 2022-07-29 16:03:05 +02:00
Arlo Siemsen
24dac452c5 Improve testing framework for http registries
Improve integration of the http server introduced by the http-registry feature.
Now the same HTTP server is used for serving downloads, the index, and
the API.

This makes it easier to write tests that deal with authentication and
http registries.
2022-06-10 16:51:35 -05:00
likzn
b486ada19f clean err msg 2022-05-26 08:49:06 +08:00
likzn
52165e8c2d update 2022-05-25 18:17:08 +08:00
likzn
72d6c5411a cargo fmt 2022-05-24 09:15:44 +08:00
likzn
72457ef462 fix test stderr 2022-05-24 09:09:57 +08:00
likzn
1179e7ef6b cargo fmt 2022-05-23 21:06:34 +08:00
likzn
89c24bf811 refactor logic 2022-05-23 21:01:55 +08:00
likzn
a5a0f6809d fix typo 2022-05-18 23:42:42 +08:00
likzn
95cb21d6a1 fix cargo -p 2022-05-18 22:40:55 +08:00
Ed Page
0f75237617 test: Fix compatibilty with new toml_edit
`toml_edit` fixed a bug in 0.13.4 that this test was relying on that is
meant to help with rust-lang/cargo#10349.  This basically restores us
back to the pre-toml_edit behavior for published manifests.
2022-01-31 10:57:38 -06:00
Ed Page
320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
l00556901
cf621fdc94 modify test 2021-12-02 19:55:56 +08:00
l00556901
64c69dffc5 fix some bugs 2021-12-01 11:21:06 +08:00
l00556901
56b8ae7c44 delete --host command and message 2021-12-01 10:29:46 +08:00
Eric Huss
30ff8424c9 Remove unnecessary format! 2021-07-26 12:56:53 -07:00
tcmal
8f1f0e40fd feat(package+publish): package arguments
adds -p, --workspace, and --exclude to package command,
and -p to publish command, as well as tests for both.

closes #7345
2021-07-26 16:31:58 +01:00