Skip to content

Commit

Permalink
feat: add message feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilerd committed Jan 26, 2025
1 parent 749d9c7 commit 13e27fd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,29 @@ jobs:
- name: Run tests
run: cargo test --package gotcha --features "${{ matrix.features }}"

define-cf-matrix:
runs-on: ubuntu-latest

outputs:
features: ${{ steps.features.outputs.features }}

steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Define Features
id: features
run: |
python3 test-feature-matrix.py echo-cf-worker >> "$GITHUB_OUTPUT"
gotcha-cf-worker-test:
runs-on: ubuntu-latest
needs: define-matrix
needs: define-cf-matrix
strategy:
matrix:
features: ${{ fromJSON(needs.define-matrix.outputs.features) }}
features: ${{ fromJSON(needs.define-cf-matrix.outputs.features) }}
steps:
- uses: actions/checkout@v3

Expand All @@ -64,7 +81,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Run tests
run: cargo test --package gotcha --no-default-features --features "cloudflare_worker ${{ matrix.features }}"
run: cargo test --package gotcha --no-default-features --features "${{ matrix.features }}"

test:
name: Test
Expand Down
1 change: 1 addition & 0 deletions gotcha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ openapi = ["dep:oas"]
cors = ["dep:tower-http"]
static_files = ["dep:tower-http", "tower-http/fs"]
task = ["dep:cron", "tokio/time"]
message = ["tokio/rt"]
cloudflare_worker = ["dep:worker"]


Expand Down
13 changes: 11 additions & 2 deletions gotcha/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,18 @@ use tracing_subscriber::{fmt, EnvFilter};
pub use {axum, inventory, tracing};

pub use crate::config::GotchaConfigLoader;

#[cfg(feature = "message")]
pub mod message;
#[cfg(feature = "message")]
pub use crate::message::{Message, Messager};

#[cfg(feature = "openapi")]
pub use crate::openapi::Operable;
#[cfg(feature = "openapi")]
pub use oas;
mod config;
pub mod message;

#[cfg(feature = "openapi")]
pub mod openapi;
pub mod router;
Expand Down Expand Up @@ -222,7 +227,11 @@ pub trait GotchaApp: Sized + Send + Sync {

let router = self.build_router(context.clone()).await?;

Ok(GotchaRouter { operations: Default::default(), router })
Ok(GotchaRouter {
#[cfg(feature = "openapi")]
operations: Default::default(),
router
})
}
}

Expand Down
4 changes: 4 additions & 0 deletions test-feature-matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def generate_combinations(features):
if len(sys.argv) > 1 and sys.argv[1] == "echo":
combinations = generate_combinations(features)
print(f"features={json.dumps(combinations)}")
elif len(sys.argv) > 1 and sys.argv[1] == "echo-cf-worker":
features = ["cors", "openapi", "cloudflare_worker"]
combinations = generate_combinations(features)
print(f"features={json.dumps(combinations)}")
else:
# Get combinations
combinations = generate_combinations(features)
Expand Down

0 comments on commit 13e27fd

Please sign in to comment.