diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 98a70a64d..000000000 --- a/.drone.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -kind: pipeline -type: docker -name: gcc_build - -steps: - - name: lint - image: vesoft/nebula-dev:ubuntu1804 - commands: - - ./ci/test.sh lint - - - name: gcc_build - image: vesoft/nebula-dev:ubuntu1804 - environment: - NEBULA_COMMON_REPO_URL: - from_secret: NEBULA_COMMON_REPO_URL - commands: - - ./ci/test.sh - depends_on: - - lint - ---- -kind: pipeline -type: docker -name: clang_build - -steps: - - name: lint - image: vesoft/nebula-dev:ubuntu1804 - commands: - - ./ci/test.sh lint - - - name: clang_build - image: vesoft/nebula-dev:ubuntu1804 - environment: - NEBULA_COMMON_REPO_URL: - from_secret: NEBULA_COMMON_REPO_URL - commands: - - ./ci/test.sh prepare - - ./ci/test.sh clang - - ./ci/test.sh test - depends_on: - - lint diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..627eca180 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,135 @@ +name: pull_request + +on: + pull_request: + types: [synchronize, reopened, labeled] + branches: + - master + - 'v[0-9]+.*' + +jobs: + lint: + name: lint + if: ${{ contains(github.event.pull_request.labels.*.name, 'ready-for-testing') }} + runs-on: ubuntu-latest + defaults: + run: + shell: bash + outputs: + num_source_files: ${{ steps.filter-source-files.outputs.num_source_files }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - name: Cpplint + run: | + ln -snf $PWD/.linters/cpp/hooks/pre-commit.sh $PWD/.linters/cpp/pre-commit.sh + .linters/cpp/pre-commit.sh $(git --no-pager diff --diff-filter=d --name-only HEAD^ HEAD) + - name: Filter source files + id: filter-source-files + run: | + diff_commits=$(git log --oneline -n 1 | cut -d' ' -f1,5) + num_source_files=$(git --no-pager diff --name-only $diff_commits | grep '^src\|^CMakeLists.txt\|^cmake\|^.github/workflows' | wc -l) + echo "::set-output name=num_source_files::${num_source_files}" + + build: + name: build + needs: lint + if: ${{ needs.lint.outputs.num_source_files != 0 }} + runs-on: self-hosted + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + os: + - centos7 + - ubuntu1804 + compiler: + - gcc-9.2 + - clang-9 + exclude: + - os: centos7 + compiler: clang-9 + container: + image: vesoft/nebula-dev:${{ matrix.os }} + env: + TOOLSET_DIR: /opt/vesoft/toolset/clang/9.0.0 + CCACHE_DIR: /tmp/ccache/nebula-storage/${{ matrix.os }}-${{ matrix.compiler }} + CCACHE_MAXSIZE: 1G + volumes: + - /tmp/ccache/nebula-storage/${{ matrix.os }}-${{ matrix.compiler }}:/tmp/ccache/nebula-storage/${{ matrix.os }}-${{ matrix.compiler }} + - /run/secrets/GITHUB_PAT:/run/secrets/GITHUB_PAT + options: --mount type=tmpfs,destination=/tmp/ccache/nebula-storage,tmpfs-size=1073741824 --cap-add=SYS_PTRACE + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Prepare environment + id: prepare + run: | + [ -d build/ ] && rm -rf build/* || mkdir -p build + echo "::set-output name=pat::$(cat /run/secrets/GITHUB_PAT)" + - name: Checkout common + uses: actions/checkout@v2 + with: + repository: ${{ github.repository_owner }}/nebula-common + token: ${{ steps.prepare.outputs.pat }} + path: modules/common + - name: CMake + run: | + case ${{ matrix.compiler }} in + gcc-*) + case ${{ matrix.os }} in + centos7) + # build with Release type + cmake \ + -DCMAKE_CXX_COMPILER=$TOOLSET_DIR/bin/g++ \ + -DCMAKE_C_COMPILER=$TOOLSET_DIR/bin/gcc \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_TESTING=on \ + -DCMAKE_PREFIX_PATH=modules/common \ + -DNEBULA_THIRDPARTY_ROOT=/opt/vesoft/third-party/ \ + -B build + ;; + ubuntu1804) + # build with Debug type + cmake \ + -DCMAKE_CXX_COMPILER=$TOOLSET_DIR/bin/g++ \ + -DCMAKE_C_COMPILER=$TOOLSET_DIR/bin/gcc \ + -DCMAKE_BUILD_TYPE=Debug \ + -DENABLE_TESTING=on \ + -DCMAKE_PREFIX_PATH=modules/common \ + -DNEBULA_THIRDPARTY_ROOT=/opt/vesoft/third-party/ \ + -B build + ;; + esac + ;; + clang-*) + # build with Sanitizer + cmake \ + -DCMAKE_CXX_COMPILER=$TOOLSET_DIR/bin/clang++ \ + -DCMAKE_C_COMPILER=$TOOLSET_DIR/bin/clang \ + -DCMAKE_BUILD_TYPE=Debug \ + -DENABLE_ASAN=on \ + -DENABLE_TESTING=on \ + -DCMAKE_PREFIX_PATH=modules/common \ + -DNEBULA_THIRDPARTY_ROOT=/opt/vesoft/third-party \ + -B build + ;; + esac + - name: Make common + run: cmake --build modules/common/ -j $(nproc) + - name: Make storage + run: cmake --build build/ -j $(nproc) + - name: CTest + env: + ASAN_SYMBOLIZER_PATH: $TOOLSET_DIR/bin/llvm-symbolizer + ASAN_OPTIONS: fast_unwind_on_malloc=1 + run: ctest -j $(($(nproc)/2+1)) --timeout 400 --output-on-failure + working-directory: build/ + timeout-minutes: 15 + - name: Cleanup + if: ${{ always() }} + run: rm -rf build modules/common