Skip to content

Commit

Permalink
Create workspace that includes the examples
Browse files Browse the repository at this point in the history
This allows testing the examples directly using the --workspace cli arg
instead of running separate ci jobs for each example
  • Loading branch information
spencewenski committed Mar 29, 2024
1 parent f66b740 commit 1f3a9e3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 43 deletions.
16 changes: 8 additions & 8 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

# Checks that don't depend on which features are enabled
echo "### cargo fmt -- --check ###"
cargo fmt -- --check
cargo fmt --workspace -- --check
echo "### cargo clippy --no-deps -- -D warnings ###"
cargo clippy --no-deps -- -D warnings
cargo clippy --workspace -- -D warnings

# Without default features
echo "### cargo test --no-default-features ###"
cargo test --no-default-features
cargo test --no-default-features --workspace
echo "### cargo check --no-default-features ###"
cargo check --no-default-features
cargo check --no-default-features --workspace

# With default features
echo "### cargo test ###"
cargo test
cargo test --workspace
echo "### cargo check ###"
cargo check
cargo check --workspace

# With all features
echo "### cargo test --all-features ###"
cargo test --all-features
cargo test --all-features --workspace
echo "### cargo check --all-features ###"
cargo check --all-features
cargo check --all-features --workspace
42 changes: 10 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Test
run: cargo test --no-fail-fast --no-default-features
run: cargo test --no-fail-fast --no-default-features --workspace
- name: Check
run: cargo check --no-default-features
run: cargo check --no-default-features --workspace

roadster_default_features:
name: Default features
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test
run: cargo test --no-fail-fast
run: cargo test --no-fail-fast --workspace
- name: Check
run: cargo check
run: cargo check --workspace

roadster_all_features:
name: All features
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test
run: cargo test --no-fail-fast --all-features
run: cargo test --no-fail-fast --all-features --workspace
- name: Check
run: cargo check --all-features
run: cargo check --all-features --workspace

roadster_with_all_feature_combinations:
name: Feature combos
Expand All @@ -56,44 +56,22 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Test
run: cargo test --no-fail-fast --no-default-features --features ${{matrix.features}}
run: cargo test --no-fail-fast --no-default-features --features ${{matrix.features}} --workspace
- name: Check
run: cargo check --no-default-features --features ${{matrix.features}}
run: cargo check --no-default-features --features ${{matrix.features}} --workspace

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clippy
run: cargo clippy --no-deps -- -D warnings
run: cargo clippy --workspace --no-deps -- -D warnings

check_formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Formatting
run: cargo fmt -- --check

examples:
name: Examples
runs-on: ubuntu-latest
strategy:
matrix:
# Todo: Is there a way to generate this list automatically?
example:
- minimal
defaults:
run:
working-directory: ./examples/${{matrix.example}}
steps:
- uses: actions/checkout@v4
- name: Test
run: cargo test --no-fail-fast
- name: Check
run: cargo check
- name: Clippy
run: cargo clippy --no-deps -- -D warnings
- name: Formatting
run: cargo fmt -- --check
run: cargo fmt --workspace -- --check
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
members = [".", "examples/*"]

[package]
name = "roadster"
version = "0.1.0"
Expand Down
3 changes: 0 additions & 3 deletions examples/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace]
members = [".", "entity", "migration"]

[dependencies]
roadster = { version = "0.1", path = "../.." }
tokio = { version = "1.35.1", features = ["full", "macros"] }
Expand Down

0 comments on commit 1f3a9e3

Please sign in to comment.