From 774366a639557781d090303244ab02cd14e8c18c Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Tue, 14 Jan 2025 04:45:19 -0800 Subject: [PATCH] fixed independent features (#1177) * run cargo-hack in ci * fix needs * now add sanity tests * fix path --- .github/workflows/loco-gen-ci.yml | 4 ++ .github/workflows/loco-gen-e2e.yml | 4 ++ .github/workflows/loco-rs-ci-sanity.yml | 68 +++++++++++++++++++++++++ .github/workflows/loco-rs-ci.yml | 22 +++++++- Cargo.toml | 3 +- 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/loco-rs-ci-sanity.yml diff --git a/.github/workflows/loco-gen-ci.yml b/.github/workflows/loco-gen-ci.yml index 3e8d01387..b170dedbb 100644 --- a/.github/workflows/loco-gen-ci.yml +++ b/.github/workflows/loco-gen-ci.yml @@ -4,7 +4,11 @@ on: push: branches: - master + paths: + - "loco-gen/**" pull_request: + paths: + - "loco-gen/**" env: RUST_TOOLCHAIN: stable diff --git a/.github/workflows/loco-gen-e2e.yml b/.github/workflows/loco-gen-e2e.yml index 0f25f13e3..223b784ab 100644 --- a/.github/workflows/loco-gen-e2e.yml +++ b/.github/workflows/loco-gen-e2e.yml @@ -4,7 +4,11 @@ on: push: branches: - master + paths: + - "loco-gen/**" pull_request: + paths: + - "loco-gen/**" env: RUST_TOOLCHAIN: stable diff --git a/.github/workflows/loco-rs-ci-sanity.yml b/.github/workflows/loco-rs-ci-sanity.yml new file mode 100644 index 000000000..80c3f8a58 --- /dev/null +++ b/.github/workflows/loco-rs-ci-sanity.yml @@ -0,0 +1,68 @@ +# To optimize CI runtime: +# A simpler "sanity check" workflow is introduced. +# This workflow only runs if changes in the PR do NOT include +# the `loco-gen` or `loco-new` paths. +# (When changes are made to `loco-gen` or `loco-new`, +# we run comprehensive tests to validate every generator command +# and template option.) + +# Purpose of the sanity check: +# It performs basic validation by comparing the local changes +# against the templates. +# If any breaking changes are detected in the templates, +# the sanity check will fail, signaling an issue. + +name: "[loco_rs:sanity]" + +on: + push: + branches: + - master + paths-ignore: + - "loco-gen/**" + - "loco-new/**" + pull_request: + paths-ignore: + - "loco-gen/**" + - "loco-new/**" + +env: + RUST_TOOLCHAIN: stable + TOOLCHAIN_PROFILE: minimal + +jobs: + sanity: + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install seaorm cli + run: cargo install sea-orm-cli + + - run: cargo install --path loco-new + + - run: | + loco new -n myappdb --db sqlite --bg async --assets serverside -a + cd myappdb + cargo check + env: + LOCO_DEV_MODE_PATH: ${{ github.workspace }} + + - run: | + loco new -n myappnodb --db none --bg none --assets none -a + cd myappdb + cargo check + env: + LOCO_DEV_MODE_PATH: ${{ github.workspace }} + + \ No newline at end of file diff --git a/.github/workflows/loco-rs-ci.yml b/.github/workflows/loco-rs-ci.yml index c055fe22b..770289934 100644 --- a/.github/workflows/loco-rs-ci.yml +++ b/.github/workflows/loco-rs-ci.yml @@ -37,10 +37,30 @@ jobs: command: clippy args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms - test: + check: needs: [style] runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ env.RUST_TOOLCHAIN }} + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@v2 + with: + tool: cargo-hack + - run: cargo hack check --each-feature + + test: + needs: [check, style] + runs-on: ubuntu-latest + permissions: contents: read diff --git a/Cargo.toml b/Cargo.toml index c264918cf..299e6ee91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -102,7 +102,7 @@ lettre = { version = "0.11.4", default-features = false, features = [ include_dir = "0.7.3" thiserror = { workspace = true } tracing = { workspace = true } -tracing-subscriber = { version = "0.3.16", features = ["env-filter"] } +tracing-subscriber = { version = "0.3.16", features = ["env-filter", "json"] } tracing-appender = "0.2.3" duct = { version = "0.13.6" } @@ -146,6 +146,7 @@ english-to-cron = { version = "0.1.2" } # bg_sqlt: sqlite workers # bg_pg: postgres workers sqlx = { version = "0.8.2", default-features = false, features = [ + "json", "postgres", "chrono", "sqlite",