From 7902e7edb7237b1340bef351a86da8c32c02a4df Mon Sep 17 00:00:00 2001 From: Joseph Cruz Date: Fri, 14 Jul 2023 14:37:17 -0400 Subject: [PATCH] ci: speed up verification (#1347) * build: introduce ci task * refactor(ci): rename cargo make task runner * ci: add ci workflow * ci: remove redundant workflows --- .github/workflows/check-examples.yml | 2 +- .github/workflows/check.yml | 46 ------------------- .github/workflows/ci.yml | 38 +++++++++++++++ .github/workflows/fmt.yml | 34 -------------- ...ample-task.yml => run-cargo-make-task.yml} | 8 ++-- .github/workflows/test.yml | 46 ------------------- .github/workflows/verify-all-examples.yml | 2 +- .github/workflows/verify-changed-examples.yml | 2 +- cargo-make/check.toml | 7 +++ cargo-make/lint.toml | 9 ++++ cargo-make/main.toml | 24 ++++------ cargo-make/test.toml | 7 +++ integrations/actix/Makefile.toml | 3 ++ integrations/axum/Makefile.toml | 3 ++ integrations/utils/Makefile.toml | 3 ++ integrations/viz/Makefile.toml | 3 ++ .../server_fn_macro_default/Makefile.toml | 3 ++ 17 files changed, 93 insertions(+), 147 deletions(-) delete mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/fmt.yml rename .github/workflows/{run-example-task.yml => run-cargo-make-task.yml} (95%) delete mode 100644 .github/workflows/test.yml create mode 100644 cargo-make/check.toml create mode 100644 cargo-make/lint.toml create mode 100644 cargo-make/test.toml diff --git a/.github/workflows/check-examples.yml b/.github/workflows/check-examples.yml index fcb74c88a4..52dec6234c 100644 --- a/.github/workflows/check-examples.yml +++ b/.github/workflows/check-examples.yml @@ -40,7 +40,7 @@ jobs: strategy: matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} fail-fast: false - uses: ./.github/workflows/run-example-task.yml + uses: ./.github/workflows/run-cargo-make-task.yml with: directory: ${{ matrix.directory }} cargo_make_task: "check" diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index a32de1f69c..0000000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Check - -on: - push: - branches: [main] - pull_request: - branches: [main] - -env: - CARGO_TERM_COLOR: always - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse - -jobs: - test: - name: Run `cargo check` ${{ matrix.os }} (using rustc ${{ matrix.rust }}) - runs-on: ${{ matrix.os }} - strategy: - matrix: - rust: - - nightly - os: - - ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - override: true - components: rustfmt - - - name: Add wasm32-unknown-unknown - run: rustup target add wasm32-unknown-unknown - - - name: Setup cargo-make - uses: davidB/rust-cargo-make@v1 - - - name: Cargo generate-lockfile - run: cargo generate-lockfile - - - uses: Swatinem/rust-cache@v2 - - - name: Run cargo check on all libraries - run: cargo make --profile=github-actions check diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..e6660aa38d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + matrix-job: + name: CI + strategy: + matrix: + directory: + [ + integrations/actix, + integrations/axum, + integrations/viz, + integrations/utils, + leptos, + leptos_config, + leptos_dom, + leptos_hot_reload, + leptos_macro, + leptos_reactive, + leptos_server, + meta, + router, + server_fn, + server_fn/server_fn_macro_default, + server_fn_macro, + ] + uses: ./.github/workflows/run-cargo-make-task.yml + with: + directory: ${{ matrix.directory }} + cargo_make_task: "ci" diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml deleted file mode 100644 index fe798324e3..0000000000 --- a/.github/workflows/fmt.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Format - -on: - push: - branches: [main] - pull_request: - branches: [main] - -env: - CARGO_TERM_COLOR: always - -jobs: - test: - name: Run rustfmt - runs-on: ${{ matrix.os }} - strategy: - matrix: - rust: - - nightly - os: - - ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - override: true - components: rustfmt - - - name: Run Rustfmt - run: cargo fmt -- --check diff --git a/.github/workflows/run-example-task.yml b/.github/workflows/run-cargo-make-task.yml similarity index 95% rename from .github/workflows/run-example-task.yml rename to .github/workflows/run-cargo-make-task.yml index eccb73fad6..a4db756132 100644 --- a/.github/workflows/run-example-task.yml +++ b/.github/workflows/run-cargo-make-task.yml @@ -1,4 +1,4 @@ -name: Run Example Task +name: Run Task on: workflow_call: @@ -27,9 +27,9 @@ jobs: steps: # Setup environment - name: Install playwright browser dependencies - run: | + run: | sudo apt-get update - sudo apt-get install libegl1 libvpx7 libevent-2.1-7 libopus0 libopengl0 libwoff1 libharfbuzz-icu0 libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0 libhyphen0 libmanette-0.2-0 libgles2 gstreamer1.0-libav + sudo apt-get install libegl1 libvpx7 libevent-2.1-7 libopus0 libopengl0 libwoff1 libharfbuzz-icu0 libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0 libhyphen0 libmanette-0.2-0 libgles2 gstreamer1.0-libav - uses: actions/checkout@v3 @@ -84,7 +84,7 @@ jobs: restore-keys: | ${{ runner.os }}-pnpm-store- - # Verify project + # Run Cargo Make Task - name: ${{ inputs.cargo_make_task }} run: | if [ "${{ inputs.directory }}" = "INTERNAL" ]; then diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index d0570f776e..0000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Test - -on: - push: - branches: [main] - pull_request: - branches: [main] - -env: - CARGO_TERM_COLOR: always - CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse - -jobs: - test: - name: Run tests ${{ matrix.os }} (using rustc ${{ matrix.rust }}) - runs-on: ${{ matrix.os }} - strategy: - matrix: - rust: - - nightly - os: - - ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - override: true - components: rustfmt - - - name: Add wasm32-unknown-unknown - run: rustup target add wasm32-unknown-unknown - - - name: Setup cargo-make - uses: davidB/rust-cargo-make@v1 - - - name: Cargo generate-lockfile - run: cargo generate-lockfile - - - uses: Swatinem/rust-cache@v2 - - - name: Run tests with all features - run: cargo make --profile=github-actions test diff --git a/.github/workflows/verify-all-examples.yml b/.github/workflows/verify-all-examples.yml index dd7a31ccc9..9b79485e30 100644 --- a/.github/workflows/verify-all-examples.yml +++ b/.github/workflows/verify-all-examples.yml @@ -41,7 +41,7 @@ jobs: strategy: matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} fail-fast: false - uses: ./.github/workflows/run-example-task.yml + uses: ./.github/workflows/run-cargo-make-task.yml with: directory: ${{ matrix.directory }} cargo_make_task: "verify-flow" diff --git a/.github/workflows/verify-changed-examples.yml b/.github/workflows/verify-changed-examples.yml index c4fa05f6df..8a369eecd8 100644 --- a/.github/workflows/verify-changed-examples.yml +++ b/.github/workflows/verify-changed-examples.yml @@ -65,7 +65,7 @@ jobs: strategy: matrix: ${{ fromJSON(needs.setup.outputs.matrix) }} fail-fast: false - uses: ./.github/workflows/run-example-task.yml + uses: ./.github/workflows/run-cargo-make-task.yml with: directory: ${{ matrix.directory }} cargo_make_task: "verify-flow" diff --git a/cargo-make/check.toml b/cargo-make/check.toml new file mode 100644 index 0000000000..1774b1c2cb --- /dev/null +++ b/cargo-make/check.toml @@ -0,0 +1,7 @@ +[tasks.check] +alias = "check-all" + +[tasks.check-all] +command = "cargo" +args = ["+nightly", "check-all-features"] +install_crate = "cargo-all-features" diff --git a/cargo-make/lint.toml b/cargo-make/lint.toml new file mode 100644 index 0000000000..d3a0b49e6e --- /dev/null +++ b/cargo-make/lint.toml @@ -0,0 +1,9 @@ +[tasks.pre-clippy] +env = { CARGO_MAKE_CLIPPY_ARGS = "--all-targets --all-features -- -D warnings" } + +[tasks.check-style] +dependencies = ["check-format-flow", "clippy-flow"] + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../" } +args = ["fmt", "--", "--check", "--config-path", "${LEPTOS_PROJECT_DIRECTORY}"] diff --git a/cargo-make/main.toml b/cargo-make/main.toml index 9f9f91c5a2..6440c236c7 100644 --- a/cargo-make/main.toml +++ b/cargo-make/main.toml @@ -1,3 +1,9 @@ +extend = [ + { path = "./check.toml" }, + { path = "./lint.toml" }, + { path = "./test.toml" }, +] + [env] RUSTFLAGS = "" LEPTOS_OUTPUT_NAME = "ci" # allows examples to check/build without cargo-leptos @@ -5,18 +11,8 @@ LEPTOS_OUTPUT_NAME = "ci" # allows examples to check/build without cargo-leptos [env.github-actions] RUSTFLAGS = "-D warnings" -[tasks.check] -alias = "check-all" - -[tasks.check-all] -command = "cargo" -args = ["+nightly", "check-all-features"] -install_crate = "cargo-all-features" - -[tasks.test] -alias = "test-all" +[tasks.ci] +dependencies = ["lint", "test"] -[tasks.test-all] -command = "cargo" -args = ["+nightly", "test-all-features"] -install_crate = "cargo-all-features" +[tasks.lint] +dependencies = ["check-format-flow"] diff --git a/cargo-make/test.toml b/cargo-make/test.toml new file mode 100644 index 0000000000..e45be9fce1 --- /dev/null +++ b/cargo-make/test.toml @@ -0,0 +1,7 @@ +[tasks.test] +alias = "test-all" + +[tasks.test-all] +command = "cargo" +args = ["+nightly", "test-all-features"] +install_crate = "cargo-all-features" diff --git a/integrations/actix/Makefile.toml b/integrations/actix/Makefile.toml index 84f458ce36..4ed6229141 100644 --- a/integrations/actix/Makefile.toml +++ b/integrations/actix/Makefile.toml @@ -1 +1,4 @@ extend = { path = "../../cargo-make/main.toml" } + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../../" } diff --git a/integrations/axum/Makefile.toml b/integrations/axum/Makefile.toml index 84f458ce36..4ed6229141 100644 --- a/integrations/axum/Makefile.toml +++ b/integrations/axum/Makefile.toml @@ -1 +1,4 @@ extend = { path = "../../cargo-make/main.toml" } + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../../" } diff --git a/integrations/utils/Makefile.toml b/integrations/utils/Makefile.toml index 84f458ce36..4ed6229141 100644 --- a/integrations/utils/Makefile.toml +++ b/integrations/utils/Makefile.toml @@ -1 +1,4 @@ extend = { path = "../../cargo-make/main.toml" } + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../../" } diff --git a/integrations/viz/Makefile.toml b/integrations/viz/Makefile.toml index 84f458ce36..4ed6229141 100644 --- a/integrations/viz/Makefile.toml +++ b/integrations/viz/Makefile.toml @@ -1 +1,4 @@ extend = { path = "../../cargo-make/main.toml" } + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../../" } diff --git a/server_fn/server_fn_macro_default/Makefile.toml b/server_fn/server_fn_macro_default/Makefile.toml index 84f458ce36..4ed6229141 100644 --- a/server_fn/server_fn_macro_default/Makefile.toml +++ b/server_fn/server_fn_macro_default/Makefile.toml @@ -1 +1,4 @@ extend = { path = "../../cargo-make/main.toml" } + +[tasks.check-format] +env = { LEPTOS_PROJECT_DIRECTORY = "../../" }