From d37fbbf486dc44336c87acd59cf8b6feff57b330 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Wed, 8 Nov 2023 21:12:00 +0800 Subject: [PATCH] ci: vendor protoc (#152) * ci: vendor protoc * ci: remove protoc compiler install --- .github/workflows/client_api_check.yml | 3 -- .github/workflows/docker.yml | 3 -- .github/workflows/rustlint.yml | 3 -- Cargo.lock | 51 ++++++++++++++++++++++++++ Dockerfile | 3 -- libs/realtime-entity/Cargo.toml | 1 + libs/realtime-entity/build.rs | 6 +++ 7 files changed, 58 insertions(+), 12 deletions(-) diff --git a/.github/workflows/client_api_check.yml b/.github/workflows/client_api_check.yml index 80623f82..12eef47c 100644 --- a/.github/workflows/client_api_check.yml +++ b/.github/workflows/client_api_check.yml @@ -19,9 +19,6 @@ jobs: workspaces: | AppFlowy-Cloud - - name: Install protobuf compiler - run: sudo apt-get install -y protobuf-compiler - - name: Check working-directory: ./libs/client-api run: cargo build diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3167be89..6b04ecae 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -41,9 +41,6 @@ jobs: run: | docker compose up -d - - name: Install protobuf compiler - run: sudo apt-get install -y protobuf-compiler - - name: Run tests run: | cargo install sqlx-cli --version=${{ env.SQLX_VERSION }} --features ${{ env.SQLX_FEATURES }} --no-default-features --locked diff --git a/.github/workflows/rustlint.yml b/.github/workflows/rustlint.yml index ff355f77..97d15b93 100644 --- a/.github/workflows/rustlint.yml +++ b/.github/workflows/rustlint.yml @@ -28,9 +28,6 @@ jobs: - name: Copy and rename dev.env to .env run: cp dev.env .env - - name: Install protobuf compiler - run: sudo apt-get install -y protobuf-compiler - - name: Code Gen working-directory: ./build run: ./code_gen.sh diff --git a/Cargo.lock b/Cargo.lock index 90030951..9ac52681 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3312,6 +3312,56 @@ dependencies = [ "prost", ] +[[package]] +name = "protoc-bin-vendored" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "005ca8623e5633e298ad1f917d8be0a44bcf406bf3cde3b80e63003e49a3f27d" +dependencies = [ + "protoc-bin-vendored-linux-aarch_64", + "protoc-bin-vendored-linux-ppcle_64", + "protoc-bin-vendored-linux-x86_32", + "protoc-bin-vendored-linux-x86_64", + "protoc-bin-vendored-macos-x86_64", + "protoc-bin-vendored-win32", +] + +[[package]] +name = "protoc-bin-vendored-linux-aarch_64" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb9fc9cce84c8694b6ea01cc6296617b288b703719b725b8c9c65f7c5874435" + +[[package]] +name = "protoc-bin-vendored-linux-ppcle_64" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d2a07dcf7173a04d49974930ccbfb7fd4d74df30ecfc8762cf2f895a094516" + +[[package]] +name = "protoc-bin-vendored-linux-x86_32" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54fef0b04fcacba64d1d80eed74a20356d96847da8497a59b0a0a436c9165b0" + +[[package]] +name = "protoc-bin-vendored-linux-x86_64" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8782f2ce7d43a9a5c74ea4936f001e9e8442205c244f7a3d4286bd4c37bc924" + +[[package]] +name = "protoc-bin-vendored-macos-x86_64" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5de656c7ee83f08e0ae5b81792ccfdc1d04e7876b1d9a38e6876a9e09e02537" + +[[package]] +name = "protoc-bin-vendored-win32" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9653c3ed92974e34c5a6e0a510864dab979760481714c172e0a34e437cb98804" + [[package]] name = "psl-types" version = "2.0.11" @@ -3531,6 +3581,7 @@ dependencies = [ "collab-entity", "prost", "prost-build", + "protoc-bin-vendored", "serde", "serde_json", "tokio-tungstenite", diff --git a/Dockerfile b/Dockerfile index 9ef9e03f..c8673dad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,6 @@ RUN cargo chef cook --release --recipe-path recipe.json COPY . . ENV SQLX_OFFLINE true -# install protobuf -RUN apt-get update -y && apt-get install -y protobuf-compiler - # Build the project RUN cargo build --release --bin appflowy_cloud diff --git a/libs/realtime-entity/Cargo.toml b/libs/realtime-entity/Cargo.toml index 54b22d67..df8885b4 100644 --- a/libs/realtime-entity/Cargo.toml +++ b/libs/realtime-entity/Cargo.toml @@ -22,4 +22,5 @@ actix_message = ["actix"] tungstenite = ["tokio-tungstenite"] [build-dependencies] +protoc-bin-vendored = { version = "3.0" } prost-build = "0.12.1" diff --git a/libs/realtime-entity/build.rs b/libs/realtime-entity/build.rs index a25c406f..4b11e89e 100644 --- a/libs/realtime-entity/build.rs +++ b/libs/realtime-entity/build.rs @@ -1,6 +1,12 @@ use std::process::Command; fn main() -> Result<(), Box> { + let protoc_path = protoc_bin_vendored::protoc_bin_path().expect("protoc bin path"); + let protoc_path_str = protoc_path.to_str().expect("protoc path to str"); + + // Set the `PROTOC` environment variable to the path of the `protoc` binary. + std::env::set_var("PROTOC", protoc_path_str); + prost_build::Config::new() .out_dir("src/") .compile_protos(&["proto/realtime.proto"], &["proto/"])?;