From 08002de3183d61d181d6497a26bd239c7a6bb76a Mon Sep 17 00:00:00 2001 From: Joseph Cruz Date: Sat, 8 Jul 2023 22:11:00 -0400 Subject: [PATCH 1/5] refactor(cargo-make): extract node --- examples/cargo-make/common.toml | 53 ++------------------------------- examples/cargo-make/main.toml | 2 +- examples/cargo-make/node.toml | 50 +++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 examples/cargo-make/node.toml diff --git a/examples/cargo-make/common.toml b/examples/cargo-make/common.toml index 9766a16b03..b260f8ae84 100644 --- a/examples/cargo-make/common.toml +++ b/examples/cargo-make/common.toml @@ -1,3 +1,5 @@ +extend = [{ path = "../cargo-make/node.toml" }] + [tasks.pre-clippy] env = { CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features -- -D warnings" } @@ -21,13 +23,6 @@ category = "Cleanup" command = "trunk" args = ["clean"] -[tasks.clean-node_modules] -description = "Delete all node_modules directories" -category = "Cleanup" -script = ''' -find . -type d -name node_modules | xargs rm -rf -''' - [tasks.clean-playwright] description = "Delete playwright directories" category = "Cleanup" @@ -52,47 +47,3 @@ args = ["make", "wasm-pack-test"] description = "Runs end to end tests with cargo leptos" command = "cargo" args = ["leptos", "end-to-end"] - -[tasks.setup-node] -description = "Install node dependencies and playwright browsers" -env = { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1" } -script = ''' -BOLD="\e[1m" -GREEN="\e[0;32m" -RED="\e[0;31m" -RESET="\e[0m" - -project_dir=$CARGO_MAKE_WORKING_DIRECTORY - -# Discover commands -if command -v pnpm; then - NODE_CMD=pnpm - PLAYWRIGHT_CMD=pnpm -elif command -v npm; then - NODE_CMD=npm - PLAYWRIGHT_CMD=npx -else - echo "${RED}${BOLD}ERROR${RESET} - pnpm or npm is required by this task" - exit 1 -fi - -# Install node dependencies -for node_path in $(find . -name package.json -not -path '*/node_modules/*') -do - node_dir=$(dirname $node_path) - echo Install node dependencies for $node_dir - cd $node_dir - ${NODE_CMD} install - cd ${project_dir} -done - -# Install playwright browsers -for pw_path in $(find . -name playwright.config.ts) -do - pw_dir=$(dirname $pw_path) - echo Install playwright browsers for $pw_dir - cd $pw_dir - ${PLAYWRIGHT_CMD} playwright install - cd $project_dir -done -''' diff --git a/examples/cargo-make/main.toml b/examples/cargo-make/main.toml index da3c32c7a2..96c5d73bcd 100644 --- a/examples/cargo-make/main.toml +++ b/examples/cargo-make/main.toml @@ -1,4 +1,4 @@ -extend = [{ path = "../cargo-make/common.toml" }] +extend = { path = "../cargo-make/common.toml" } [tasks.ci] alias = "verify-flow" diff --git a/examples/cargo-make/node.toml b/examples/cargo-make/node.toml new file mode 100644 index 0000000000..d6a12c357e --- /dev/null +++ b/examples/cargo-make/node.toml @@ -0,0 +1,50 @@ +[tasks.clean-node_modules] +description = "Delete all node_modules directories" +category = "Cleanup" +script = ''' +find . -type d -name node_modules | xargs rm -rf +''' + +[tasks.setup-node] +description = "Install node dependencies and playwright browsers" +env = { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1" } +script = ''' +BOLD="\e[1m" +GREEN="\e[0;32m" +RED="\e[0;31m" +RESET="\e[0m" + +project_dir=$CARGO_MAKE_WORKING_DIRECTORY + +# Discover commands +if command -v pnpm; then + NODE_CMD=pnpm + PLAYWRIGHT_CMD=pnpm +elif command -v npm; then + NODE_CMD=npm + PLAYWRIGHT_CMD=npx +else + echo "${RED}${BOLD}ERROR${RESET} - pnpm or npm is required by this task" + exit 1 +fi + +# Install node dependencies +for node_path in $(find . -name package.json -not -path '*/node_modules/*') +do + node_dir=$(dirname $node_path) + echo Install node dependencies for $node_dir + cd $node_dir + ${NODE_CMD} install + cd ${project_dir} +done + +# Install playwright browsers +for pw_path in $(find . -name playwright.config.ts) +do + pw_dir=$(dirname $pw_path) + echo Install playwright browsers for $pw_dir + cd $pw_dir + ${PLAYWRIGHT_CMD} playwright install + cd $project_dir +done +''' From f3929bc43e495f65bc5ab7d062e196db339c27a5 Mon Sep 17 00:00:00 2001 From: Joseph Cruz Date: Sun, 9 Jul 2023 09:08:36 -0400 Subject: [PATCH 2/5] refactor(cargo-make): extract lint --- examples/cargo-make/common.toml | 16 ++++------------ examples/cargo-make/lint.toml | 10 ++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 examples/cargo-make/lint.toml diff --git a/examples/cargo-make/common.toml b/examples/cargo-make/common.toml index b260f8ae84..6030ad0a3b 100644 --- a/examples/cargo-make/common.toml +++ b/examples/cargo-make/common.toml @@ -1,15 +1,7 @@ -extend = [{ path = "../cargo-make/node.toml" }] - -[tasks.pre-clippy] -env = { CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features -- -D warnings" } - -[tasks.check-style] -description = "Check for style violations" -dependencies = ["check-format-flow", "clippy-flow"] - -[tasks.check-format] -env = { LEPTOS_PROJECT_DIRECTORY = "../../" } -args = ["fmt", "--", "--check", "--config-path", "${LEPTOS_PROJECT_DIRECTORY}"] +extend = [ + { path = "../cargo-make/lint.toml" }, + { path = "../cargo-make/node.toml" }, +] [tasks.clean-cargo] description = "Runs the cargo clean command." diff --git a/examples/cargo-make/lint.toml b/examples/cargo-make/lint.toml new file mode 100644 index 0000000000..b8c6c69608 --- /dev/null +++ b/examples/cargo-make/lint.toml @@ -0,0 +1,10 @@ +[tasks.pre-clippy] +env = { CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features -- -D warnings" } + +[tasks.check-style] +description = "Check for style violations" +dependencies = ["check-format-flow", "clippy-flow"] + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../../" } +args = ["fmt", "--", "--check", "--config-path", "${LEPTOS_PROJECT_DIRECTORY}"] From 2d524538c895482b24cf3518b7ea15254f832d22 Mon Sep 17 00:00:00 2001 From: Joseph Cruz Date: Sun, 9 Jul 2023 09:15:15 -0400 Subject: [PATCH 3/5] refactor(counters_stable): remove redundant tasks --- examples/cargo-make/common.toml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/examples/cargo-make/common.toml b/examples/cargo-make/common.toml index 6030ad0a3b..ac3923598a 100644 --- a/examples/cargo-make/common.toml +++ b/examples/cargo-make/common.toml @@ -9,22 +9,6 @@ category = "Cleanup" command = "cargo" args = ["clean"] -[tasks.clean-trunk] -description = "Runs the trunk clean command." -category = "Cleanup" -command = "trunk" -args = ["clean"] - -[tasks.clean-playwright] -description = "Delete playwright directories" -category = "Cleanup" -script = ''' -for pw_dir in $(find . -name playwright.config.ts | xargs dirname) -do - rm -rf $pw_dir/playwright-report pw_dir/playwright pw_dir/test-results -done -''' - [tasks.clean-all] description = "Delete all temporary directories" category = "Cleanup" From 13ee80501b5c14790ec8f9e0b0635639b66e6eac Mon Sep 17 00:00:00 2001 From: Joseph Cruz Date: Sun, 9 Jul 2023 09:20:07 -0400 Subject: [PATCH 4/5] docs(cargo-make): remove descriptions --- examples/cargo-make/common.toml | 5 ----- examples/cargo-make/lint.toml | 1 - examples/cargo-make/main.toml | 5 ----- examples/cargo-make/playwright.toml | 10 ---------- 4 files changed, 21 deletions(-) diff --git a/examples/cargo-make/common.toml b/examples/cargo-make/common.toml index ac3923598a..341f984b33 100644 --- a/examples/cargo-make/common.toml +++ b/examples/cargo-make/common.toml @@ -4,14 +4,10 @@ extend = [ ] [tasks.clean-cargo] -description = "Runs the cargo clean command." -category = "Cleanup" command = "cargo" args = ["clean"] [tasks.clean-all] -description = "Delete all temporary directories" -category = "Cleanup" dependencies = ["clean-cargo"] [tasks.test-wasm] @@ -20,6 +16,5 @@ command = "cargo" args = ["make", "wasm-pack-test"] [tasks.cargo-leptos-e2e] -description = "Runs end to end tests with cargo leptos" command = "cargo" args = ["leptos", "end-to-end"] diff --git a/examples/cargo-make/lint.toml b/examples/cargo-make/lint.toml index b8c6c69608..5f1e700db0 100644 --- a/examples/cargo-make/lint.toml +++ b/examples/cargo-make/lint.toml @@ -2,7 +2,6 @@ env = { CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features -- -D warnings" } [tasks.check-style] -description = "Check for style violations" dependencies = ["check-format-flow", "clippy-flow"] [tasks.check-format] diff --git a/examples/cargo-make/main.toml b/examples/cargo-make/main.toml index 96c5d73bcd..64c00067d8 100644 --- a/examples/cargo-make/main.toml +++ b/examples/cargo-make/main.toml @@ -4,15 +4,12 @@ extend = { path = "../cargo-make/common.toml" } alias = "verify-flow" [tasks.verify-flow] -description = "Provides pre and post hooks for verify" dependencies = ["pre-verify", "verify", "post-verify"] [tasks.verify] -description = "Run all quality checks and tests" dependencies = ["check-style", "test-unit-and-e2e"] [tasks.test-unit-and-e2e] -description = "Run all unit and e2e tests" dependencies = ["test-flow", "test-e2e-flow"] [tasks.pre-verify] @@ -21,11 +18,9 @@ dependencies = ["test-flow", "test-e2e-flow"] dependencies = ["maybe-clean-all"] [tasks.maybe-clean-all] -description = "Used to clean up locally after call to verify-examples" condition = { env_true = ["CLEAN_AFTER_VERIFY"] } [tasks.test-e2e-flow] -description = "Provides pre and post hooks for test-e2e" dependencies = ["pre-test-e2e", "test-e2e", "post-test-e2e"] [tasks.pre-test-e2e] diff --git a/examples/cargo-make/playwright.toml b/examples/cargo-make/playwright.toml index 5085b8cba7..a030d8fa9a 100644 --- a/examples/cargo-make/playwright.toml +++ b/examples/cargo-make/playwright.toml @@ -1,6 +1,4 @@ [tasks.clean-playwright] -description = "Delete playwright directories" -category = "Cleanup" script = ''' for pw_dir in $(find . -name playwright.config.ts | xargs dirname) do @@ -9,14 +7,10 @@ done ''' [tasks.test-playwright-autostart] -description = "Run playwright test with server autostart" -category = "Test" command = "npm" args = ["run", "e2e:auto-start"] [tasks.test-playwright] -description = "Run playwright test" -category = "Test" script = ''' BOLD="\e[1m" GREEN="\e[0;32m" @@ -46,8 +40,6 @@ done ''' [tasks.test-playwright-ui] -description = "Run playwright test --ui" -category = "Test" script = ''' BOLD="\e[1m" GREEN="\e[0;32m" @@ -77,8 +69,6 @@ done ''' [tasks.test-playwright-report] -description = "Run playwright show-report" -category = "Test" script = ''' BOLD="\e[1m" GREEN="\e[0;32m" From 5e9aa1760e1eb26123e30fb0a1618d1b2c38c06e Mon Sep 17 00:00:00 2001 From: Joseph Cruz Date: Sun, 9 Jul 2023 18:33:22 -0400 Subject: [PATCH 5/5] refactor(counters_stable): streamline stages --- Makefile.toml | 15 ++------ examples/cargo-make/cargo-leptos-test.toml | 9 ++--- examples/cargo-make/clean.toml | 28 +++++++++++++++ examples/cargo-make/common.toml | 20 ----------- examples/cargo-make/main.toml | 42 +++++++++++----------- examples/cargo-make/node.toml | 7 ---- examples/cargo-make/playwright-test.toml | 7 ++-- examples/cargo-make/playwright.toml | 8 ----- examples/cargo-make/trunk_server.toml | 6 +--- examples/cargo-make/wasm-test.toml | 6 ++-- 10 files changed, 65 insertions(+), 83 deletions(-) create mode 100644 examples/cargo-make/clean.toml delete mode 100644 examples/cargo-make/common.toml diff --git a/Makefile.toml b/Makefile.toml index 8e219a2950..5ca9991c7e 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -97,24 +97,15 @@ args = ["+nightly", "doc"] cwd = "leptos_macro/example" install_crate = false -[tasks.test-examples] -description = "Run all unit and web tests for examples" +[tasks.ci-examples] cwd = "examples" command = "cargo" -args = ["make", "test-unit-and-web"] - -[tasks.verify-examples] -description = "Run all quality checks and tests for examples" -env = { CLEAN_AFTER_VERIFY = "true" } -cwd = "examples" -command = "cargo" -args = ["make", "verify-flow"] +args = ["make", "ci-clean"] [tasks.clean-examples] -description = "Clean all example projects" cwd = "examples" command = "cargo" -args = ["make", "clean-all"] +args = ["make", "clean"] [env] RUSTFLAGS = "" diff --git a/examples/cargo-make/cargo-leptos-test.toml b/examples/cargo-make/cargo-leptos-test.toml index 3a741eda9d..280be10dae 100644 --- a/examples/cargo-make/cargo-leptos-test.toml +++ b/examples/cargo-make/cargo-leptos-test.toml @@ -1,5 +1,6 @@ -[tasks.test-e2e] -dependencies = ["setup-node", "cargo-leptos-e2e"] +[tasks.integration-test] +dependencies = ["cargo-leptos-e2e"] -[tasks.clean-all] -dependencies = ["clean-cargo", "clean-node_modules", "clean-playwright"] +[tasks.cargo-leptos-e2e] +command = "cargo" +args = ["leptos", "end-to-end"] diff --git a/examples/cargo-make/clean.toml b/examples/cargo-make/clean.toml new file mode 100644 index 0000000000..e3cf2e9146 --- /dev/null +++ b/examples/cargo-make/clean.toml @@ -0,0 +1,28 @@ +[tasks.clean] +dependencies = [ + "clean-cargo", + "clean-trunk", + "clean-node_modules", + "clean-playwright", +] + +[tasks.clean-cargo] +command = "cargo" +args = ["clean"] + +[tasks.clean-trunk] +command = "trunk" +args = ["clean"] + +[tasks.clean-node_modules] +script = ''' +project_dir=${PWD##*/} +if [ "$project_dir" != "todomvc" ]; then + find . -type d -name node_modules | xargs rm -rf +fi +''' + +[tasks.clean-playwright] +script = ''' +find . -name playwright-report -name playwright -name test-results | xargs rm -rf +''' diff --git a/examples/cargo-make/common.toml b/examples/cargo-make/common.toml deleted file mode 100644 index 341f984b33..0000000000 --- a/examples/cargo-make/common.toml +++ /dev/null @@ -1,20 +0,0 @@ -extend = [ - { path = "../cargo-make/lint.toml" }, - { path = "../cargo-make/node.toml" }, -] - -[tasks.clean-cargo] -command = "cargo" -args = ["clean"] - -[tasks.clean-all] -dependencies = ["clean-cargo"] - -[tasks.test-wasm] -env = { CARGO_MAKE_WASM_TEST_ARGS = "--headless --chrome" } -command = "cargo" -args = ["make", "wasm-pack-test"] - -[tasks.cargo-leptos-e2e] -command = "cargo" -args = ["leptos", "end-to-end"] diff --git a/examples/cargo-make/main.toml b/examples/cargo-make/main.toml index 64c00067d8..3456383d44 100644 --- a/examples/cargo-make/main.toml +++ b/examples/cargo-make/main.toml @@ -1,30 +1,32 @@ -extend = { path = "../cargo-make/common.toml" } +extend = [ + { path = "../cargo-make/clean.toml" }, + { path = "../cargo-make/lint.toml" }, + { path = "../cargo-make/node.toml" }, +] -[tasks.ci] -alias = "verify-flow" - -[tasks.verify-flow] -dependencies = ["pre-verify", "verify", "post-verify"] +# CI Stages -[tasks.verify] -dependencies = ["check-style", "test-unit-and-e2e"] +[tasks.ci] +dependencies = ["prepare", "lint", "build", "test-flow", "integration-test"] -[tasks.test-unit-and-e2e] -dependencies = ["test-flow", "test-e2e-flow"] +[tasks.ci-clean] +dependencies = ["ci", "clean"] -[tasks.pre-verify] +[tasks.prepare] +dependencies = ["setup-node"] -[tasks.post-verify] -dependencies = ["maybe-clean-all"] +[tasks.lint] +dependencies = ["check-style"] -[tasks.maybe-clean-all] -condition = { env_true = ["CLEAN_AFTER_VERIFY"] } +[tasks.integration-test] -[tasks.test-e2e-flow] -dependencies = ["pre-test-e2e", "test-e2e", "post-test-e2e"] +# ALIASES -[tasks.pre-test-e2e] +[tasks.verify-flow] +alias = "ci" -[tasks.test-e2e] +[tasks.t] +dependencies = ["test-flow"] -[tasks.post-test-e2e] +[tasks.it] +alias = "integration-test" diff --git a/examples/cargo-make/node.toml b/examples/cargo-make/node.toml index d6a12c357e..bd5c22c537 100644 --- a/examples/cargo-make/node.toml +++ b/examples/cargo-make/node.toml @@ -1,10 +1,3 @@ -[tasks.clean-node_modules] -description = "Delete all node_modules directories" -category = "Cleanup" -script = ''' -find . -type d -name node_modules | xargs rm -rf -''' - [tasks.setup-node] description = "Install node dependencies and playwright browsers" env = { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1" } diff --git a/examples/cargo-make/playwright-test.toml b/examples/cargo-make/playwright-test.toml index 694b2990ba..53458acf19 100644 --- a/examples/cargo-make/playwright-test.toml +++ b/examples/cargo-make/playwright-test.toml @@ -1,7 +1,4 @@ extend = [{ path = "../cargo-make/playwright.toml" }] -[tasks.test-e2e] -dependencies = ["setup-node", "test-playwright-autostart"] - -[tasks.clean-all] -dependencies = ["clean-cargo", "clean-node_modules", "clean-playwright"] +[tasks.integration-test] +dependencies = ["test-playwright-autostart"] diff --git a/examples/cargo-make/playwright.toml b/examples/cargo-make/playwright.toml index a030d8fa9a..c88fc540af 100644 --- a/examples/cargo-make/playwright.toml +++ b/examples/cargo-make/playwright.toml @@ -1,11 +1,3 @@ -[tasks.clean-playwright] -script = ''' -for pw_dir in $(find . -name playwright.config.ts | xargs dirname) -do - rm -rf $pw_dir/playwright-report pw_dir/playwright pw_dir/test-results -done -''' - [tasks.test-playwright-autostart] command = "npm" args = ["run", "e2e:auto-start"] diff --git a/examples/cargo-make/trunk_server.toml b/examples/cargo-make/trunk_server.toml index 09610e28ed..041a5f6048 100644 --- a/examples/cargo-make/trunk_server.toml +++ b/examples/cargo-make/trunk_server.toml @@ -2,13 +2,9 @@ command = "trunk" args = ["build"] -[tasks.clean-trunk] -command = "trunk" -args = ["clean"] - [tasks.start-trunk] command = "trunk" -args = ["serve", "--open"] +args = ["serve", "${@}"] [tasks.stop-trunk] script = ''' diff --git a/examples/cargo-make/wasm-test.toml b/examples/cargo-make/wasm-test.toml index 54a857499b..d01eab0538 100644 --- a/examples/cargo-make/wasm-test.toml +++ b/examples/cargo-make/wasm-test.toml @@ -5,5 +5,7 @@ condition = { env_true = ["RUN_CARGO_TEST"] } [tasks.post-test] dependencies = ["test-wasm"] -[tasks.clean-all] -dependencies = ["clean-cargo", "clean-trunk"] +[tasks.test-wasm] +env = { CARGO_MAKE_WASM_TEST_ARGS = "--headless --chrome" } +command = "cargo" +args = ["make", "wasm-pack-test"]