Skip to content

Commit e36ee52

Browse files
authored
Add cargo-make support (#4191)
1 parent e952ff9 commit e36ee52

File tree

12 files changed

+84
-43
lines changed

12 files changed

+84
-43
lines changed

.cargo/Makefile.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This Makefile.toml defines common tasks and settings used in the rustfmt project.
2+
3+
[env]
4+
CFG_RELEASE = { value = "nightly", condition = { env_not_set = ["CFG_RELEASE"] } }
5+
CFG_RELEASE_CHANNEL = { value = "nightly", condition = { env_not_set = ["CFG_RELEASE_CHANNEL"] } }
6+
7+
[tasks.b]
8+
alias = "build"
9+
10+
[tasks.c]
11+
alias = "check"
12+
13+
[tasks.t]
14+
alias = "test"

.cargo/config

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/linux.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ jobs:
3939
override: true
4040
profile: minimal
4141
default: true
42+
43+
- name: cargo-make
44+
run: cargo install --force cargo-make
45+
4246
- name: build
4347
run: |
4448
rustc -Vv
4549
cargo -V
46-
cargo build --manifest-path rustfmt-core/Cargo.toml --workspace
50+
cargo make build
4751
4852
- name: test
49-
run: cargo test-all
50-
- name: test ignored
51-
run: cargo test-all -- --ignored
53+
run: cargo make test

.github/workflows/mac.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ jobs:
3232
override: true
3333
profile: minimal
3434
default: true
35+
36+
- name: cargo-make
37+
run: cargo install --force cargo-make
38+
3539
- name: build
3640
run: |
3741
rustc -Vv
3842
cargo -V
39-
cargo build --manifest-path rustfmt-core/Cargo.toml --workspace
43+
cargo make build
4044
4145
- name: test
42-
run: cargo test-all
43-
- name: test ignored
44-
run: cargo test-all -- --ignored
46+
run: cargo make test

.github/workflows/windows.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,17 @@ jobs:
8282
override: true
8383
profile: minimal
8484
default: true
85+
86+
- name: cargo-make
87+
run: cargo install --force cargo-make
88+
8589
- name: build
8690
run: |
8791
rustc -Vv
8892
cargo -V
89-
cargo build --manifest-path rustfmt-core/Cargo.toml --workspace
93+
cargo make build
9094
shell: cmd
9195

9296
- name: test
93-
run: cargo test-all
94-
shell: cmd
95-
- name: test ignored
96-
run: cargo test-all -- --ignored
97+
run: cargo make test
9798
shell: cmd

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ matrix:
4545

4646
script:
4747
- |
48-
export CFG_RELEASE_CHANNEL=nightly
49-
export CFG_RELEASE=nightly
48+
export CFG_RELEASE_CHANNEL=nightly
49+
export CFG_RELEASE=nightly
5050
if [ -z ${INTEGRATION} ]; then
5151
cargo build && cargo test && cargo test -- --ignored && cargo test --manifest-path rustfmt-core/Cargo.toml && cargo test --manifest-path rustfmt-core/Cargo.toml -- --ignored
5252
else

Makefile.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
extend = ".cargo/Makefile.toml"
2+
3+
[tasks.build]
4+
clear = true
5+
command = "cargo"
6+
args = [
7+
"build",
8+
"--manifest-path",
9+
"rustfmt-core/Cargo.toml",
10+
"--workspace",
11+
]
12+
13+
[tasks.install]
14+
command = "cargo"
15+
args = [
16+
"install",
17+
"--path",
18+
".",
19+
"--force",
20+
"--locked",
21+
]
22+
23+
[tasks.test]
24+
clear = true
25+
run_task = { name = ["test-bin", "test-lib"] }
26+
27+
[tasks.test-bin]
28+
env = { "RUSTFMT_MAKE_MANIFEST_PATH" = "rustfmt-core/rustfmt-bin/Cargo.toml" }
29+
run_task = "test-subproject"
30+
31+
[tasks.test-lib]
32+
env = { "RUSTFMT_MAKE_MANIFEST_PATH" = "rustfmt-core/rustfmt-lib/Cargo.toml" }
33+
run_task = "test-subproject"
34+
35+
[tasks.test-subproject]
36+
condition = { env_set = ["RUSTFMT_MAKE_MANIFEST_PATH"] }
37+
script_runner = "@shell"
38+
script = [
39+
"cargo test --manifest-path ${RUSTFMT_MAKE_MANIFEST_PATH}",
40+
"cargo test --manifest-path ${RUSTFMT_MAKE_MANIFEST_PATH} -- --ignored",
41+
]

ci/integration.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,8 @@ set -ex
44

55
: ${INTEGRATION?"The INTEGRATION environment variable must be set."}
66

7-
# FIXME: this means we can get a stale cargo-fmt from a previous run.
8-
#
9-
# `which rustfmt` fails if rustfmt is not found. Since we don't install
10-
# `rustfmt` via `rustup`, this is the case unless we manually install it. Once
11-
# that happens, `cargo install --force` will be called, which installs
12-
# `rustfmt`, `cargo-fmt`, etc to `~/.cargo/bin`. This directory is cached by
13-
# travis (see `.travis.yml`'s "cache" key), such that build-bots that arrive
14-
# here after the first installation will find `rustfmt` and won't need to build
15-
# it again.
16-
#
17-
#which cargo-fmt || cargo install --force
18-
19-
export CFG_RELEASE_CHANNEL=nightly
20-
export CFG_RELEASE=nightly
21-
22-
cargo install --path . --force --locked
7+
which cargo-make || cargo install --force cargo-make
8+
cargo make install
239

2410
echo "Integration tests for: ${INTEGRATION}"
2511
cargo fmt -- --version

rustfmt-core/Makefile.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extend = { path = "../.cargo/Makefile.toml" }
2+
3+
[env]
4+
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extend = { path = "../Makefile.toml" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extend = { path = "../Makefile.toml" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extend = { path = "../Makefile.toml" }

0 commit comments

Comments
 (0)