Skip to content

Commit

Permalink
feat: relocate hybridse java (4paradigm#884)
Browse files Browse the repository at this point in the history
- move hybridse java to java directory, close feat: move hybridse java module to OpenMLDB 4paradigm#674
- refactor coverage job, ci: include OpenMLDB cpp & java code in codecoverage report 4paradigm#677
- minor bug fix for top Makefile

limit:
- OpenMLDB's test is not added into ctest, so coverage task will not run it from this pr.
Just checked the it is the same number of tests runs by coverage compared to previous coverage job: 65. And we will end up add more tests to coverage task
  • Loading branch information
aceforeverd authored Dec 17, 2021
1 parent 22acf53 commit db5baac
Show file tree
Hide file tree
Showing 45 changed files with 387 additions and 1,097 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
tags:
- v*
pull_request:
paths-ignore:
- docs/
- demo/
- image/
- release/
- tools/
workflow_dispatch:

env:
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: coverage

on:
push:
branches:
- main
pull_request:
paths-ignore:
- docs/
- demo/
- release/
- image/
- tools/
workflow_dispatch:

jobs:
coverage:
runs-on: self-hosted
container:
image: ghcr.io/4paradigm/hybridsql:0.4.0
env:
CMAKE_BUILD_TYPE: Debug
SQL_PYSDK_ENABLE: OFF
SQL_JAVASDK_ENABLE: ON
TESTING_ENABLE: ON
NPROC: 8
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('java/**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: setup thirdparty
run: |
make thirdparty
- name: coverage configure
run: |
make coverage-configure
- name: build openmldb
run: |
cmake --build build --target openmldb -- -j${{ env.NPROC }}
- name: start service
run: |
sh steps/ut_zookeeper.sh start
cd onebox
bash start_onebox.sh
- name: Build and Coverage
run: |
make coverage
- name: Upload Coverage Report
uses: codecov/codecov-action@v2
with:
files: build/coverage.info,java/**/target/site/jacoco/jacoco.xml
name: coverage
fail_ci_if_error: true
verbose: true

- name: stop service
run: |
./onebox/stop_all.sh
sh steps/ut_zookeeper.sh stop
194 changes: 0 additions & 194 deletions .github/workflows/hybridse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
tags:
- hybridse-v*
pull_request:
paths:
- .github/workflows/hybridse-ci.yml
Expand All @@ -30,22 +28,6 @@ jobs:
with:
submodules: true

- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Import GPG key
if: ${{ github.event_name == 'push' }}
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Build Core
run: |
make hybridse-build
Expand All @@ -62,44 +44,6 @@ jobs:
path: |
${{ env.HYBRIDSE_PATH }}/build/*.xml
- name: Java SDK Test
working-directory: ${{ env.HYBRIDSE_PATH }}/java
run: |
mvn -U clean compile test
- name: Upload Java UT Results
if: always()
uses: actions/upload-artifact@v2
with:
name: linux-ut-result-java-${{ github.sha }}
path: |
${{ env.HYBRIDSE_PATH }}/java/hybridse-sdk/target/**/TEST-*.xml
- name: Upload jsdk
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v2
with:
path: ${{ env.HYBRIDSE_PATH }}/build/src/sdk/libhybridse*.so
name: lib-artifacts

- name: Prepare Maven Release Deploy
if: startsWith(github.ref, 'refs/tags/hybridse-v')
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^hybridse-v//')
.${{ env.HYBRIDSE_PATH }}/java/prepare_release.sh $VERSION
- name: Publish Java Library
if: ${{ github.event_name == 'push' }}
working-directory: ${{ env.HYBRIDSE_PATH }}/java
run: |
mvn --batch-mode deploy
env:
MAVEN_OPTS: -Duser.home=/github/home
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

macos-build:
name: Build in MacOS
runs-on: macos-latest
Expand All @@ -110,22 +54,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Import GPG key
if: ${{ github.event_name == 'push' }}
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Install dependencies
run: |
brew install coreutils
Expand All @@ -146,107 +74,6 @@ jobs:
path: |
${{ env.HYBRIDSE_PATH }}/build/*.xml
- name: Java SDK Test
working-directory: ${{ env.HYBRIDSE_PATH }}/java
run: |
mvn -U clean compile test
- name: Upload Java UT Results
if: always()
uses: actions/upload-artifact@v2
with:
name: macos-ut-result-java-${{ github.sha }}
path: |
${{ env.HYBRIDSE_PATH }}/java/hybridse-sdk/target/**/TEST-*.xml
- name: Upload jsdk
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v2
with:
path: ${{ env.HYBRIDSE_PATH }}/build/src/sdk/libhybridse*.dylib
name: lib-artifacts

- name: Prepare Maven Release Deploy
if: startsWith(github.ref, 'refs/tags/hybridse-v')
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^hybridse-v//')
./${{ env.HYBRIDSE_PATH }}/java/prepare_release.sh $VERSION
- name: Publish Java Library
if: ${{ github.event_name == 'push' }}
working-directory: ${{ env.HYBRIDSE_PATH }}/java
run: |
mvn --batch-mode -P macos clean install
mvn --batch-mode -P macos -pl hybridse-native deploy
mvn --batch-mode -P macos -pl hybridse-sdk deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

java-allinone-deploy:
runs-on: ubuntu-latest
container:
image: ghcr.io/4paradigm/hybridsql:0.4.0
needs: ["macos-build", "linux-build"]
if: >
success() && github.event_name == 'push'
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Download Lib Artifacts
uses: actions/download-artifact@v2
with:
name: lib-artifacts
path: ${{ env.HYBRIDSE_PATH }}

- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Import GPG key
if: ${{ github.event_name == 'push' }}
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Build proto library
run: |
make hybridse_proto
- name: Copy Dylib
run: |
cp libhybridse_*.dylib ${{ env.HYBRIDSE_PATH }}/java/hybridse-native/src/main/resources/
cp libhybridse_*.so ${{ env.HYBRIDSE_PATH }}/java/hybridse-native/src/main/resources/
- name: Prepare Maven Release Deploy
if: startsWith(github.ref, 'refs/tags/hybridse-v')
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^hybridse-v//')
.${{ env.HYBRIDSE_PATH }}/java/prepare_release.sh $VERSION
- name: Publish Java Library
working-directory: ${{ env.HYBRIDSE_PATH }}/java
run: |
mvn --batch-mode -P allinone clean install
mvn --batch-mode -P allinone -pl hybridse-native deploy
mvn --batch-mode -P allinone -pl hybridse-sdk deploy
env:
MAVEN_OPTS: -Duser.home=/github/home
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_TOKEN: ${{ secrets.OSSRH_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

publish-test-results:
runs-on: ubuntu-latest
needs: ["linux-build", "macos-build"]
Expand All @@ -273,24 +100,3 @@ jobs:
check_name: HybridSE Mac Test Report
comment_title: HybridSE Mac Test Report

coverage:
runs-on: ubuntu-latest
container:
image: ghcr.io/4paradigm/hybridsql:0.4.0

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Build and Coverage
run: |
make coverage
- name: Upload Coverage Report
uses: codecov/codecov-action@v2
with:
files: ${{ env.HYBRIDSE_PATH }}/build/coverage.info,${{ env.HYBRIDSE_PATH }}/java/hybridse-sdk/target/site/jacoco/jacoco.xml
name: coverage
fail_ci_if_error: true
verbose: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ java/openmldb-common/src/main/java/com/_4paradigm/openmldb/proto/
java/openmldb-import/src/main/java/com/_4paradigm/openmldb/proto/
java/openmldb-nearline-tablet/src/main/java/com/_4paradigm/openmldb/proto/
java/openmldb-taskmanager/src/main/java/com/_4paradigm/openmldb/proto/
java/hybridse-native/src/main/java
java/hybridse-proto/src
python/logs
/python/test/*.xml

Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "cmake-modules"]
path = hybridse/cmake-modules
path = cmake-modules
url = https://github.com/bilke/cmake-modules.git
28 changes: 24 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ if (POLICY CMP0086)
cmake_policy(SET CMP0086 NEW)
endif ()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules")

project(openmldb)

if (CMAKE_BUILD_TYPE STREQUAL "")
Expand Down Expand Up @@ -75,6 +77,7 @@ option(TCMALLOC_ENABLE "Enable TCMALLOC" ON)
option(SQL_PYSDK_ENABLE "Enable sql pysdk" OFF)
option(SQL_JAVASDK_ENABLE "Enable sql javasdk" OFF)
option(MAC_TABLET_ENABLE "Enable Table on Mac OS" ON)
option(COVERAGE_ENABLE "Enable Coverage" OFF)
message (STATUS "MAC_TABLET_ENABLE: ${MAC_TABLET_ENABLE}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if (MAC_TABLET_ENABLE)
Expand All @@ -98,6 +101,18 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(BRPC_LIBS brpc protobuf glog gflags ssl crypto leveldb z snappy dl pthread ${OS_LIB})
endif ()


if (TESTING_ENABLE)
enable_testing()
endif ()

set(test_list "")
if (COVERAGE_ENABLE AND CMAKE_COMPILER_IS_GNUCXX)
find_program(LCOV_EXE NAMES lcov DOC "coverage requires lcov installed" REQUIRED)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
endif ()

if (NOT DEFINED CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/.deps/usr)
endif()
Expand Down Expand Up @@ -174,10 +189,6 @@ if (TCMALLOC_ENABLE)
set(CMAKE_EXE_LINKER_FLAGS "-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free ${CMAKE_EXE_LINKER_FLAGS}")
endif()

if(POLICY CMP0086)
cmake_policy(SET CMP0086 NEW)
endif()

configure_file(
"${PROJECT_SOURCE_DIR}/src/config.h.in"
"${PROJECT_SOURCE_DIR}/src/config.h")
Expand All @@ -191,6 +202,15 @@ link_directories(${CMAKE_PREFIX_PATH}/lib ${CMAKE_PREFIX_PATH}/lib64)

add_subdirectory(src)

if (COVERAGE_ENABLE AND CMAKE_COMPILER_IS_GNUCXX)
# depends proto targets so java's coverage will work
set(coverage_deps openmldb_proto hybridse_proto ${test_list})
SETUP_TARGET_FOR_COVERAGE_LCOV(NAME coverage
EXECUTABLE ctest -j ${n_cores}
DEPENDENCIES ${test_list})
endif ()


if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# CMAKE_INSTALL_PREFIX default to /usr/local on unix.
# At current phase we'd like to change it to a customized directory by default
Expand Down
Loading

0 comments on commit db5baac

Please sign in to comment.