Skip to content

Add cargo-make support #4191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .cargo/Makefile.toml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 0 additions & 12 deletions .cargo/config

This file was deleted.

10 changes: 6 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ jobs:
override: true
profile: minimal
default: true

- name: cargo-make
run: cargo install --force cargo-make
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth trying the GitHub Actions (https://github.com/sagiegurari/cargo-make#usage-ci-github-actions or https://github.com/marketplace/actions/rust-cargo-make) approach for grabbing cargo-make to see if that speeds things up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the advice! I have added rustc-cargo-make action.

Copy link
Contributor Author

@topecongiro topecongiro May 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, unfortunately, it looks like the rustc-cargo-make does not pick up the latest cargo-make even when told to do so 🤔 I will just use cargo install approach for now.


- 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
10 changes: 6 additions & 4 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -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}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems the Windows jobs aren't substituting here though seems right to me based on a cursory reading of the cargo make docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to change script_runner on windows: sagiegurari/cargo-make#62.

"cargo test --manifest-path ${RUSTFMT_MAKE_MANIFEST_PATH} -- --ignored",
]
18 changes: 2 additions & 16 deletions ci/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions rustfmt-core/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extend = { path = "../.cargo/Makefile.toml" }

[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
1 change: 1 addition & 0 deletions rustfmt-core/rustfmt-bin/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend = { path = "../Makefile.toml" }
1 change: 1 addition & 0 deletions rustfmt-core/rustfmt-lib/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend = { path = "../Makefile.toml" }
1 change: 1 addition & 0 deletions rustfmt-core/rustfmt-lib/config_proc_macro/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extend = { path = "../Makefile.toml" }