Skip to content

Commit

Permalink
fix: install proto before build
Browse files Browse the repository at this point in the history
  • Loading branch information
thuan2172001 committed Mar 10, 2024
1 parent 9722980 commit fdaf62b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@ on:
- main

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install protoc and grpcio-tools
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
cargo install grpcio-compiler
cargo-check:
name: Cargo check
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -26,6 +39,7 @@ jobs:
fmt-check:
name: Rust fmt
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand All @@ -42,6 +56,7 @@ jobs:
test-and-coverage:
name: Test and Coverage
runs-on: ubuntu-latest
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -53,8 +68,7 @@ jobs:
cargo install cargo-tarpaulin
- name: Run tests with coverage
run: |
cargo tarpaulin --all-features --verbose
run: cargo tarpaulin --all-features --verbose

release-github-artifact:
name: Release Packaging
Expand Down Expand Up @@ -117,9 +131,8 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push docker image
run: |
run: |
docker build . --tag ${{ env.DOCKER_HUB_REPOSITORY }}:latest
docker push ${{ env.DOCKER_HUB_REPOSITORY }}:latest
13 changes: 13 additions & 0 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ on:
- cron: '27 4 * * 6'

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install protoc and grpcio-tools
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
cargo install grpcio-compiler
rust-clippy-analyze:
name: Run rust-clippy analyzing
runs-on: ubuntu-latest
needs: setup
permissions:
contents: read
security-events: write
Expand Down
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

RUN apt-get update && \
apt-get install -y protobuf-compiler

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
Expand Down
27 changes: 18 additions & 9 deletions src/grpc/src/grpc_server/gpt_answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,25 @@ impl GptAnswerService for GptAnswerServer {
}

pub async fn init_gpt_answer_server() {
let addr: std::net::SocketAddr = "http://0.0.0.0:50051".parse().unwrap();
println!("GPT Answer server config at {}", addr);
let result = "http://0.0.0.0:50051".parse().map_err(|err| {
println!("Error: {:?}", err);
});

let gpt_answer_server = GptAnswerServer::default();
if result.is_ok() {
let addr = result.unwrap();

Server::builder()
.add_service(GptAnswerServiceServer::new(gpt_answer_server))
.serve(addr)
.await
.unwrap();
println!("GPT Answer server config at {}", addr);

println!("GPT Answer server started at {}", addr);
let gpt_answer_server = GptAnswerServer::default();

Server::builder()
.add_service(GptAnswerServiceServer::new(gpt_answer_server))
.serve(addr)
.await
.unwrap();

println!("GPT Answer server started at {}", addr);
} else {
println!("GPT Answer server failed to start");
}
}

0 comments on commit fdaf62b

Please sign in to comment.