Skip to content

Commit

Permalink
add ci and fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sehz committed Jan 27, 2025
1 parent 580eec3 commit 19cabe6
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 20 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: main CI workflow for PR

permissions: read-all

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

on:
pull_request:
branches: [main]

env:
WASI_TARGET: wasm32-unknown-unknown
FLUVIO_URL: https://hub.infinyon.cloud/install/install.sh
FLUVIO_CHANNEL: stable



jobs:

check:
name: Check widgets
runs-on: ubuntu-latest


steps:
- name: Checkout Source Code
uses: actions/checkout@v4


- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable

- name: install wasm target
run: rustup target add ${{ env.WASI_TARGET }}


- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
timeout-minutes: 10

- name: Fmt check
run: make fmt

- name: Clippy check
run: make clippy




# To satisfy the merge queue check
done:
name: Done
needs:
- check
runs-on: ubuntu-latest
if: always()
steps:
- name: Dump needs context
env:
CONTEXT: ${{ toJson(needs) }}
run: |
echo -e "\033[33;1;4mDump context\033[0m"
echo -e "$CONTEXT\n"
- name: Report failure on cancellation
if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }}
run: exit 1
- name: Failing test and build
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Successful test and build
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
WASM_TARGET = wasm32-unknown-unknown

fmt:
cargo fmt -- --check

WS_PROXY = fluvio-ws-proxy
WEB = fluvio-web
COUNTER = fluvio-counter

clippy:
cargo clippy --all-features --tests -p $(WS_PROXY) -- -D warnings
cargo clippy --all-features --tests --target $(WASM_TARGET) -p $(WEB) -- -D warnings
cargo clippy --all-features --tests --target $(WASM_TARGET) -p $(COUNTER) -- -D warnings
3 changes: 1 addition & 2 deletions crates/fluvio-web/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ impl TcpDomainConnector for FluvioWebsocketConnector {
let mut url = Url::parse(&self.url).map_err(|err| {
IoError::other(format!(
"Failed to parse URL on connect. URL: {}. Error: {}",
self.url,
err.to_string()
self.url, err
))
})?;

Expand Down
2 changes: 1 addition & 1 deletion crates/fluvio-ws-proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ async fn main() -> anyhow::Result<()> {
fluvio_future::subscriber::init_tracer(None);

let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), WS_PORT);
let _ws = start_web_services(addr).await?;
start_web_services(addr).await?;
Ok(())
}
4 changes: 2 additions & 2 deletions crates/fluvio-ws-proxy/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use tracing::info;

pub(crate) async fn start_web_services(addr: SocketAddr) -> Result<()> {
info!(ip = %addr.ip(),port = addr.port(),"starting web server at");
HttpServer::new(move || App::new().route("/ws/", web::get().to(ws::register)))
HttpServer::new(move || App::new().route("/ws/", web::get().to(websocket::register)))
.bind(addr)?
.run()
.await
.map_err(|err| err.into())
}

mod ws {
mod websocket {
use actix_web::{
web::{Payload, Query},
Error, HttpRequest, HttpResponse,
Expand Down
8 changes: 7 additions & 1 deletion widgets/counter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ build:
trunk build --config release/Trunk.toml

serve:
trunk serve --config dev/Trunk.toml
trunk serve --config dev/Trunk.toml


RELEASE_TAG = v0.1.0

release:
gh release create $(RELEASE_TAG)
25 changes: 11 additions & 14 deletions widgets/counter/src/components/counter.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use std::time::Duration;
use fluvio_web::fluvio::FluvioBrowser;
use leptos::{component, IntoView};

use fluvio::{
consumer::{ConsumerConfigBuilder, ConsumerConfigExtBuilder},
Offset, TopicProducerConfig, TopicProducerConfigBuilder,
};
use leptos::*;
#[component]
pub fn Counter(client: FluvioBrowser, topic: String) -> impl IntoView {
use std::time::Duration;

use fluvio_web::{
fluvio::FluvioBrowser,
leptos_fluvio::{topic_consumer, topic_producer},
};
use fluvio::{consumer::ConsumerConfigExtBuilder, Offset, TopicProducerConfigBuilder};
use leptos::*;

use crate::components::count::Count;
use crate::components::increment_button::IncrementButton;
use fluvio_web::leptos_fluvio::{topic_consumer, topic_producer};

use crate::components::count::Count;
use crate::components::increment_button::IncrementButton;

#[component]
pub fn Counter(client: FluvioBrowser, topic: String) -> impl IntoView {
let fluvio = client.inner_clone();

let (state, set_state) = create_signal(0);
Expand Down

0 comments on commit 19cabe6

Please sign in to comment.