Commit Graph

754 Commits

Author SHA1 Message Date
Ed Page 633929d3aa refactor(schemas): Pull out `cargo-util-schemas` crate
Fixes #12801
2023-12-15 13:22:25 -06:00
bors 9c1316ff3f Auto merge of #13181 - hi-rustin:rustin-patch-rename-files, r=weihanglo
chore(rustfix): rename Readme.md to README.md
2023-12-18 15:04:01 +00:00
hi-rustin 0b6c229e9d chore(rustfix): remove useless clippy rules
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-18 20:17:05 +08:00
hi-rustin b8e2f75881 chore(rustfix): fix a typo
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-18 20:10:28 +08:00
hi-rustin efdaf4bbc6 chore(rustfix): rename `Changelog.md` to `CHANGELOG.md`
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-18 20:05:52 +08:00
hi-rustin 88993a3bbe chore(rustfix): rename `Readme.md` to `README.md`
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-12-18 20:04:50 +08:00
Ed Page c7bcc6c199
docs(home): Set release date 2023-12-15 12:32:15 -06:00
Guillaume Dallenne 7ce9c26f39
docs(home): prepare the changelog for 0.5.9 2023-12-15 19:04:51 +01:00
Chris Denton 6e11c77384
Replace SHGetFolderPathW with SHGetKnownFolderPath 2023-12-15 03:36:39 +00:00
Weihang Lo 516313379e
chore(bump-check): dont check home against beta/stable branches
The publish of home is not tied with Rust release process, hence.
2023-12-13 18:21:55 -05:00
bors 1aa9df1a5b Auto merge of #13158 - Turbo87:crates-io-status-codes, r=epage
crates-io: Add support for other 2xx HTTP status codes

Replying with `201 Created` of `202 Accepted` should not result in showing errors.

Related:

- https://github.com/rust-lang/cargo/issues/3995
- https://github.com/rust-lang/cargo/pull/6771
2023-12-12 14:52:31 +00:00
Tobias Bieniek 32d4c0fd80
crates-io: Add support for other 2xx HTTP status codes
Replying with `201 Created` of `202 Accepted` should not result in showing errors.
2023-12-12 13:33:03 +01:00
Ed Page 808e2a174f refactor(schema): Adopt RustVersion 2023-12-11 13:44:14 -06:00
bors 749654c5fd Auto merge of #13132 - arlosi:cachedir, r=epage
Avoid writing CACHEDIR.TAG if it already exists

Cargo currently unconditionally writes `CACHEDIR.TAG` files even if they already exist.

This practice causes problems for build systems that disallow multiple writes to the same file.
2023-12-07 22:37:55 +00:00
Arlo Siemsen 04af5e7a06 Avoid writing CACHEDIR.TAG if it already exists 2023-12-07 14:51:01 -06:00
Ed Page 96f8517a28 test(mdman): Switch to snapbox
- We use it elsewhere
- We don't have to bake our own snapshotting solution
- It is more obvious how to update the snapshots
2023-12-01 15:31:27 -06:00
renovate[bot] ab6adab01b
chore(deps): update compatible 2023-12-01 17:33:18 +00:00
Ed Page 378502bf20 refactor: Try to make PackageId conversion clearer 2023-12-01 10:48:14 -06:00
bors c192d989b3 Auto merge of #13091 - weihanglo:trim-paths-lldb, r=epage
test(trim-paths): exercise with real world debugger
2023-12-01 15:47:10 +00:00
Weihang Lo 5c32fe0432
test(trim-paths): exercise with real world debugger 2023-12-01 08:48:24 -05:00
Eric Huss 1aa769240d Add more options to registry test support. 2023-11-30 16:39:08 -08:00
Ed Page a43e09073c test(resolver): Don't bother generating public cases 2023-11-29 13:11:39 -06:00
Ed Page e6da166c8b test(resolver-tests): Remove public dep support from SAT resolver 2023-11-29 12:17:26 -06:00
Ed Page 71172d52b5 fix(resolver): Remove unused public-deps error handling
To implement rust-lang/rfcs#3516, we need to decouple the resolver's
behavior from the unstable flag.  Since the code path is now dead, I
went ahead and removed it.
2023-11-22 15:20:10 -06:00
Weihang Lo 21274da65b
chore: bump `rustfix` to 0.7.0 2023-11-27 10:50:10 -05:00
Weihang Lo ed347ce4dc
refactor: use custom error instead of anyhow 2023-11-27 10:50:10 -05:00
bors 3920bd5ea5 Auto merge of #13047 - tompscanlan:rustfix-ignored-tests, r=weihanglo
review and remove ignored tests in rustfix

### What does this PR try to resolve?
review ignored tests in rustfix crate per #13034.

### How should we test and review this PR?
CI testing

### Additional information

* Removed unproductive test in `parse_and_replace`
* un-ignore proptests, and reduce runtime from ~2s to ~<.25s
2023-11-26 17:14:11 +00:00
Tom Scanlan b179cd175a
review and remove ignored tests in rustfix
* reduce time in proptest
* delete edition dir
* remove refs to fixmode::EDITION
2023-11-26 09:29:18 -05:00
bors 35ed69cb1b Auto merge of #13048 - weihanglo:rustfix-doc, r=epage
docs: add doc comments for rustfix
2023-11-25 23:45:45 +00:00
Weihang Lo 358b7ae76d
docs(rustfix): add more doc comments 2023-11-25 17:48:21 -05:00
Weihang Lo 27b7c6c203
docs(rustfix): comments for diagnostic JSON output
Most doc comments are copied from rust-lang/rust repo.

The doc for each item is hand-written as there is no comment in the
original place.
2023-11-25 13:09:39 -05:00
Tom Scanlan e9e22e5c2f try running on windows 2023-11-23 18:34:56 -05:00
bors 65d0eb536d Auto merge of #12997 - hi-rustin:rustin-patch-cargo-test-support, r=epage
cargo-test-support: Add features to the default Cargo.toml file
2023-11-22 01:47:31 +00:00
bors eed300d5e8 Auto merge of #13005 - ehuss:rustfix, r=weihanglo
Migrate rustfix to the cargo repo

This migrates the `rustfix` crate from https://github.com/rust-lang/rustfix/ to the cargo repo. The cargo team has been responsible for the client-side of `cargo fix`, and it can make it easier to maintain with all our tooling and tracking here. This crate is used by some external parties (like the compiler), so it will need to be maintained like an "ecosystem" package, but hopefully there shouldn't be any outside requirements (I haven't seen any in several years).

After merging, I'll follow up with some things to address in the future, such as:
- Migrating issues from the other repo.
- Opening new issues for some cleanup tasks, such as adding documentation, fixing the `#[ignore]` annotations, fixing testing on windows, maybe migrating the test code to use different dependencies, various code cleanup.
- Archiving the repo.
2023-11-21 18:36:36 +00:00
Eric Huss 47c7ff0f96 Deduplicate the similar dependency. 2023-11-21 10:18:15 -08:00
Eric Huss 70f56e9004 Add a general introduction to the rustfix library docs. 2023-11-21 10:10:22 -08:00
Eric Huss 402d072d72 Ignore rustfix for semver-checks since it doesn't exist on the beta branch. 2023-11-21 10:02:14 -08:00
David Tolnay 65bb09d434
Handle $message_type in JSON diagnostics 2023-11-19 20:37:16 -08:00
Eric Huss f99a494c31 Remove copyright headers in tests.
These were all removed a while ago in https://github.com/rust-lang/rust/pull/57108
2023-11-19 08:20:21 -08:00
Eric Huss b5308f648b Fix tests to run on stable. 2023-11-19 08:17:17 -08:00
Eric Huss d6e49ca06b Fix clippy warnings. 2023-11-19 08:07:37 -08:00
hi-rustin 504c4b2fbb Add optional flag to manifest for dependencies
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-19 22:04:04 +08:00
hi-rustin 12d7818192 Add features to the default Cargo.toml file
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-11-19 22:03:57 +08:00
Eric Huss b8ba6cd333 Bump the rustfix version. 2023-11-18 18:46:34 -08:00
Eric Huss 6e798b39bd Update rustfix readme to be a little more current. 2023-11-18 18:44:40 -08:00
Eric Huss a4fd77ce35 Switch rustfix license files to be symlinks 2023-11-18 18:31:08 -08:00
Eric Huss 63830afede Remove some unused rustfix files. 2023-11-18 18:29:58 -08:00
Eric Huss 3c0126aec4 rustfix: Drop test dependency on duct
It didn't seem to be doing anything that `Command` doesn't already
support. This helps lighten the dependency size.
2023-11-18 18:21:01 -08:00
Eric Huss f25cc63617 Update rustfix to use a newer proptest.
This uses the same version used elsewhere in cargo.
2023-11-18 18:14:00 -08:00
Eric Huss d0d9bd5cbb Switch rustfix to using tracing instead of log.
This helps bring it in line with the rust of cargo.
2023-11-18 18:10:44 -08:00
Eric Huss 9cb59bc202 Idiom lints are now configured in the manifest. 2023-11-18 17:49:18 -08:00
Eric Huss 3ca00ad8cd Integrate rustfix's manifest into the workspace. 2023-11-18 17:40:20 -08:00
Eric Huss 2eac6f5c0c Fix clippy-wrapper test race condition. 2023-11-18 17:23:29 -08:00
Eric Huss 73e5506338 Merge remote-tracking branch 'rustfix/master' into rustfix 2023-11-18 16:51:22 -08:00
Weihang Lo e2f5925bb0
chore: bump version for member crates 2023-11-16 13:19:44 -05:00
Weihang Lo 7a4754a1d3
lint: allow `print_stdout` and `print_stderr` 2023-11-16 11:35:21 -05:00
Weihang Lo 870f9ea7b3
lint: allow `disallow_methods` 2023-11-16 11:35:21 -05:00
Weihang Lo 1539b3dfc1
lint: dogfood ourselves `lints` table in manifest
These lint rules are from src/lib.rs. We aim to remove
them in the source code once `Zlints` hit stable.
2023-11-16 11:35:21 -05:00
Eric Huss 1d35833e3b Switch from AtomicU64 to Mutex.
Not all platforms support AtomicU64, so this swaps the usage with
Mutex. The difference in performance should be imperceptible.
2023-11-15 14:41:56 -08:00
Jacob Finkelman 6835fa3867 query{_vec} should use IndexSummary 2023-11-13 19:39:25 +00:00
Eric Huss 80ffb1de1c Fix --quiet being used with nested subcommands.
This fixes an issue where `--quiet` doesn't work with commands that have
subcommands. This is because `config_configure` only looks at the global
and top-level subcommand, and not deeper subcommands. The issue was that
`--quiet` was not defined as a global flag. This was changed in
https://github.com/rust-lang/cargo/pull/6358 in order to give a better
help message for `cargo test --quiet`. I don't remember if clap just
didn't support overriding at the time, or if we just didn't know how it
worked. Anyways, it seems to work to override it now, so I think it
should be fine to mark it as global.

This should bring in `--quiet` more in-line with how `--verbose` works.
This means that `--quiet` is now accepted with `cargo report`,
`cargo help`, and `cargo config`.

This also fixes `--quiet` with `cargo clean gc`.

This should also help with supporting `--quiet` with the new `cargo
owner` subcommands being added in
https://github.com/rust-lang/cargo/pull/11879.

Fixes #12957
2023-11-12 11:17:43 -08:00
Eric Huss 56c8d90d13 Use walkdir's built-in sorting option. 2023-11-11 10:56:59 -08:00
Eric Huss da3ca05677 Add a global cache garbage collector.
This adds a garbage collector which will remove old files from cargo's
global cache.

A general overview of the changes here:

- `cargo::core::global_cache_tracker` contains the `GlobalCacheTracker`
  which handles the interface to a sqlite database which stores
  timestamps of the last time a file was used.
- `DeferredGlobalLastUse` is a type that implements an optimization for
  collecting last-use timestamps so that they can be flushed to disk all
  at once.
- `cargo::core::gc` contains the `Gc` type which is the interface for
  performing garbage collection. It coordinates with the
  `GlobalCacheTracker` for determining what to delete.
- Garbage collection can either be automatic or manual. The automatic
  garbage collection supports some config options for defining when
  it runs and how much it deletes.
- Manual garbage collection can be performed via options to `cargo
  clean`.
- `cargo clean` uses the new package cache locking system to coordinate
  access to the package cache to prevent interference with other cargo
  commands running concurrently.
2023-11-11 10:56:58 -08:00
Eric Huss 9588fb6dda Add a du utility function.
This adds a very primitive `du` function for determining the disk usage
in a directory. This should probably be improved or replaced at some
point in the future, this is just a start for supporting tracking sizes
of cache data.
2023-11-11 10:56:58 -08:00
Ed Page 6bfc32a15e refactor(resolver): Pull MSRV handling to VersionPreferences 2023-11-07 20:39:35 -06:00
Ed Page bf2987b09b refactor(resolver): Track minimal-versions in VersionPreferences
This had repurcussions on direct-minimal-versions as it before relied on
the ordering parameter to `sort_sumarries`.
2023-11-07 20:39:35 -06:00
Ed Page 3cdddbf033 test(resolver): Improve failure output 2023-11-07 20:39:35 -06:00
Ed Page e70e310ce0 fix: Report more detailed semver errors
For `cargo install` we'll now show a more specific parse error for
semver, much like other parts of cargo.

This came out of my work on #12801.  I was looking at what might be
appropriate to put in a `cargo-util-semver` crate and realized we have
the `ToSemver` trait that exists but doesn't do much, so I dropped it.
2023-11-06 15:24:32 -06:00
Ed Page 293f2250d6 feat(doc): Print the generated docs links
I've wanted something like this myself.  I dislike using `--open`
because I tend to move up to re-run my `cargo doc` run but then have to
edit it to remove `--open`.
Also makes it annoying when opening docs when `cargo doc` is wrapped by
a tool like `make`.

This was previously attempted in #5592:
- Unlike the request in #5562, this aligns with #5592 in always printing
  rather than using a flag as this seems generally useful
- Unlike #5592, this prints as an alternative to "Opening" to keep
  things light
- Unlike #5592, this prints afterwards as the link is only valid then

Fixes #5562
2023-10-19 10:51:56 -05:00
bors f7e7cc2356 Auto merge of #12820 - linyihai:broken-symlink-target, r=weihanglo
add detailed message when target folder path is invalid

# What does this PR try to resolve?
close https://github.com/rust-lang/cargo/issues/12789

add more detailed message when target folder path is invalid

# How should we test and review this PR?

Before this PR, if the target folder refer to broken symbolic link like /a/b/c, then run cargo build, the output is:

```
error: Not a directory (os error 20)
```
the detailed error message is missing.

This PR will add the error context for it, the finall output will be
```
cargo build
error: failed to create directory `/root/workspace/playground/target`

Caused by:
  Not a directory (os error 20)
```
2023-10-14 04:43:58 +00:00
Lin Yihai ceac419776 add detailed message when target folder path is invalid 2023-10-14 11:34:42 +08:00
Ed Page 7846fe8cb4 chore: Sort dependency tables
This will make `cargo add` put things in the right place.

Verified by doing `cargo add arcstr && git diff && git reset --hard`
2023-10-10 15:03:22 -05:00
bors b48c41aedb Auto merge of #12706 - ehuss:cache-lock-mode, r=epage
Add new package cache lock modes

The way locking worked before this PR is that only one cargo could write to the package cache at once (otherwise it could cause corruption). However, it allowed cargo's to read from the package cache while running a build under the assumption that writers are append-only and won't affect reading. This allows multiple builds to run concurrently, only blocking on the part where it is not possible to run concurrently (downloading to the cache).

This introduces a new package cache locking strategy to support the ability to safely modify existing cache entries while other cargos are potentially reading from the cache. It has different locking modes:

- `MutateExclusive` (new) — Held when cargo wants to modify existing cache entries (such as being introduced for garbage collection in #12634), and ensures only one cargo has access to the cache during that time.
- `DownloadExclusive`  (renamed) — This is a more specialized name for the lock that was before this PR.   A caller should acquire this when downloading into the cache and doing resolution.  It ensures that only one cargo can append to the cache, but allows other cargos to concurrently read from the cache.
- `Shared` (new) — This is to preserve the old concurrent build behavior by allowing multiple concurrent cargos to hold this while a build is running when it is reading from the cache

**Reviewing suggestions:**
There are a few commits needed to help with testing which are first. The main commit has the following:
- `src/cargo/util/cache_lock.rs` is an abstraction around package cache locks, and is the heart of the change. It should have comments and notes which should guide what it is doing. The `CacheLocker` is stored in `Config` along with all our other global stuff.
- Every call to `config.acquire_package_cache_lock()` has been changed to explicitly state which lock mode it wants to lock the package cache in.
- `Context::compile` is the key point where the `Shared` lock is acquired, ensuring that no mutation is done while the cache is being read.
- `MutateExclusive` is not used in this PR, but is being added in preparation for #12634.
- The non-blocking `try_acquire_package_cache_lock` API is not used in this PR, but is being added in preparation for #12634 to allow automatic gc to skip running if another cargo is already running (to avoid unnecessary blocking).
- `src/cargo/util/flock.rs` has been updated with some code cleanup (removing unused stuff), adds support for non-blocking locks, and renames some functions to make their operation clearer.
- `tests/testsuite/cache_lock.rs` contains tests for all the different permutations of ways of acquiring locks.
2023-10-09 15:56:42 +00:00
Eric Huss b4982adfd9 Add a new package cache locking system.
This introduces a new `CacheLocker` which manages locks on the package
cache. Instead of either being "locked" or "not locked", the new locker
supports multiple modes:

- Shared lock: Cargo can read from the package sources, along with any
  other cargos reading at the same time.
- Download exclusive lock: Only one cargo can perform downloads.
  Download locks do not interfere with Shared locks, since it is
  expected that downloading does not modify existing files (only adds
  new ones).
- Mutate exclusive lock: Only one cargo can have this lock, and it also
  prevents shared locks. This is so that the cargo can modify the
  package cache (such as deleting files) without breaking concurrent
  processes.
2023-10-08 14:16:51 -07:00
Eric Huss b85ef38187 Add test helpers for waiting for an operation with a timeout. 2023-10-08 14:16:51 -07:00
Eric Huss 83fff2d1b1 Add a test helper for retrying a function multiple times. 2023-10-08 14:16:51 -07:00
bors 0871c0e2f4 Auto merge of #12795 - weihanglo:semver-checks, r=ehuss
ci: bump cargo-semver-checks to 0.24.0
2023-10-08 21:15:54 +00:00
Weihang Lo 60539e94dc
ci: bump cargo-semver-checks to 0.24.0
Also remove workaround since the issue was fixed in upstream.
2023-10-08 16:24:23 -04:00
Ed Page 03a642b1d8 fix: Set MSRV in all published packages 2023-10-06 16:34:42 -05:00
Tobias Bieniek 9e5dac18b9
crates.io: Bump version to 0.39.1 2023-10-06 16:11:38 +02:00
Tobias Bieniek e287f43006
crates-io: Add doc comment for `NewCrate` struct 2023-10-06 14:04:03 +02:00
Ed Page 72f4f0cb3f chore: Simplify releasing `home`
I'm not seeing any benefit derived by `html_root_url`
2023-10-02 12:13:49 -05:00
bors 9a94183771 Auto merge of #12744 - tompscanlan:atomic-write, r=epage
fix bug: corruption when cargo killed while writing

### What does this PR try to resolve?

fix  #11386, superseding #12362

### How should we test and review this PR?

Added unit test showing basic equivalency to existing `write(path, content)`. Full test suite should exercise write.
Added tests for cargo add and remove. These are timing tests, so take a bit of time to run. 5-10s each.  They may not fail every time, but do so regularly.  Making the change to these two writes seems to prevent me from failing these tests at all.

### Additional information

This uses tempfile::persist which was an existing dependency. atomicwrites crate, an alternative option for this fix, indicates `tempfile::persist` is the same thing.  Since we already use tempfile as a dep, I stuck with that.
2023-10-02 13:34:00 +00:00
Tom Scanlan aee8c75410
bug: corruption when killed while writing 2023-10-01 08:29:24 -04:00
Ed Page 37c6f3d085 fix(test): Add back in newlines to diffs
Errors like this aren't too helpful
```
error: stderr did not match:
1   1     error: failed to parse manifest at `[..]`2   2     3   3     Caused by:4   4       TOML parse error at line 3, column 275   5         |6   6       3 |                 version = 17
  7         |                           ^8        -  invalid type: integer `1`, expected SemVer version    8    +  invalid type: integer `1`, expected a string or workspace
```

This was broken in #12581
2023-09-29 20:02:53 -05:00
Ed Page 796398563a refactor(test): Switch termcolor to anstream 2023-09-29 10:16:15 -05:00
cui fliter c8f4d234bb Fix some typos
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-24 23:10:07 +08:00
Eric Huss ebea09d8f4 Fix spurious errors with networking tests. 2023-09-22 13:37:26 -07:00
Eric Huss 495ed7ebe2 Add a summary to `cargo clean`.
This adds a summary at the end when `cargo clean` finishes that displays
how many files and bytes were removed.
2023-09-19 18:16:40 -07:00
bors f9335babbc Auto merge of #12707 - epage:spell, r=ehuss
chore: Fix typos

This is a repeat of #11561
2023-09-19 22:07:03 +00:00
Jacob Finkelman 679d65103f shortest path is probably more informative than random path for error messages 2023-09-19 20:39:02 +00:00
Ed Page e4e10f2393 chore: Fix typos
This is a repeat of #11561
2023-09-19 15:28:48 -05:00
Jacob Finkelman 245e69ce10 add a test for shortest path 2023-09-19 20:22:13 +00:00
Ed Page 4135f562b8 refactor(manifest): Clarify the specialized role of RustVersion 2023-09-13 21:59:26 -06:00
Weihang Lo 463622ad81
lint: fix errors for self-named module files 2023-09-14 13:43:48 +08:00
Weihang Lo aef3bd22d3
lint: fix errors for rust 2018 idioms 2023-09-14 13:43:48 +08:00
Weihang Lo 437942ee7e
lint: use `eprintln` for human-facing outputs 2023-09-14 13:43:47 +08:00
Weihang Lo f9d82a1703
lint: remove unused `dbg!` 2023-09-14 13:43:47 +08:00
Jacob Finkelman 205fd1a765 libgit2 fixed upstream 2023-09-11 19:25:45 +00:00
Jacob Finkelman 2b2838302f bump cargo-platform 2023-09-08 19:16:42 +00:00
Jacob Finkelman 44666f7377 Ues strip_prefix for cleaner code 2023-09-07 17:57:28 +00:00
Weihang Lo e575448574
refactor: flatten module path of `SourceId` 2023-09-07 21:06:35 +08:00
Weihang Lo b6c4e47cc0
refactor: put `Source` trait under `cargo::sources` 2023-09-07 21:06:34 +08:00
bors baca00ebe1 Auto merge of #12636 - ehuss:fs-metadata-wrappers, r=weihanglo
Add wrappers around std::fs::metadata

This adds wrappers around `std::fs::metadata` and `std::fs::symlink_metadata` which provide better error messages indicating the path that caused the error. This just helps clean up some duplicated code, and is also going to be used to assist with some code changes in #12634.
2023-09-07 08:54:50 +00:00
bors 282424e42d Auto merge of #12635 - ehuss:with-stdout-unordered, r=weihanglo
Add with_stdout_unordered.

This adds the `with_stdout_unordered` method to cargo's test system so that tests can use it to check stdout but ignoring the order of lines. Nothing in this PR actually uses this method, but it is added to support #12634. I also expect it could potentially be useful in other cases in the future.
2023-09-07 06:26:51 +00:00
Eric Huss 62d86470d1 Add wrappers around std::fs::metadata
This adds wrappers around std::fs::metadata and
std::fs::symlink_metadata which provide better error messages indicating
the path that caused the error.
2023-09-06 21:41:54 -07:00
Eric Huss 0adb9f1b2a Add with_stdout_unordered.
This adds Execs::with_stdout_unordered to check stdout ignoring the
order of lines.
2023-09-06 21:40:56 -07:00
Eric Huss 8964f3fd5d Fix example for creating a git project test. 2023-09-06 18:56:12 -07:00
bors cff6d19f6e Auto merge of #12615 - Eh2406:split_once, r=epage
use split_once for cleaner code

### What does this PR try to resolve?

Search the code base for `.splitn(2` and replace with `.split_once` where it was clearer. I don't think any of them matter in practice.

### How should we test and review this PR?

This was an internal re-factor, and the tests still pass.
The two methods have subtly different semantics, so please review carefully.
2023-09-03 02:27:49 +00:00
Jacob Finkelman 1ea81a3692 use split_once for cleaner code 2023-09-01 21:45:55 +00:00
Jacob Finkelman 16b330bc59 stop using lazy_static 2023-09-01 21:38:03 +00:00
Ed Page 4820624ce7 feat(resolver): Respect MSRV 2023-08-25 10:42:26 -05:00
bors f797978283 Auto merge of #12553 - epage:version, r=weihanglo
refactor: Pull out cargo-add MSRV code for reuse

### What does this PR try to resolve?

#12078 added MSRV code in `cargo add`. Our assumption when writing it is that we'd need to generalize the code before reusing it in other places, like `cargo install`.  This PR focused purely on that refactor because I'm hopeful it will be useful for other work I'm doing.  Despite not having a user for this yet, I think the `cargo install` case is inevitable and I feel this does a bit to clean up MSRV related code by using a more specific type everywhere.

### How should we test and review this PR?

Each commit gradually progresses things along
2023-08-25 14:56:24 +00:00
Deadbeef b2b34e4ca2 update tests 2023-08-25 01:43:29 +00:00
Deadbeef 3d50f47197 Add fields for bindeps on the registry 2023-08-25 01:43:29 +00:00
Ed Page 423a334520 refactor: Parse, don't validate, rust_version
By using the `PartialVersion` type with serde, we get the context for
the error automatically.
2023-08-24 14:15:35 -05:00
Ed Page 7a65c826a0 fix: Set MSRV for internal packages
For now, I'm punting on packages we generally expect others to use
2023-08-22 16:46:47 -05:00
Ed Page 576f901f81 fix(log): Use a more compact relative-time format
This changes logged messages from
```
2023-08-23T01:01:59.922018Z DEBUG cargo::core::compiler::fingerprint: filesystem up-to-date "/home/epage/src/personal/dump"
```
To
```
   0.041729583s DEBUG cargo::core::compiler::fingerprint: filesystem up-to-date "/home/epage/src/personal/dump"
```
Benefits
- Less horizontal space taken up in boilerplate
- Easier to compare within a run

Downsides
- Harder to correlate with other processes, like with crates.io server
  operations

This gives us up to 4 digits for seconds which should be sufficient for
cargo build times.

We could make this more compact by dropping the digits of precision from
9 to 6 but that would require a custom Timer which might be a paint to
keep in sync between packages.
2023-08-22 20:34:07 -05:00
Eric Huss 96da3c4872 Support hidden lines. 2023-08-17 18:18:10 -07:00
Eric Huss 4c1d8f1364 Document the special code block annotations. 2023-08-17 18:18:10 -07:00
Arlo Siemsen 763edbab09 rename crate to cargo-credential-libsecret 2023-08-17 16:05:31 -05:00
Weihang Lo 5691da2b79
chore(cargo-util): bump version to 0.2.6 2023-08-16 20:06:40 +01:00
Weihang Lo 1ee9db3123
fix(xtask-bump-check): query by package name to detect changes
versions and paths of a workspace members between the original and
a checked-out workspace are different, and shouldn't be included in
hash keys when querying packages.
2023-08-16 15:46:43 +01:00
Weihang Lo c07043b7cf
fix(log): enable ansi color only in terminal 2023-08-14 15:45:25 +01:00
Weihang Lo 9d707e4b9a
chore: remove `log`, `env_logger`, and `pretty_env_logger` 2023-08-07 12:02:19 +01:00
Weihang Lo 7e69050c64
refactor: setup `tracing-subscriber` 2023-08-07 12:02:19 +01:00
Weihang Lo 23561f36a1
chore: add `tracing-subscriber` crate 2023-08-07 11:25:41 +01:00
Weihang Lo af1a78b424
refactor: find & replace `log::` -> `tracing::`
Except HTTP network debugging
2023-08-07 11:25:40 +01:00
Weihang Lo 9f0565e985
chore: add `tracing` crate 2023-08-07 11:21:55 +01:00
bors 6145d0c4d2 Auto merge of #12395 - weihanglo:cargo-semver-checks, r=epage
ci: rewrite bump check and respect semver

### What does this PR try to resolve?

This ports `ci/validate-version-bump.sh` and #12200 to the new xtask `bump-check`. It also adds the ability to set the correct baseline revision when checking version bump. That is, it fixes #12347.

In addition, this integrates the community tool `cargo-semver-checks`. SemVer violation can now be detected earlier.

### How should we test and review this PR?

This PR extracts the registry query part from `xtask-unpublished` and removes other pars. I don't feel like we need it in the short term.

For how it works, please the check doc comment in each function.

One concern is that this check is still a required job for bors. I believe `@obi1kenobi` is quite responsive and willing to help if there is something wrong. So, waiting for an upstream fix won't be a problem for cargo. Also as a good citizen in the community, we can always contribute back.
(Take it easy `@obi1kenobi,` don't be stressed out 🙂)
<!-- homu-ignore:end -->
2023-08-01 23:00:45 +00:00
Weihang Lo 8d31d626a2
chore: remove `xtask-unpublished` 2023-08-01 22:54:41 +01:00
Weihang Lo 9cca5721e4
chore: new xtask `bump-check`
This is a rewrite of old `ci/validate-version-bump.sh` in Rust.
2023-08-01 22:54:40 +01:00
renovate[bot] a63bc76577
chore(deps): update alpine docker tag to v3.18 2023-08-01 02:18:33 +00:00
Weihang Lo 46bf05dcaf
chore: update `home` to 0.5.7 2023-07-26 11:26:49 +01:00
Arlo Siemsen 2b39792aef Credential provider implementation 2023-07-21 16:02:24 -05:00
Weihang Lo 31b500c7c0
refactor(crates-io): use `thiserror`
Optionally use `thiserror` to reduce boilerplates but this part can
be dropped if we don't want.
2023-07-18 22:22:47 +01:00
Weihang Lo b4499af4e9
refactor(crates-io): remove `anyhow`
This removes the dependency `anyhow` and uses our own custom Error
enum, so that crates-io consumer can access `Error::API::challenge`
field.
2023-07-18 22:22:47 +01:00
Weihang Lo a561e8b781
feat(crates-io): use our own `Result` wrapper everywhere 2023-07-18 22:22:47 +01:00
Weihang Lo ed6692b1c6
refactor(crates-io): rename `ResponseError` to `Error` 2023-07-18 22:22:47 +01:00
Weihang Lo 00a872740a
fix(crates-io): don't let server sneak extra lines anywhere
From 5febbe5587/src/cargo/sources/registry/http_remote.rs (L234-L237)
2023-07-18 22:22:46 +01:00
Weihang Lo 6805944715
feat(crates-io): expose headers for `ResponseError::Api`
In response to RFC 3231 [^1], our registry client need to return headers
to caller, so that the caller (cargo binary) can continue parsing
challenge headers.

[^1]: https://rust-lang.github.io/rfcs/3231-cargo-asymmetric-tokens.html#the-authentication-process
2023-07-18 22:22:46 +01:00
Ed Page 83a5859221 chore(platform): Version bump 2023-07-17 13:21:41 -05:00
Ed Page 4bd5f9ca50 chore(util): Version bump 2023-07-17 13:21:41 -05:00
Ed Page 5d80aa263d refactor: Provide workspace-level default license 2023-07-17 13:21:41 -05:00
Ed Page 3752929dd4 refactor: Update home to 2021 edition 2023-07-17 13:21:41 -05:00
Ed Page e4877cc701 refactor: Update resolver-tests to 2021 edition 2023-07-17 13:21:41 -05:00
Ed Page f358359a17 refactor: Provide a workspace-level default edition 2023-07-17 13:21:40 -05:00
Ed Page 8b02d4927e refactor: Infer package.readme 2023-07-17 13:21:10 -05:00
Arlo Siemsen d45ba88290 Bump version of crates-io due to unintentional semver-breaking change 2023-07-13 14:35:09 -05:00
Eric Huss 43c253e69a Rustfmt with latest nightly. 2023-07-11 16:58:53 -07:00
Eric Huss 9835622853 Convert valid feature name warning to an error. 2023-06-20 12:39:27 -07:00
Eric Huss 75bcada1eb Show a better error when container tests fail. 2023-06-13 11:15:39 -07:00
Ed Page b2b4d9771f test(cli): Verify precedence over external subcommands 2023-06-09 13:16:12 -05:00
Weihang Lo c977baa9cf
refactor: rename `RegistryPackage` to `IndexPackage`
This is a better name to reflect it is from "index" files.
2023-06-07 23:01:55 +01:00
Weihang Lo fa7cc198aa
refactor: replace some usages of `lazy_static` with `OnceLock`
* Some usages still wait for `LazyCell`.
* `TEST_ROOTS` is no longer used. Removed.
2023-06-01 22:11:20 +01:00
Weihang Lo 8cb220f5eb
refactor: use `IsTerminal` from std instead of `is-terminal` crate 2023-06-01 21:50:43 +01:00
trevyn 5dfae689fa Improve error chain formatting 2023-05-30 13:55:05 +04:00
trevyn 0b8c12f5c6 Document reasoning and report previous error chain 2023-05-30 07:51:07 +04:00
trevyn ddc49783ce Fall back to `fs::remove_dir_all` on error 2023-05-28 17:57:49 +04:00
Weihang Lo 7b4e32d64b
test: set retry sleep to 1ms for all tests 2023-05-27 11:28:58 +01:00
bors d90ff55ca5 Auto merge of #11968 - bzEq:aix-libpath, r=weihanglo
fix: AIX searches dynamic libraries in `LIBPATH`.

### What does this PR try to resolve?

On IBM AIX machines people have encountered issues in `compiletest` and rustc's bootstrap builder. They haven't encountered any in cargo. This PR is made for avoiding potential failures in the future in cargo.

It's documented in <https://www.ibm.com/support/pages/libpath-environment-variables-aix-platforms>:

> The `LIBPATH` environment variable tells AIX applications where to find shared libraries when located in a different directories than those specified in the header section of the executable.

See also the counterpart in <https://github.com/rust-lang/rust/pull/109526>

### How to verify and test this in Cargo's CI?

This is indeed an issue. At IBM people are maintaining a buildbot since GitHub Action doesn't support AIX yet.
2023-05-25 10:20:29 +00:00
bors 5a396277e8 Auto merge of #12126 - weihanglo:ci-version-bump, r=epage
ci: check if any version bump needed for member crates

### What does this PR try to resolve?

Check if a crate requires a version bump in CI.

Part of #12033

### How should we test and review this PR?

Demo action result: <https://github.com/weihanglo/cargo/actions/runs/4941952784/jobs/8835049007>

### Additional information

This doesn't devalue #12089. I love the changelog detection, saving maintainers' times a lot ( I am the one writing changelogs for each release for now). However, the amount of code there is too excessive to me. I think someday when we are going to integrate [cargo-release](https://crates.io/crates/cargo-release) and/or [ehuss/cargo-new-release](https://github.com/ehuss/cargo-new-release), we can remove this script perhaps entirely :)

I tried to document the script a bit hard. Hope it won't get worse over time.
2023-05-23 02:28:15 +00:00
WANG Rui 6a9cb23923 Remove useless drop of copy type 2023-05-13 16:51:30 +08:00
Weihang Lo 8eb3f51725
doc: explain what xtask-unpublished does 2023-05-10 23:28:45 +01:00
Eric Huss dd25e89460 Update the semver-check script to be able to run in any directory. 2023-05-09 12:53:05 -07:00
Weihang Lo 8620f5a7d5
xtask-unpublished: table output 2023-05-05 16:32:07 +01:00
Weihang Lo 0bffcbcb8a
chore: `publish = false` for pkgs not meant to be published
These tree packages are considered to be published something.
To reduce the logic of xtask-unpubilshed, let's flag them false for now.
We can always set it `true` when needed.
2023-05-05 16:24:19 +01:00
Weihang Lo 8d753a767c
xtask-unpublished: respect `--package` flag 2023-05-05 16:24:18 +01:00
bors 33c64109fe Auto merge of #12055 - QiangHeisenberg:crates-io-doc-test, r=weihanglo
fix:  doc-test failures

### What does this PR try to resolve?

When I read the source code, I found that the `Registry::new_handle` document test failed and seemed to be missing parameters;

There is no change in this [PR](https://github.com/rust-lang/cargo/pull/10592/files#diff-12973056cf99e8de997011a8738a6740a7dfd06142a73f122f3b35218db37351).
2023-05-04 14:30:42 +00:00
QiangHeisenberg ff7ff7d50d Added the no_run attribute 2023-05-04 16:25:12 +08:00
QiangHeisenberg ea0d487b99 fix cargo-test-support doc test 2023-05-04 11:16:34 +08:00
Scott Schafer 34b8c39d77 chore: Use `[workspace.dependencies]` 2023-04-28 09:56:09 -05:00
cui fliter 825c75af31 Remove repeated definite articles
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-05-01 21:37:28 +08:00
bors 393ce5b416 Auto merge of #12048 - weihanglo:mdman, r=epage
chore: move build-man workflow away from shell
2023-04-28 15:48:53 +00:00
bors 7a90ba1ecc Auto merge of #12043 - epage:rust-version, r=weihanglo
feat: Add `-Zmsrv-policy` feature flag

### What does this PR try to resolve?

Nothing noticeable....

The intent is to unblock experiments with different compatible MSRV policies like
- #9930
- #10653
- #10903

While I normally don't like PRs that do nothing on their own, this at least allows any one of those efforts to move forward with different people without juggling these base commits for whoever is first to include in their PR

While there isn't an RFC for this yet, this is intended to allow us to experiment to get a better idea of what we should put in an RFC.  In some cases, we first do an eRFC for this but I assumed this wouldn't be needed in this case as this builds on rust-lang/rfcs#2495 and, I'm assuming, will be more surgical in nature

### How should we test and review this PR?

The `Summary` changes are largely untested as they will be mostly tested through the future work that builds on this PR.  However, I wasn't too concerned about that because the code is relatively trivial.

### Additional information

I chose the name `msrv-policy` to distinguish this unstable feature from `rust-version`.  Though those appear in different places (`Cargo.toml` vs `-Z`), I can see them being confusing which was especially apparent when editing `unstable.md` which has an anchor for `rust-version`.
2023-04-28 14:55:25 +00:00
Weihang Lo 137c82a54b
mdman: update mdman's example outputs 2023-04-28 15:46:37 +01:00
Weihang Lo e3dec38f4b
mdman: use `cargo build-man` everywhere 2023-04-28 15:46:37 +01:00
Weihang Lo c01bad9b20
mdman: make build-man part of xtask
Turn `src/doc/build-man.sh` into a Cargo binary target.
So is `crates/mdman/build-man.sh`.
2023-04-28 15:46:37 +01:00
Weihang Lo 9c426c90de
mdman: remove dangling Cargo.lock 2023-04-28 15:44:24 +01:00
Weihang Lo 36653ab85a
ci: add job `stale-label` 2023-04-28 12:02:51 +01:00
Weihang Lo 981282891f
xtask-stale-label: check stale paths in autolabel defintions 2023-04-28 12:02:51 +01:00
QiangHeisenberg 796f9acbcb fix test failed 2023-04-28 17:08:04 +08:00
Utkarsh Gupta fd1f1043e0
home: bump version & update changelog 2023-04-27 22:00:19 +05:30
Utkarsh Gupta c078c0ca21
home: fix & enhance documentation 2023-04-27 21:49:05 +05:30
bors 0ad289b264 Auto merge of #12045 - epage:publish, r=weihanglo
chore: Mark unpublished crates as such

This is a follow up to #12039.
This makes it easier for tools to report less irrelevant information.

I did both `publish = false` and `version = "0.0.0"` to help draw attention to the fact that these crates are internal (inspired by a matklad post).

I left `cargo-test-macro` and `cargo-test-support` in for my own personal bias of one day wanting to see those crates published...

The only one removed that had previously been published was `mdman` but seeing as that was a `0.0.0`, I'm assuming that was a mistake or just reserving the name.

Before:
```console
$ cargo unpublished
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.1 0.72.0
semver-check - 0.1.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

After:
```console
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
cargo 0.70.1 0.72.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
```
2023-04-27 05:54:17 +00:00
bors 42a45c841f Auto merge of #12041 - cassaundra:publish-rust-version, r=epage
Include rust-version in publish request

crates.io reads rust-version from the tarball directly, but we can include it in the publish request for the sake of consistency for third-party registries. See [relevant Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/318791-t-crates-io/topic/rust-version.20field).

Validation for the field was already implemented in #8037.
2023-04-27 01:13:35 +00:00
bors 8bcf8fe770 Auto merge of #12039 - epage:xtask, r=weihanglo
chore(xtask): Add `cargo xtask unpublished`

### What does this PR try to resolve?

This tries to make it easy to see what existing versions have not been published.  A future version of this could post to a PR what the current delta in version numbers for touched crates so reviewer have more context when deciding if they should ask for a crate version to be bumped
```console
$ cargo unpublished
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `/home/epage/src/personal/cargo/target/debug/xtask unpublished`
    Updating crates.io index
name published current
==== ========= =======
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.0 0.71.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

Room for improvement
- Aligning the start of each column
- Filtering the list by a commit range
- Adding this to an action to post to a review
- Maybe sorting the output
- Marking some our crates as `package.publish = false`, like benchsuite and resolver-tests

### How should we test and review this PR?

This is broken down commit by commit for easier seeing of the building blocks for our first xtask
2023-04-26 23:09:59 +00:00
Ed Page 077b1bc311 chore: Mark unpublished crates as such
This is a follow up to #12039.
This makes it easier for tools to report less irrelevant information.

I did both `publish = false` and `version = "0.0.0"` to help draw
attention to the fact that these crates are internal (inspired by a
matklad post).

I left `cargo-test-macro` and `cargo-test-support` in for my own
personal bias of one day wanting to see those crates published...

The only one removed that had previously been published was `mdman` but
seeing as that was a `0.0.0`, I'm assuming that was a mistake or just
reserving the name.

Before:
```console
$ cargo unpublished
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
mdman 0.0.0 0.1.0
resolver-tests - 0.1.0
cargo 0.70.1 0.72.0
semver-check - 0.1.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
benchsuite - 0.1.0
```

After:
```console
name published current
==== ========= =======
cargo-platform 0.1.2 0.1.3
cargo-test-macro - 0.1.0
cargo-test-support - 0.1.0
cargo-util 0.2.3 0.2.4
crates-io 0.36.0 0.36.1
cargo 0.70.1 0.72.0
cargo-credential 0.1.0 0.2.0
cargo-credential-1password 0.1.0 0.2.0
cargo-credential-gnome-secret 0.1.0 0.2.0
cargo-credential-macos-keychain 0.1.0 0.2.0
cargo-credential-wincred 0.1.0 0.2.0
```
2023-04-26 17:51:16 -05:00
Ed Page f3728d3250 feat: Expose 'rust_version' in the Summary 2023-04-26 15:59:22 -05:00
Ed Page 07e3bb880d feat(test): Manual publishes set 'rust_version' in Index 2023-04-26 15:59:22 -05:00
cassaundra 5554889f88
Include rust-version in publish request
crates.io reads rust-version from the tarball directly, but we can include it in
the publish request for the sake of consistency for third-party registries.
2023-04-26 11:59:29 -07:00
Ed Page 5b13963044 perf(xtask): Split xtask binaries
This will allow running an xtask without requiring building the world.
In most cases, a user will already have been building cargo but not in
CI.

The packages keep an `xtask-` prefix to help raise awareness of them but
exposed as `cargo <suffix>` to avoid having a direction proxy to wrap
`cargo run -p xtask-<suffix>` as `cargo xtask <suffix>`.
2023-04-26 11:18:51 -05:00
Eric Huss a4f01c0352 Update home dependency 2023-04-25 11:38:52 -07:00
Ed Page c6f8ee9e51 feat(xtask): First pass at 'cargo xtask unpublished' 2023-04-25 03:06:46 -05:00
Ed Page 0b20bd99e3 chore(xtask): Add core cargo flags 2023-04-25 02:33:47 -05:00
Ed Page a675e047e7 chore(xtask): Add xtask skeleton 2023-04-25 02:13:56 -05:00
bors a4a8bd1742 Auto merge of #12021 - ehuss:update-windows-sys, r=weihanglo
Update windows-sys

This updates the windows-sys dependency from 0.45 to 0.48. This shouldn't add or remove any duplicate dependencies (since there are other dependencies still using 0.45 and 0.42). The intent is to move it along the direction towards unifying in the future (though it seems like a moving target that will be difficult to ever hit).

This also bumps the home crate version. I think it should be OK to make the migration from winapi to windows-sys a patch version, though there seems to be some issues with the way windows-sys works that could introduce some build-time problems in some situations (such as those encountered in https://github.com/rust-lang/rust/pull/108665 and https://github.com/rust-lang/rust/pull/106610). However, I don't expect too much of an issue.
2023-04-24 11:50:26 +00:00
Eric Huss eea69e549f Bump versions of local crates 2023-04-23 13:01:29 -07:00
Eric Huss ac25009500 Update windows-sys 2023-04-23 12:40:00 -07:00
Weihang Lo ff216ebc96
chore: make `server-check` a workspace member 2023-04-21 10:58:45 +01:00