Skip to content

Commit

Permalink
build: config github action (apache#1)
Browse files Browse the repository at this point in the history
* build: config github action

Signed-off-by: Ruihang Xia <[email protected]>

* fix comment syntax

Signed-off-by: Ruihang Xia <[email protected]>

* comment out other stages

Signed-off-by: Ruihang Xia <[email protected]>

* setup build env

Signed-off-by: Ruihang Xia <[email protected]>

* ignore vergen error

Signed-off-by: Ruihang Xia <[email protected]>

* enable cache steps

Signed-off-by: Ruihang Xia <[email protected]>

* set default vergen env

Signed-off-by: Ruihang Xia <[email protected]>

* add more jobs

Signed-off-by: Ruihang Xia <[email protected]>

* fix trigger

Signed-off-by: Ruihang Xia <[email protected]>

* fix build env

Signed-off-by: Ruihang Xia <[email protected]>

* submodule add parquet test data

Signed-off-by: Ruihang Xia <[email protected]>

* enable dep cache

Signed-off-by: Ruihang Xia <[email protected]>

* replace tab with white space

Signed-off-by: Ruihang Xia <[email protected]>

* ignore document change

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored May 31, 2022
1 parent ff983d0 commit 28dcf1a
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 7 deletions.
180 changes: 180 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "components/parquet-testing"]
path = components/parquet-testing
url = https://github.com/apache/parquet-testing.git
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ fn main() {
}
}

vergen(config).expect("Vergen failed to generate config");
let _ = vergen(config);
}
1 change: 1 addition & 0 deletions components/parquet-testing
Submodule parquet-testing added at 7175a4
8 changes: 4 additions & 4 deletions src/bin/ceresdb-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}",
Expand Down

0 comments on commit 28dcf1a

Please sign in to comment.