mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Add cargo-make files (#1504)
* Migrate run_stable_checks shell script to cargo-make * simplify makefile * More improvements based on new cargo-make features in development * initial work on migrating run_tests to cargo-make * do not test examples * Enforce cargo-make minimal version 0.32.2 * Start/stop httpbin docker container * Update Makefile.toml Co-authored-by: Simon <simon@siku2.io> * Update Makefile.toml Co-authored-by: Simon <simon@siku2.io> * use new cleanup task feature to ensure we cleanup docker container * bump min cargo-make version * Use configurable or default port number and also validate docker is installed * spelling mistake fix * fixing env set * ensure min cargo-make version Co-authored-by: Simon <simon@siku2.io>
This commit is contained in:
parent
7301abea14
commit
7e7b8baaec
165
Makefile.toml
Normal file
165
Makefile.toml
Normal file
@ -0,0 +1,165 @@
|
||||
|
||||
######################
|
||||
#
|
||||
# public tasks:
|
||||
# * stable-checks
|
||||
# * run-tests
|
||||
#
|
||||
######################
|
||||
|
||||
[config]
|
||||
min_version = "0.32.4"
|
||||
default_to_workspace = false
|
||||
|
||||
[env]
|
||||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
||||
CARGO_MAKE_CLIPPY_ARGS = "-- --deny=warnings"
|
||||
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = ""
|
||||
|
||||
[config.modify_core_tasks]
|
||||
private = true
|
||||
namespace = "core"
|
||||
|
||||
[tasks.stable-checks]
|
||||
description = "Runs all validations for both workspaces on rust stable only."
|
||||
condition = { channels = [ "stable" ] }
|
||||
run_task = { name = [ "stable-checks-flow", "stable-checks-stdweb" ], fork = true }
|
||||
|
||||
[tasks.run-tests]
|
||||
dependencies = ["tests-setup"]
|
||||
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["examples/*", "yewtil/examples/*"] }
|
||||
run_task = { name = [ "run-tests-flow", "run-tests-stdweb" ], fork = true, cleanup_task = "tests-cleanup" }
|
||||
|
||||
[tasks.stable-checks-stdweb]
|
||||
private = true
|
||||
cwd = "yew-stdweb"
|
||||
command = "cargo"
|
||||
args = [
|
||||
"make",
|
||||
"--loglevel",
|
||||
"${CARGO_MAKE_LOG_LEVEL}",
|
||||
"--profile",
|
||||
"${CARGO_MAKE_PROFILE}",
|
||||
"stable-checks-flow"
|
||||
]
|
||||
|
||||
[tasks.stable-checks-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = [
|
||||
"core::check-format-flow",
|
||||
"core::check-flow",
|
||||
"core::clippy-flow",
|
||||
"post-stable-checks"
|
||||
]
|
||||
|
||||
[tasks.post-stable-checks]
|
||||
|
||||
[tasks.web-check]
|
||||
command = "cargo"
|
||||
args = ["web", "check", "--target", "wasm32-unknown-unknown"]
|
||||
|
||||
[tasks.tests-setup]
|
||||
script = [
|
||||
'''
|
||||
#!@duckscript
|
||||
test_flags= array --headless --firefox
|
||||
yew_test_features= set wasm_test
|
||||
|
||||
fn set_httpbin_test_features
|
||||
HTTPBIN_URL = get_env HTTPBIN_URL
|
||||
echo INFO: using ${HTTPBIN_URL} for fetch service tests
|
||||
yew_test_features = set "${yew_test_features},httpbin_test"
|
||||
end
|
||||
|
||||
if is_defined HTTPBIN_URL
|
||||
set_httpbin_test_features
|
||||
else
|
||||
# only enable docker if docker executable is available
|
||||
# and --skip-httpbin cli argument not provided to cargo make
|
||||
docker_path = which docker
|
||||
start_docker = is_defined docker_path
|
||||
args_provided = not is_empty ${CARGO_MAKE_TASK_ARGS}
|
||||
if ${args_provided}
|
||||
args = split ${CARGO_MAKE_TASK_ARGS} ;
|
||||
for arg in ${args}
|
||||
if eq ${arg} --skip-httpbin
|
||||
start_docker = set false
|
||||
release ${args}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ${start_docker}
|
||||
echo Starting httpbin docker image...
|
||||
mkdir ./target
|
||||
cidfile = set ./target/httpbin_container.cid
|
||||
|
||||
# if container already running, stop it
|
||||
if is_file ${cidfile}
|
||||
container_id = readfile ${cidfile}
|
||||
rm ${cidfile}
|
||||
set_env HTTPBIN_CONTAINER_ID ${container_id}
|
||||
cm_run_task tests-cleanup
|
||||
end
|
||||
|
||||
# get local port
|
||||
docker_port = get_env YEW_HTTPBIN_PORT
|
||||
if not is_defined docker_port
|
||||
docker_port = set 7117
|
||||
end
|
||||
|
||||
# bind to a random free port
|
||||
exec docker run -d --cidfile ${cidfile} -p "${docker_port}:80" kennethreitz/httpbin
|
||||
container_id = readfile ${cidfile}
|
||||
container_id = trim ${container_id}
|
||||
set_env HTTPBIN_CONTAINER_ID ${container_id}
|
||||
|
||||
set_env HTTPBIN_URL http://localhost:${docker_port}
|
||||
set_httpbin_test_features
|
||||
|
||||
# wait for docker container to boot before running tests
|
||||
if is_defined HTTPBIN_WAIT
|
||||
sleep ${HTTPBIN_WAIT}
|
||||
else
|
||||
sleep 500
|
||||
end
|
||||
else
|
||||
echo INFO: HTTPBIN_URL isn't set, won't run fetch service tests
|
||||
echo " please see the CONTRIBUTING.md file for instructions"
|
||||
end
|
||||
end
|
||||
|
||||
yew_test_flags = array_join ${test_flags} " "
|
||||
echo "running tests with flags: ${yew_test_flags} and features: ${yew_test_features}"
|
||||
|
||||
set_env YEW_TEST_FLAGS ${yew_test_flags}
|
||||
set_env YEW_TEST_FEATURES ${yew_test_features}
|
||||
'''
|
||||
]
|
||||
|
||||
[tasks.tests-cleanup]
|
||||
condition = { env_set = ["HTTPBIN_CONTAINER_ID"] }
|
||||
ignore_errors = true
|
||||
command = "docker"
|
||||
args = ["rm", "--force", "${HTTPBIN_CONTAINER_ID}"]
|
||||
|
||||
[tasks.run-tests-flow]
|
||||
workspace = true
|
||||
dependencies = [ "test" ]
|
||||
|
||||
[tasks.run-tests-stdweb]
|
||||
private = true
|
||||
extend = "core::wasm-pack-base"
|
||||
cwd = "yew-stdweb"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )",
|
||||
"--",
|
||||
"--features",
|
||||
"${YEW_TEST_FEATURES}"
|
||||
]
|
||||
|
||||
[tasks.test]
|
||||
command = "cargo"
|
||||
args = ["test"]
|
||||
8
yew-functional/Makefile.toml
Normal file
8
yew-functional/Makefile.toml
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
[tasks.test]
|
||||
clear = true
|
||||
extend = "core::wasm-pack-base"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )"
|
||||
]
|
||||
16
yew-macro/Makefile.toml
Normal file
16
yew-macro/Makefile.toml
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
[tasks.test]
|
||||
clear = true
|
||||
dependencies = ["test-macro", "test-derive-props", "test-doc"]
|
||||
|
||||
[tasks.test-macro]
|
||||
command = "cargo"
|
||||
args = ["test", "--test", "macro_test"]
|
||||
|
||||
[tasks.test-derive-props]
|
||||
command = "cargo"
|
||||
args = ["test", "--test", "derive_props_test"]
|
||||
|
||||
[tasks.test-doc]
|
||||
command = "cargo"
|
||||
args = ["test", "--doc"]
|
||||
3
yew-stdweb/examples/webgl/Makefile.toml
Normal file
3
yew-stdweb/examples/webgl/Makefile.toml
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
[tasks.post-stable-checks]
|
||||
alias = "web-check"
|
||||
29
yew/Makefile.toml
Normal file
29
yew/Makefile.toml
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
[env]
|
||||
CARGO_MAKE_CLIPPY_ARGS = "--features cbor,msgpack,toml,yaml -- --deny=warnings"
|
||||
|
||||
[tasks."core::check"]
|
||||
args = ["check", "--features", "cbor,msgpack,toml,yaml"]
|
||||
|
||||
[tasks.test]
|
||||
clear = true
|
||||
dependencies = ["test-wasm", "test-doc-partial-features", "test-doc-all-features"]
|
||||
|
||||
[tasks.test-wasm]
|
||||
private = true
|
||||
extend = "core::wasm-pack-base"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )",
|
||||
"--",
|
||||
"--features",
|
||||
"${YEW_TEST_FEATURES}"
|
||||
]
|
||||
|
||||
[tasks.test-doc-partial-features]
|
||||
command = "cargo"
|
||||
args = ["test", "--doc", "--features", "doc_test,wasm_test,yaml,msgpack,cbor,toml"]
|
||||
|
||||
[tasks.test-doc-all-features]
|
||||
command = "cargo"
|
||||
args = ["test", "--doc", "--features", "doc_test,wasm_test,yaml,msgpack,cbor,toml,std_web,agent,services", "--no-default-features"]
|
||||
Loading…
x
Reference in New Issue
Block a user