refactor(examples): extract client process tasks (#1665) (#1666)

* doc(test-report): report trunk and node

* refactor(examples): extract client process tasks

* chore(exaples): force ci
This commit is contained in:
Joseph Cruz 2023-09-08 07:31:55 -04:00 committed by GitHub
parent 03cabf6ea3
commit 905d46a09d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 96 additions and 137 deletions

View File

@ -51,7 +51,7 @@ echo "CARGO_MAKE_CRATE_WORKSPACE_MEMBERS = $examples"
[tasks.test-report]
workspace = false
description = "report ci test runners and tools for each example - OPTION: [all]"
description = "report web testing technology used by examples - OPTION: [all]"
script = '''
set -emu
@ -62,9 +62,7 @@ YELLOW="\e[0;33m"
RESET="\e[0m"
echo
echo "${YELLOW}Test Report${RESET}"
echo
echo "${ITALIC}Pass the option \"all\" to show all the examples${RESET}"
echo "${YELLOW}Web Test Technology${RESET}"
echo
makefile_paths=$(find . -name Makefile.toml -not -path '*/target/*' -not -path '*/node_modules/*' |
@ -80,15 +78,7 @@ for path in $makefile_paths; do
crate_symbols=
test_count=$(grep -r --exclude-dir=target --exclude-dir=node_modules --fixed-strings "#[test]" | wc -l)
if [ $test_count -gt 0 ]; then
crate_symbols="T"
fi
rstest_count=$(grep -r --exclude-dir=target --exclude-dir=node_modules --fixed-strings "#[rstest]" | wc -l)
if [ $rstest_count -gt 0 ]; then
crate_symbols=$crate_symbols"R"
fi
pw_count=$(find . -name playwright.config.ts | wc -l)
while read -r line; do
case $line in
@ -96,22 +86,36 @@ for path in $makefile_paths; do
crate_symbols=$crate_symbols"C"
;;
*"fantoccini"*)
crate_symbols=$crate_symbols"F"
crate_symbols=$crate_symbols"D"
;;
esac
done <"./Cargo.toml"
while read -r line; do
case $line in
*"cargo-make/wasm-test"*)
*"cargo-make/wasm-test.toml"*)
crate_symbols=$crate_symbols"W"
;;
*"cargo-make/playwright"*)
*"cargo-make/playwright-test.toml"*)
crate_symbols=$crate_symbols"P"
crate_symbols=$crate_symbols"N"
;;
*"cargo-make/cargo-leptos-test"*)
*"cargo-make/playwright-trunk-test.toml"*)
crate_symbols=$crate_symbols"P"
crate_symbols=$crate_symbols"T"
;;
*"cargo-make/trunk_server.toml"*)
crate_symbols=$crate_symbols"T"
;;
*"cargo-make/cargo-leptos-webdriver-test.toml"*)
crate_symbols=$crate_symbols"L"
;;
*"cargo-make/cargo-leptos-test.toml"*)
crate_symbols=$crate_symbols"L"
if [ $pw_count -gt 0 ]; then
crate_symbols=$crate_symbols"P"
fi
;;
esac
done <"./Makefile.toml"
@ -135,20 +139,15 @@ for path in $makefile_paths; do
cd ${start_path}
done
c="${BOLD}${YELLOW}C${RESET} = Cucumber Test"
f="${BOLD}${YELLOW}F${RESET} = Fantoccini WebDriver"
l="${BOLD}${YELLOW}L${RESET} = Cargo Leptos Test"
p="${BOLD}${YELLOW}P${RESET} = Playwright Test"
r="${BOLD}${YELLOW}R${RESET} = RS Test"
u="${BOLD}${YELLOW}U${RESET} = Unit Test"
w="${BOLD}${YELLOW}W${RESET} = WASM Test"
c="${BOLD}${YELLOW}C${RESET} = Cucumber"
d="${BOLD}${YELLOW}D${RESET} = WebDriver"
l="${BOLD}${YELLOW}L${RESET} = Cargo Leptos"
n="${BOLD}${YELLOW}N${RESET} = Node"
p="${BOLD}${YELLOW}P${RESET} = Playwright"
t="${BOLD}${YELLOW}T${RESET} = Trunk"
w="${BOLD}${YELLOW}W${RESET} = WASM"
echo
echo "${ITALIC}Keys:${RESET}\n $c\n $f\n $l\n $p\n $r\n $u\n $w"
echo "${ITALIC}Keys:${RESET} $c, $d, $l, $n, $p, $t, $w"
echo
'''
# ALIASES
[tasks.tr]
alias = "test-report"

View File

@ -4,4 +4,4 @@ The examples in this directory are all built and tested against the current `mai
To the extent that new features have been released or breaking changes have been made since the previous release, the examples are compatible with the `main` branch and not the current release.
To see the examples as they were at the time of the `0.3.0` release, [click here](https://github.com/leptos-rs/leptos/tree/v0.3.0/examples).
To see the examples as they were at the time of the `0.3.0` release, [click here](https://github.com/leptos-rs/leptos/tree/v0.3.0/examples).

View File

@ -2,7 +2,3 @@ extend = { path = "./cargo-leptos.toml" }
[tasks.integration-test]
dependencies = ["install-cargo-leptos", "cargo-leptos-e2e"]
[tasks.cargo-leptos-e2e]
command = "cargo"
args = ["leptos", "end-to-end"]

View File

@ -0,0 +1,7 @@
extend = [
{ path = "./cargo-leptos.toml" },
{ path = "../cargo-make/webdriver.toml" },
]
[tasks.integration-test]
dependencies = ["install-cargo-leptos", "start-webdriver", "cargo-leptos-e2e"]

View File

@ -1,6 +1,12 @@
extend = { path = "../cargo-make/client-process.toml" }
[tasks.install-cargo-leptos]
install_crate = { crate_name = "cargo-leptos", binary = "cargo-leptos", test_arg = "--help" }
[tasks.cargo-leptos-e2e]
command = "cargo"
args = ["leptos", "end-to-end"]
[tasks.build]
clear = true
command = "cargo"
@ -25,31 +31,3 @@ install_crate = "cargo-all-features"
[tasks.start-client]
command = "cargo"
args = ["leptos", "watch"]
[tasks.stop-client]
condition = { env_set = ["APP_PROCESS_NAME"] }
script = '''
if [ ! -z $(pidof ${APP_PROCESS_NAME}) ]; then
pkill -f todo_app_sqlite
fi
if [ ! -z $(pidof ${APP_PROCESS_NAME}) ]; then
pkill -f cargo-leptos
fi
'''
[tasks.client-status]
condition = { env_set = ["APP_PROCESS_NAME"] }
script = '''
if [ -z $(pidof ${APP_PROCESS_NAME}) ]; then
echo " ${APP_PROCESS_NAME} is not running"
else
echo " ${APP_PROCESS_NAME} is up"
fi
if [ -z $(pidof cargo-leptos) ]; then
echo " cargo-leptos is not running"
else
echo " cargo-leptos is up"
fi
'''

View File

@ -0,0 +1,35 @@
[tasks.start-client]
[tasks.stop-client]
condition = { env_set = ["CLIENT_PROCESS_NAME"] }
script = '''
if [ ! -z $(pidof ${CLIENT_PROCESS_NAME}) ]; then
pkill -ef ${CLIENT_PROCESS_NAME}
fi
'''
[tasks.client-status]
condition = { env_set = ["CLIENT_PROCESS_NAME"] }
script = '''
if [ -z $(pidof ${CLIENT_PROCESS_NAME}) ]; then
echo " ${CLIENT_PROCESS_NAME} is not running"
else
echo " ${CLIENT_PROCESS_NAME} is up"
fi
'''
[tasks.maybe-start-client]
condition = { env_set = ["CLIENT_PROCESS_NAME"] }
script = '''
if [ -z $(pidof ${CLIENT_PROCESS_NAME}) ]; then
echo " Starting ${CLIENT_PROCESS_NAME}"
cargo make start-client ${@} &
else
echo " ${CLIENT_PROCESS_NAME} is already started"
fi
'''
# ALIASES
[tasks.dev]
alias = "maybe-start-client"

View File

@ -5,10 +5,10 @@ extend = [
[tasks.integration-test]
dependencies = [
"maybe-start-trunk",
"maybe-start-client",
"wait-one",
"test-playwright",
"stop-trunk",
"stop-client",
]
[tasks.wait-one]

View File

@ -1,36 +1,12 @@
extend = { path = "../cargo-make/client-process.toml" }
[env]
CLIENT_PROCESS_NAME = "trunk"
[tasks.build]
command = "trunk"
args = ["build"]
[tasks.start-trunk]
[tasks.start-client]
command = "trunk"
args = ["serve", "${@}"]
[tasks.stop-trunk]
script = '''
pkill -ef "trunk"
'''
[tasks.trunk-status]
script = '''
if [ -z $(pidof trunk) ]; then
echo trunk is not running
else
echo trunk is up
fi
'''
[tasks.maybe-start-trunk]
script = '''
if [ -z $(pidof trunk) ]; then
echo Starting trunk...
cargo make start-trunk ${@} &
else
echo Trunk already started
fi
'''
# ALIASES
[tasks.dev]
dependencies = ["start-trunk"]

View File

@ -1,22 +1,10 @@
extend = [
{ path = "../cargo-make/main.toml" },
{ path = "../cargo-make/webdriver.toml" },
{ path = "../cargo-make/cargo-leptos.toml" },
{ path = "../cargo-make/cargo-leptos-webdriver-test.toml" },
]
[env]
APP_PROCESS_NAME = "suspense_tests"
[tasks.integration-test]
dependencies = [
"install-cargo-leptos",
"start-webdriver",
"test-e2e-with-auto-start",
]
[tasks.test-e2e-with-auto-start]
command = "cargo"
args = ["leptos", "end-to-end"]
CLIENT_PROCESS_NAME = "suspense_tests"
[tasks.test-ui]
cwd = "./e2e"

View File

@ -1,4 +1,8 @@
extend = [
{ path = "../cargo-make/main.toml" },
{ path = "../cargo-make/playwright.toml" },
{ path = "../cargo-make/cargo-leptos-test.toml" },
]
[env]
CLIENT_PROCESS_NAME = "tailwind"

View File

@ -1,22 +1,10 @@
extend = [
{ path = "../cargo-make/main.toml" },
{ path = "../cargo-make/webdriver.toml" },
{ path = "../cargo-make/cargo-leptos.toml" },
{ path = "../cargo-make/cargo-leptos-webdriver-test.toml" },
]
[env]
APP_PROCESS_NAME = "todo_app_sqlite"
[tasks.integration-test]
dependencies = [
"install-cargo-leptos",
"start-webdriver",
"test-e2e-with-auto-start",
]
[tasks.test-e2e-with-auto-start]
command = "cargo"
args = ["leptos", "end-to-end"]
CLIENT_PROCESS_NAME = "todo_app_sqlite"
[tasks.test-ui]
cwd = "./e2e"

View File

@ -1,22 +1,10 @@
extend = [
{ path = "../cargo-make/main.toml" },
{ path = "../cargo-make/webdriver.toml" },
{ path = "../cargo-make/cargo-leptos.toml" },
{ path = "../cargo-make/cargo-leptos-webdriver-test.toml" },
]
[env]
APP_PROCESS_NAME = "todo_app_sqlite_axum"
[tasks.integration-test]
dependencies = [
"install-cargo-leptos",
"start-webdriver",
"test-e2e-with-auto-start",
]
[tasks.test-e2e-with-auto-start]
command = "cargo"
args = ["leptos", "end-to-end"]
CLIENT_PROCESS_NAME = "todo_app_sqlite_axum"
[tasks.test-ui]
cwd = "./e2e"