diff --git a/.cargo/Makefile.toml b/.cargo/Makefile.toml new file mode 100644 index 00000000000..3f771a9dfd3 --- /dev/null +++ b/.cargo/Makefile.toml @@ -0,0 +1,14 @@ +# This Makefile.toml defines common tasks and settings used in the rustfmt project. + +[env] +CFG_RELEASE = { value = "nightly", condition = { env_not_set = ["CFG_RELEASE"] } } +CFG_RELEASE_CHANNEL = { value = "nightly", condition = { env_not_set = ["CFG_RELEASE_CHANNEL"] } } + +[tasks.b] +alias = "build" + +[tasks.c] +alias = "check" + +[tasks.t] +alias = "test" diff --git a/.cargo/config b/.cargo/config deleted file mode 100644 index b6df9194d4b..00000000000 --- a/.cargo/config +++ /dev/null @@ -1,12 +0,0 @@ -[alias] -t = "test-all" -ta = "test-all" -test-all = "test --manifest-path rustfmt-core/Cargo.toml" - -test-bin = "test --manifest-path rustfmt-core/rustfmt-bin/Cargo.toml" -tb = "test-bin" - -test-lib = "test --manifest-path rustfmt-core/rustfmt-lib/Cargo.toml" -tl = "test-lib" - -i = "install --path . --force --locked" diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6074c9c76b5..559eaec1595 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -39,13 +39,15 @@ jobs: override: true profile: minimal default: true + + - name: cargo-make + run: cargo install --force cargo-make + - name: build run: | rustc -Vv cargo -V - cargo build --manifest-path rustfmt-core/Cargo.toml --workspace + cargo make build - name: test - run: cargo test-all - - name: test ignored - run: cargo test-all -- --ignored + run: cargo make test diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 183d5dc7bc7..39a6c1cc4d2 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -32,13 +32,15 @@ jobs: override: true profile: minimal default: true + + - name: cargo-make + run: cargo install --force cargo-make + - name: build run: | rustc -Vv cargo -V - cargo build --manifest-path rustfmt-core/Cargo.toml --workspace + cargo make build - name: test - run: cargo test-all - - name: test ignored - run: cargo test-all -- --ignored + run: cargo make test diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index dcb80852611..e3b95ee115d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -82,16 +82,17 @@ jobs: override: true profile: minimal default: true + + - name: cargo-make + run: cargo install --force cargo-make + - name: build run: | rustc -Vv cargo -V - cargo build --manifest-path rustfmt-core/Cargo.toml --workspace + cargo make build shell: cmd - name: test - run: cargo test-all - shell: cmd - - name: test ignored - run: cargo test-all -- --ignored + run: cargo make test shell: cmd diff --git a/.travis.yml b/.travis.yml index 7f92a175f00..f59f51f0470 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,8 +45,8 @@ matrix: script: - | - export CFG_RELEASE_CHANNEL=nightly - export CFG_RELEASE=nightly + export CFG_RELEASE_CHANNEL=nightly + export CFG_RELEASE=nightly if [ -z ${INTEGRATION} ]; then cargo build && cargo test && cargo test -- --ignored && cargo test --manifest-path rustfmt-core/Cargo.toml && cargo test --manifest-path rustfmt-core/Cargo.toml -- --ignored else diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 00000000000..e26685aba54 --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,41 @@ +extend = ".cargo/Makefile.toml" + +[tasks.build] +clear = true +command = "cargo" +args = [ + "build", + "--manifest-path", + "rustfmt-core/Cargo.toml", + "--workspace", +] + +[tasks.install] +command = "cargo" +args = [ + "install", + "--path", + ".", + "--force", + "--locked", +] + +[tasks.test] +clear = true +run_task = { name = ["test-bin", "test-lib"] } + +[tasks.test-bin] +env = { "RUSTFMT_MAKE_MANIFEST_PATH" = "rustfmt-core/rustfmt-bin/Cargo.toml" } +run_task = "test-subproject" + +[tasks.test-lib] +env = { "RUSTFMT_MAKE_MANIFEST_PATH" = "rustfmt-core/rustfmt-lib/Cargo.toml" } +run_task = "test-subproject" + +[tasks.test-subproject] +condition = { env_set = ["RUSTFMT_MAKE_MANIFEST_PATH"] } +script_runner = "@shell" +script = [ + "cargo test --manifest-path ${RUSTFMT_MAKE_MANIFEST_PATH}", + "cargo test --manifest-path ${RUSTFMT_MAKE_MANIFEST_PATH} -- --ignored", +] diff --git a/ci/integration.sh b/ci/integration.sh index 823f176a95b..09d0fb959f5 100755 --- a/ci/integration.sh +++ b/ci/integration.sh @@ -4,22 +4,8 @@ set -ex : ${INTEGRATION?"The INTEGRATION environment variable must be set."} -# FIXME: this means we can get a stale cargo-fmt from a previous run. -# -# `which rustfmt` fails if rustfmt is not found. Since we don't install -# `rustfmt` via `rustup`, this is the case unless we manually install it. Once -# that happens, `cargo install --force` will be called, which installs -# `rustfmt`, `cargo-fmt`, etc to `~/.cargo/bin`. This directory is cached by -# travis (see `.travis.yml`'s "cache" key), such that build-bots that arrive -# here after the first installation will find `rustfmt` and won't need to build -# it again. -# -#which cargo-fmt || cargo install --force - -export CFG_RELEASE_CHANNEL=nightly -export CFG_RELEASE=nightly - -cargo install --path . --force --locked +which cargo-make || cargo install --force cargo-make +cargo make install echo "Integration tests for: ${INTEGRATION}" cargo fmt -- --version diff --git a/rustfmt-core/Makefile.toml b/rustfmt-core/Makefile.toml new file mode 100644 index 00000000000..632f925a4ec --- /dev/null +++ b/rustfmt-core/Makefile.toml @@ -0,0 +1,4 @@ +extend = { path = "../.cargo/Makefile.toml" } + +[env] +CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true" diff --git a/rustfmt-core/rustfmt-bin/Makefile.toml b/rustfmt-core/rustfmt-bin/Makefile.toml new file mode 100644 index 00000000000..65706bdf2d4 --- /dev/null +++ b/rustfmt-core/rustfmt-bin/Makefile.toml @@ -0,0 +1 @@ +extend = { path = "../Makefile.toml" } diff --git a/rustfmt-core/rustfmt-lib/Makefile.toml b/rustfmt-core/rustfmt-lib/Makefile.toml new file mode 100644 index 00000000000..65706bdf2d4 --- /dev/null +++ b/rustfmt-core/rustfmt-lib/Makefile.toml @@ -0,0 +1 @@ +extend = { path = "../Makefile.toml" } diff --git a/rustfmt-core/rustfmt-lib/config_proc_macro/Makefile.toml b/rustfmt-core/rustfmt-lib/config_proc_macro/Makefile.toml new file mode 100644 index 00000000000..65706bdf2d4 --- /dev/null +++ b/rustfmt-core/rustfmt-lib/config_proc_macro/Makefile.toml @@ -0,0 +1 @@ +extend = { path = "../Makefile.toml" }