Skip to content

Commit 18f004b

Browse files
authored
Fix cargo make config and tests (yewstack#2640)
* remove pr-flow, run all the tests when asked * make tests that were never run pass * run tests cargo make properly * use wasm-pack-base test for running wasm tests * cargo make config should be good * update CI
1 parent b712f6c commit 18f004b

File tree

14 files changed

+110
-117
lines changed

14 files changed

+110
-117
lines changed

.github/PULL_REQUEST_TEMPLATE.md

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Fixes #0000 <!-- replace with issue number or remove if not applicable -->
88

99
<!-- For further details, please read CONTRIBUTING.md -->
1010

11-
- [ ] I have run `cargo make pr-flow`
1211
- [ ] I have reviewed my own code
1312
- [ ] I have added tests
1413
<!-- If this is a bug fix, these tests will fail if the bug is present (to stop it from cropping up again) -->

.github/workflows/main-checks.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ jobs:
8787
sudo apt-get install aspell
8888
ci/spellcheck.sh list
8989
90-
9190
- name: Run doctest
9291
uses: actions-rs/cargo@v1
9392
with:
@@ -106,8 +105,6 @@ jobs:
106105
command: test
107106
args: --doc --features doc_test --features wasm_test
108107

109-
110-
111108
integration_tests:
112109
name: Integration Tests on ${{ matrix.toolchain }}
113110
runs-on: ubuntu-latest
@@ -134,7 +131,6 @@ jobs:
134131

135132
- uses: Swatinem/rust-cache@v1
136133

137-
138134
- name: Run tests - yew
139135
run: |
140136
cd packages/yew
@@ -170,13 +166,17 @@ jobs:
170166

171167
- uses: Swatinem/rust-cache@v1
172168

173-
- name: Run tests
169+
- name: Run native tests
174170
uses: actions-rs/cargo@v1
175171
with:
176172
command: test
177173
args: --all-targets --workspace --exclude yew --exclude website-test
178174

179-
175+
- name: Run native tests for yew
176+
uses: actions-rs/cargo@v1
177+
with:
178+
command: test
179+
args: -p yew --features "csr,ssr,hydration"
180180

181181
test-lints:
182182
name: Test lints on nightly
@@ -192,7 +192,6 @@ jobs:
192192

193193
- uses: Swatinem/rust-cache@v1
194194

195-
196195
- name: Run tests
197196
uses: actions-rs/cargo@v1
198197
with:

Makefile.toml

+42-56
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,90 @@
11
######################
22
#
33
# public tasks:
4-
# * pr-flow
5-
# * lint
6-
# * lint-release
7-
# * tests
4+
# * checks-flow
5+
# * lint
6+
# * lint-release
7+
# * format
8+
# * test-flow
9+
# * test
10+
# * doc-test
11+
# * website-test
812
#
13+
# packages/yew also contains `clippy-feature-soundness` to ensure everything is fine
914
# Run `cargo make --list-all-steps` for more details.
1015
#
1116
######################
1217
[config]
1318
min_version = "0.32.4"
19+
skip_core_tasks = true
1420
default_to_workspace = false
1521

1622
[env]
1723
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
1824
CARGO_MAKE_CLIPPY_ARGS = "-- --deny=warnings"
25+
CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = [
26+
"examples/*",
27+
"tools/*",
28+
]
1929

2030
[config.modify_core_tasks]
2131
private = true
2232
namespace = "core"
2333

24-
[tasks.pr-flow]
25-
toolchain = "stable"
26-
category = "Checks"
27-
description = "Lint and test"
28-
run_task = { name = ["lint", "lint-release", "tests"], fork = true }
34+
# checks
2935

3036
[tasks.lint]
3137
category = "Checks"
32-
description = "Check formatting and run Clippy"
33-
toolchain = "nightly"
34-
run_task = { name = ["lint-flow"], fork = true }
35-
36-
[tasks.tests]
37-
category = "Testing"
38-
description = "Run all tests"
39-
dependencies = ["tests-setup"]
40-
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["**/examples/*", "**/packages/changelog"] }
41-
run_task = { name = ["test-flow", "doc-test-flow", "ssr-test", "website-test"], fork = true }
42-
43-
[tasks.lint-flow]
44-
private = true
45-
workspace = true
46-
dependencies = ["core::check-format-flow", "core::clippy-flow"]
38+
description = "Runs clippy"
39+
command = "cargo"
40+
args = ["clippy", "--", "--deny=warnings"]
4741

4842
# Needed, because we have some code differences between debug and release builds
4943
[tasks.lint-release]
5044
category = "Checks"
51-
workspace = true
5245
command = "cargo"
5346
args = ["clippy", "--all-targets", "--release", "--", "--deny=warnings"]
5447

55-
[tasks.tests-setup]
56-
private = true
57-
script_runner = "@duckscript"
58-
script = [
59-
"""
60-
test_flags = array --headless --firefox
61-
yew_test_features = set wasm_test
62-
63-
yew_test_flags = array_join ${test_flags} " "
64-
echo "running tests with flags: ${yew_test_flags} and features: ${yew_test_features}"
65-
66-
set_env YEW_TEST_FLAGS ${yew_test_flags}
67-
set_env YEW_TEST_FEATURES ${yew_test_features}
68-
""",
69-
]
48+
[tasks.format]
49+
category = "Checks"
50+
toolchain = "nightly"
51+
env = { CARGO_MAKE_RUST_CHANNEL = "nightly" }
7052

71-
[tasks.test-flow]
72-
private = true
73-
workspace = true
74-
dependencies = ["test"]
53+
54+
[tasks.checks-flow]
55+
category = "Checks"
56+
description = "Runs clippy in debug and release mode and format all the code"
57+
run_task = { name = ["lint", "lint-release", "format"], fork = true }
58+
59+
# Tests
7560

7661
[tasks.test]
77-
private = true
7862
command = "cargo"
7963
args = ["test", "--all-targets"]
80-
81-
[tasks.doc-test-flow]
82-
private = true
8364
workspace = true
84-
dependencies = ["doc-test"]
8565

8666
[tasks.doc-test]
87-
private = true
8867
command = "cargo"
89-
args = ["test", "--doc"]
68+
args = ["test", "--doc", "--all-features"]
69+
workspace = true
9070

9171
[tasks.website-test]
9272
command = "cargo"
9373
args = ["test", "-p", "website-test"]
9474

75+
[tasks.test-flow]
76+
category = "Testing"
77+
description = "Run all tests"
78+
run_task = { name = ["test", "doc-test", "website-test"], fork = true, parallel = true }
79+
80+
# misc
81+
9582
[tasks.generate-change-log]
9683
category = "Maintainer processes"
9784
toolchain = "stable"
9885
command = "cargo"
99-
args = ["run","-p","changelog", "--release", "${@}"]
86+
args = ["run", "-p", "changelog", "--release", "${@}"]
10087

101-
[tasks.ssr-test]
102-
env = { CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS = ["**/packages/yew"] }
103-
private = true
104-
workspace = true
88+
[tasks.default]
89+
#run_task = { name = ["checks-flow", "test-flow"], fork = true }
90+
dependencies = ["checks-flow", "test-flow"]

packages/yew-macro/Makefile.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tasks.test]
22
clear = true
3-
toolchain = ""
3+
toolchain = "1.56.0"
44
command = "cargo"
55
# test target can be optionally specified like `cargo make test html_macro`,
66
args = ["test", "${@}"]
@@ -9,7 +9,7 @@ args = ["test", "${@}"]
99
clear = true
1010
toolchain = "nightly"
1111
command = "cargo"
12-
args = ["test test_html_lints --features lints"]
12+
args = ["test", "test_html_lints", "--features", "lints"]
1313

1414
[tasks.test-overwrite]
1515
extend = "test"

packages/yew-router-macro/Makefile.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tasks.test]
22
clear = true
3-
toolchain = "1.56"
3+
toolchain = "1.56.0"
44
command = "cargo"
55
args = ["test"]
66

packages/yew-router/Makefile.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
[tasks.test]
2-
extend = "core::wasm-pack-base"
32
command = "wasm-pack"
43
args = [
54
"test",
6-
"@@split(YEW_TEST_FLAGS, )",
7-
"--",
8-
"--features",
9-
"${YEW_TEST_FEATURES}",
5+
"--firefox",
6+
"--headless",
107
]

packages/yew/Makefile.toml

+8-23
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
11
[tasks.native-test]
22
command = "cargo"
3-
toolchain = "1.56"
4-
args = ["test", "native_"]
3+
args = ["test", "--features", "csr,ssr,hydration"]
54

6-
[tasks.test]
7-
dependencies = ["native-test"]
8-
extend = "core::wasm-pack-base"
5+
[tasks.wasm-test]
96
command = "wasm-pack"
107
args = [
118
"test",
12-
"@@split(YEW_TEST_FLAGS, )",
9+
"--firefox",
10+
"--headless",
1311
"--",
1412
"--features",
15-
"${YEW_TEST_FEATURES}",
16-
]
17-
18-
[tasks.doc-test]
19-
clear = true
20-
run_task = { name = ["doc-test-normal"], fork = true }
21-
22-
[tasks.doc-test-normal]
23-
command = "cargo"
24-
args = [
25-
"test",
26-
"--doc",
27-
"--features",
28-
"tokio,doc_test,wasm_test",
13+
"wasm_test"
2914
]
3015

3116
[tasks.ssr-test]
3217
command = "cargo"
3318
args = ["test", "ssr_tests", "--features", "ssr"]
3419

20+
[tasks.test]
21+
dependencies = ["native-test", "wasm-test"]
22+
3523
[tasks.clippy-feature-soundness]
3624
script = '''
3725
#!/usr/bin/env bash
@@ -48,6 +36,3 @@ cargo clippy --release --features=csr -- --deny=warnings
4836
cargo clippy --release --features=hydration -- --deny=warnings
4937
cargo clippy --release --all-features --all-targets -- --deny=warnings
5038
'''
51-
52-
[tasks.lint-flow]
53-
dependencies = ["clippy-feature-soundness"]

packages/yew/src/dom_bundle/blist.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ mod feat_hydration {
504504
}
505505
}
506506

507-
#[cfg(test)]
507+
#[cfg(all(test, feature = "wasm_test"))]
508508
mod layout_tests {
509509
extern crate self as yew;
510510

@@ -514,7 +514,6 @@ mod layout_tests {
514514
use crate::html;
515515
use crate::tests::layout_tests::{diff_layouts, TestLayout};
516516

517-
#[cfg(feature = "wasm_test")]
518517
wasm_bindgen_test_configure!(run_in_browser);
519518

520519
#[test]
@@ -582,7 +581,7 @@ mod layout_tests {
582581
}
583582
}
584583

585-
#[cfg(test)]
584+
#[cfg(all(test, feature = "wasm_test"))]
586585
mod layout_tests_keys {
587586
extern crate self as yew;
588587

@@ -594,7 +593,6 @@ mod layout_tests_keys {
594593
use crate::virtual_dom::VNode;
595594
use crate::{html, Children, Component, Context, Html, Properties};
596595

597-
#[cfg(feature = "wasm_test")]
598596
wasm_bindgen_test_configure!(run_in_browser);
599597

600598
struct Comp {}

packages/yew/src/dom_bundle/bnode.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,14 @@ mod feat_hydration {
291291
}
292292
}
293293

294-
#[cfg(test)]
294+
#[cfg(all(test, feature = "wasm_test"))]
295295
mod layout_tests {
296296
#[cfg(feature = "wasm_test")]
297297
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
298298

299299
use super::*;
300300
use crate::tests::layout_tests::{diff_layouts, TestLayout};
301301

302-
#[cfg(feature = "wasm_test")]
303302
wasm_bindgen_test_configure!(run_in_browser);
304303

305304
#[test]

packages/yew/src/dom_bundle/bportal.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl BPortal {
118118
}
119119
}
120120

121-
#[cfg(test)]
121+
#[cfg(all(test, feature = "wasm_test"))]
122122
mod layout_tests {
123123
extern crate self as yew;
124124

@@ -130,7 +130,6 @@ mod layout_tests {
130130
use crate::tests::layout_tests::{diff_layouts, TestLayout};
131131
use crate::virtual_dom::VNode;
132132

133-
#[cfg(feature = "wasm_test")]
134133
wasm_bindgen_test_configure!(run_in_browser);
135134

136135
#[test]

0 commit comments

Comments
 (0)