From 28dcf1aef020587f2c979a533177b8d21dea3106 Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Tue, 31 May 2022 10:46:14 +0800 Subject: [PATCH] build: config github action (#1) * build: config github action Signed-off-by: Ruihang Xia * fix comment syntax Signed-off-by: Ruihang Xia * comment out other stages Signed-off-by: Ruihang Xia * setup build env Signed-off-by: Ruihang Xia * ignore vergen error Signed-off-by: Ruihang Xia * enable cache steps Signed-off-by: Ruihang Xia * set default vergen env Signed-off-by: Ruihang Xia * add more jobs Signed-off-by: Ruihang Xia * fix trigger Signed-off-by: Ruihang Xia * fix build env Signed-off-by: Ruihang Xia * submodule add parquet test data Signed-off-by: Ruihang Xia * enable dep cache Signed-off-by: Ruihang Xia * replace tab with white space Signed-off-by: Ruihang Xia * ignore document change Signed-off-by: Ruihang Xia --- .github/workflows/rust.yml | 180 +++++++++++++++++++++++++++++++++++++ .gitmodules | 3 + Makefile | 4 +- build.rs | 2 +- components/parquet-testing | 1 + src/bin/ceresdb-server.rs | 8 +- 6 files changed, 191 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/rust.yml create mode 100644 .gitmodules create mode 160000 components/parquet-testing diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000000..e932e21ac4 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,180 @@ +# Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0. + +name: Rust + +on: + push: + branches: + - main + paths-ignore: + - 'docs/**' + - 'etc/**' + - '**.md' + pull_request: + branches: + - main + paths-ignore: + - 'docs/**' + - 'etc/**' + - '**.md' + +env: + CARGO_TERM_COLOR: always + +jobs: + # build the library, a compilation step used by multiple steps below + linux-build-lib: + name: Build Libraries with Rust ${{ matrix.rust }} + runs-on: ubuntu-latest + strategy: + matrix: + rust: [1.59.0] + container: + image: rust:${{ matrix.rust }}-slim-bullseye + env: + # Disable full debug symbol generation to speed up CI build and keep memory down + # "1" means line tables only, which is useful for panic tracebacks. + RUSTFLAGS: "-C debuginfo=1" + steps: + - uses: actions/checkout@v3 + # with: + # submodules: true + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: /github/home/.cargo + key: cargo-cache- + - name: Cache Rust dependencies + uses: actions/cache@v3 + with: + path: /github/home/target + key: ${{ runner.os }}-target-cache-${{ matrix.rust }}- + - name: Cache Build Dependencies + uses: actions/cache@v3 + with: + path: /github/home + key: ${{ runner.os }}-toolchain-cache- + - name: Setup Build Environment + run: | + apt update + apt install --yes gcc g++ libssl-dev pkg-config cmake + rm -rf /var/lib/apt/lists/* + - name: Build workspace in debug mode + run: | + make build-ut + env: + CARGO_HOME: "/github/home/.cargo" + CARGO_TARGET_DIR: "/github/home/target/debug" + + style-check: + name: Libraries Style Check + needs: [linux-build-lib] + runs-on: ubuntu-latest + strategy: + matrix: + rust: [1.59.0] + container: + image: rust:${{ matrix.rust }}-slim-bullseye + steps: + - uses: actions/checkout@v3 + - name: Setup Build Environment + run: | + apt update + apt install --yes cmake + rm -rf /var/lib/apt/lists/* + - name: Setup Toolchain + run: | + rustup component add rustfmt + - name: Run + run: | + make fmt + env: + CARGO_HOME: "/github/home/.cargo" + CARGO_TARGET_DIR: "/github/home/target/debug" + + clippy: + name: Clippy + needs: [linux-build-lib] + runs-on: ubuntu-latest + strategy: + matrix: + rust: [1.59.0] + container: + image: rust:${{ matrix.rust }}-slim-bullseye + env: + RUSTFLAGS: "-C debuginfo=1" + steps: + - uses: actions/checkout@v3 + # with: + # submodules: true + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: /github/home/.cargo + key: cargo-cache- + - name: Cache Rust dependencies + uses: actions/cache@v3 + with: + path: /github/home/target + key: ${{ runner.os }}-target-cache-${{ matrix.rust }}- + - name: Cache Build Dependencies + uses: actions/cache@v3 + with: + path: /github/home + key: ${{ runner.os }}-toolchain-cache- + - name: Setup Build Environment + run: | + apt update + apt install --yes gcc g++ libssl-dev pkg-config cmake + rm -rf /var/lib/apt/lists/* + - name: Install Clippy + run: | + rustup component add clippy + - name: Run Clippy + run: | + make clippy + env: + CARGO_HOME: "/github/home/.cargo" + CARGO_TARGET_DIR: "/github/home/target/debug" + + linux-test: + name: Test Workspace with Rust ${{ matrix.rust }} + needs: [linux-build-lib] + runs-on: ubuntu-latest + strategy: + matrix: + rust: [1.59.0] + container: + image: rust:${{ matrix.rust }}-slim-bullseye + env: + RUSTFLAGS: "-C debuginfo=1" + steps: + - uses: actions/checkout@v3 + # with: + # submodule: true + - name: Cache Cargo + uses: actions/cache@v3 + with: + path: /github/home/.cargo + key: cargo-cache- + - name: Cache Rust dependencies + uses: actions/cache@v3 + with: + path: /github/home/target + key: ${{ runner.os }}-target-cache-${{ matrix.rust }}- + - name: Cache Build Dependencies + uses: actions/cache@v3 + with: + path: /github/home + key: ${{ runner.os }}-toolchain-cache- + - name: Setup Build Environment + run: | + apt update + apt install --yes gcc g++ libssl-dev pkg-config cmake + - name: Run Tests + run: | + make test-ut + env: + CARGO_HOME: "/github/home/.cargo" + CARGO_TARGET_DIR: "/github/home/target/debug" + RUST_BACKTRACE: "1" \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..96ef7ba5c0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "components/parquet-testing"] + path = components/parquet-testing + url = https://github.com/apache/parquet-testing.git diff --git a/Makefile b/Makefile index dfc71ea25a..d99e9c3930 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,13 @@ build-ut: echo $(CARGO_INCREMENTAL) echo $(RUSTFLAGS) echo $(RUSTDOCFLAGS) - cd $(DIR); cargo build -j 4 --workspace + cd $(DIR); cargo build --workspace test-ut: echo $(CARGO_INCREMENTAL) echo $(RUSTFLAGS) echo $(RUSTDOCFLAGS) - cd $(DIR); cargo test -j 4 --workspace -- -Z unstable-options --format json | tee results.json; \ + cd $(DIR); cargo test --workspace -- -Z unstable-options --format json | tee results.json; \ cat results.json | cargo2junit > ${WORKSPACE}/testresult/TEST-all.xml fmt: diff --git a/build.rs b/build.rs index ce2a0fb668..30efa28554 100644 --- a/build.rs +++ b/build.rs @@ -22,5 +22,5 @@ fn main() { } } - vergen(config).expect("Vergen failed to generate config"); + let _ = vergen(config); } diff --git a/components/parquet-testing b/components/parquet-testing new file mode 160000 index 0000000000..7175a47133 --- /dev/null +++ b/components/parquet-testing @@ -0,0 +1 @@ +Subproject commit 7175a471339704c7645af0fe66c68305e2e6759c diff --git a/src/bin/ceresdb-server.rs b/src/bin/ceresdb-server.rs index 8c6bba31ad..dd44fc78d2 100644 --- a/src/bin/ceresdb-server.rs +++ b/src/bin/ceresdb-server.rs @@ -20,10 +20,10 @@ const CLUSTER_NAME: &str = "CLUSTER_NAME"; const ENABLE_META: &str = "ENABLE_META"; fn fetch_version() -> String { - let build_version = env!("VERGEN_BUILD_SEMVER"); - let git_branch = env!("VERGEN_GIT_BRANCH"); - let git_commit_id = env!("VERGEN_GIT_SHA_SHORT"); - let build_time = env!("VERGEN_BUILD_TIMESTAMP"); + let build_version = option_env!("VERGEN_BUILD_SEMVER").unwrap_or("NONE"); + let git_branch = option_env!("VERGEN_GIT_BRANCH").unwrap_or("NONE"); + let git_commit_id = option_env!("VERGEN_GIT_SHA_SHORT").unwrap_or("NONE"); + let build_time = option_env!("VERGEN_BUILD_TIMESTAMP").unwrap_or("NONE"); format!( "\nCeresDB Version: {}\nGit branch: {}\nGit commit: {}\nBuild: {}",