Skip to content

Commit 5b938cb

Browse files
Make -Dwarnings mandatory when running build-and-test
1 parent e599b32 commit 5b938cb

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

.github/workflows/linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ jobs:
3636
rustup target add ${{ matrix.target }}
3737
3838
- name: Build and Test
39+
env:
40+
RUSTFLAGS: -D warnings
3941
run: cargo run --bin ci-integration build-and-test

.github/workflows/mac.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ jobs:
3232
rustup target add ${{ matrix.target }}
3333
3434
- name: Build and Test
35+
env:
36+
RUSTFLAGS: -D warnings
3537
run: cargo run --bin ci-integration build-and-test

.github/workflows/windows.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ jobs:
5858
shell: bash
5959

6060
- name: Build and Test
61+
env:
62+
RUSTFLAGS: -D warnings
6163
run: cargo run --bin ci-integration build-and-test

ci/build_and_test.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,24 @@ fn run_tests_in_dir(env: &HashMap<&str, &str>, dir: &str) -> Result<(), String>
88
}
99

1010
pub fn runner() -> Result<(), String> {
11-
let env = HashMap::from([("RUSTFLAGS", "-D warnings"), ("RUSTFMT_CI", "1")]);
11+
let Ok(rustflags) = std::env::var("RUSTFLAGS") else {
12+
return Err(
13+
"`RUSTFLAGS` environment variable must be set to run `build-and-test`".to_string(),
14+
);
15+
};
16+
if !rustflags.contains("-D warnings") && !rustflags.contains("-Dwarnings") {
17+
return Err(
18+
"`RUSTFLAGS` environment variable must contain `-Dwarnings` to run `build-and-test`"
19+
.to_string(),
20+
);
21+
}
22+
23+
let mut env = HashMap::from([("RUSTFLAGS", "-D warnings"), ("RUSTFMT_CI", "1")]);
24+
let value_holder;
25+
if let Ok(cfg_release_channel) = std::env::var("CFG_RELEASE_CHANNEL") {
26+
value_holder = cfg_release_channel;
27+
env.insert("CFG_RELEASE_CHANNEL", value_holder.as_str());
28+
}
1229

1330
// Print version information
1431
run_command_with_env("rustc", &["-Vv"], ".", &env)?;

0 commit comments

Comments
 (0)