Skip to content

Commit 39116cc

Browse files
committed
Auto merge of #11851 - weihanglo:make-cargo-a-workspace, r=ehuss
Make cargo a workspace ### What does this PR try to resolve? The first step of making cargo a workspace. Benefits: * Dogfooding ourselves. * Unblock #11831: It got stuck because the new version of tempfile using `windows-sys` but some issues haven't yet be solved in rust-lang/rust. * Make `cargo xtask` or similar developer workflow possible (e.g., #11717) * Having our own Cargo.lock, so our CI can cover the exact binary going to ship. Also free Cargo from CI breaks due to dependency patch releases. * Probably more? Please add them by yourself. ### How should we test and review this PR? Please review it commit by commit. A companion PR is here rust-lang/rust#109133, and should be reviewed together. ### Unresolved issues To limit the scope of this pull request, the following issues are intentionally left unresolved. They will be addressed right after this pull request gets merged. - [x] Make `benches/capture` and `benches/capture` workspace members. (Addressed with 2cf9718) - [x] Make `crates/resolver-tests` a workspace member. (Addressed with #11886) - [ ] ~~Fix clippy warnings and re-enable clippy check in CI for all workspace members.~~ - Blocked on rust-lang/rfcs#3389 so we can more easily propagate our clippy settings - [ ] Fix rustdoc warnings and re-enable rustdoc check in CI for all workspace members. - [ ] Fix `linkchecker.sh` warnings in CI (#11851 (comment)) - [ ] Leverage workspace flag `--workspace` when running `cargo build` or `cargo test`, instead of using flag `-p`. - [ ] Leverage glob syntax when probing members in `[workspace]` in Cargo.toml (i.e., `crates/*`). ### Additional information This depends on prior works from `@Muscraft` and `@ehuss.` Credits to them!
2 parents 7fb89f0 + aaca5a0 commit 39116cc

File tree

3 files changed

+3753
-35
lines changed

3 files changed

+3753
-35
lines changed

.github/workflows/main.yml

+21-30
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ jobs:
2424
- run: rustup update stable && rustup default stable
2525
- run: rustup component add rustfmt
2626
- run: cargo fmt --all --check
27-
- run: |
28-
for manifest in `find crates benches/benchsuite benches/capture -name Cargo.toml`
29-
do
30-
echo check fmt for $manifest
31-
cargo fmt --all --manifest-path $manifest --check
32-
done
27+
- run: cargo fmt --all --check --manifest-path crates/resolver-tests/Cargo.toml
3328

3429
# Ensure there are no clippy warnings
3530
clippy:
@@ -39,7 +34,8 @@ jobs:
3934
- run: rustup update stable && rustup default stable
4035
- run: rustup component add clippy
4136
# Only check cargo lib for now
42-
- run: cargo clippy -p cargo --lib -- -D warnings
37+
# TODO: check every members
38+
- run: cargo clippy -p cargo --lib --no-deps -- -D warnings
4339

4440
test:
4541
runs-on: ${{ matrix.os }}
@@ -101,47 +97,41 @@ jobs:
10197
run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
10298
if: matrix.os == 'ubuntu-latest'
10399

104-
- run: cargo test
100+
- run: cargo test -p cargo
105101
- name: Clear intermediate test output
106102
run: ci/clean-test-output.sh
107103
- name: gitoxide tests (all git-related tests)
108-
run: cargo test git
104+
run: cargo test -p cargo git
109105
env:
110106
__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1
111107
# The testsuite generates a huge amount of data, and fetch-smoke-test was
112108
# running out of disk space.
113109
- name: Clear test output
114110
run: ci/clean-test-output.sh
111+
# This only tests `cargo fix` because fix-proxy-mode is one of the most
112+
# complicated subprocess management in Cargo.
115113
- name: Check operability of rustc invocation with argfile
114+
run: 'cargo test -p cargo --test testsuite -- fix::'
116115
env:
117116
__CARGO_TEST_FORCE_ARGFILE: 1
118-
run: |
119-
# This only tests `cargo fix` because fix-proxy-mode is one of the most
120-
# complicated subprocess management in Cargo.
121-
cargo test --test testsuite -- fix::
122-
- run: cargo test --manifest-path crates/cargo-test-support/Cargo.toml
123-
env:
124-
CARGO_TARGET_DIR: target
117+
- run: cargo test -p cargo-test-support
125118
- run: cargo test -p cargo-platform
126119
- run: cargo test -p cargo-util
127-
- run: cargo test --manifest-path crates/home/Cargo.toml
128-
- run: cargo test --manifest-path crates/mdman/Cargo.toml
129-
- run: cargo build --manifest-path crates/credential/cargo-credential-1password/Cargo.toml
130-
- run: cargo build --manifest-path crates/credential/cargo-credential-gnome-secret/Cargo.toml
120+
- run: cargo test -p home
121+
- run: cargo test -p mdman
122+
- run: cargo build -p cargo-credential-1password
123+
- run: cargo build -p cargo-credential-gnome-secret
131124
if: matrix.os == 'ubuntu-latest'
132-
- run: cargo build --manifest-path crates/credential/cargo-credential-macos-keychain/Cargo.toml
125+
- run: cargo build -p cargo-credential-macos-keychain
133126
if: matrix.os == 'macos-latest'
134-
- run: cargo build --manifest-path crates/credential/cargo-credential-wincred/Cargo.toml
127+
- run: cargo build -p cargo-credential-wincred
135128
if: matrix.os == 'windows-latest'
136129
- name: Check benchmarks
137-
env:
138-
# Share the target dir to try to cache a few build-time deps.
139-
CARGO_TARGET_DIR: target
140130
run: |
141131
# This only tests one benchmark since it can take over 10 minutes to
142132
# download all workspaces.
143-
cargo test --manifest-path benches/benchsuite/Cargo.toml --all-targets -- cargo
144-
cargo check --manifest-path benches/capture/Cargo.toml
133+
cargo test -p benchsuite --all-targets -- cargo
134+
cargo check -p capture
145135
# The testsuite generates a huge amount of data, and fetch-smoke-test was
146136
# running out of disk space.
147137
- name: Clear benchmark output
@@ -164,7 +154,7 @@ jobs:
164154
- run: rustup target add i686-unknown-linux-gnu
165155
- run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y
166156
- run: rustup component add rustfmt || echo "rustfmt not available"
167-
- run: cargo test
157+
- run: cargo test -p cargo
168158
env:
169159
__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2: 1
170160

@@ -175,7 +165,7 @@ jobs:
175165
- run: rustup update nightly && rustup default nightly
176166
- run: rustup component add rust-src
177167
- run: cargo build
178-
- run: cargo test --test build-std
168+
- run: cargo test -p cargo --test build-std
179169
env:
180170
CARGO_RUN_BUILD_STD_TESTS: 1
181171
docs:
@@ -192,7 +182,8 @@ jobs:
192182
mkdir mdbook
193183
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.27/mdbook-v0.4.27-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
194184
echo `pwd`/mdbook >> $GITHUB_PATH
195-
- run: cargo doc --document-private-items --no-deps
185+
# TODO: should check all workspace members
186+
- run: cargo doc -p cargo --document-private-items --no-deps
196187
env:
197188
RUSTDOCFLAGS: -D warnings
198189
- run: cd src/doc && mdbook build --dest-dir ../../target/doc

0 commit comments

Comments
 (0)