Skip to content

Commit 6c6f87c

Browse files
authored
ci: adaptation for windows (milvus-io#232)
Signed-off-by: Ji Bin <[email protected]>
1 parent ffa93cf commit 6c6f87c

File tree

10 files changed

+107
-66
lines changed

10 files changed

+107
-66
lines changed

.github/workflows/main.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,40 @@ jobs:
152152
- name: Uint Testing
153153
run: |
154154
make test
155+
windows:
156+
name: Build and test windows
157+
runs-on: windows-2022
158+
timeout-minutes: 45
159+
env:
160+
CCACHE_DIR: ${{ github.workspace }}/.ccache
161+
CCACHE_COMPILERCHECK: content
162+
CCACHE_COMPRESS: 1
163+
CCACHE_COMPRESSLEVEL: 5
164+
steps:
165+
- name: Checkout
166+
uses: actions/checkout@v3
167+
- name: Cache ccache
168+
uses: actions/cache@v3
169+
with:
170+
path: |
171+
${{ github.workspace }}/.ccache
172+
key: windows-ccache-${{ github.sha }}
173+
restore-keys: windows-ccache-
174+
- name: Install dependencies on windows
175+
shell: cmd
176+
run: |
177+
choco install cmake ninja ccache
178+
cmake --version
179+
ninja --version
180+
- name: Build
181+
shell: cmd
182+
run: |
183+
call "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
184+
cmake -S . -B build -DMILVUS_BUILD_TEST=YES -G Ninja
185+
cmake --build build
186+
- name: Uint Testing
187+
shell: cmd
188+
run: |
189+
build\test\testing-ut
190+
build\test\testing-it
191+

CMakeLists.txt

+19-24
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,21 @@ find_program(CCACHE_FOUND ccache)
3232
if(CCACHE_FOUND)
3333
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
3434
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
35+
message(STATUS "using ccache")
3536
endif(CCACHE_FOUND)
3637

37-
include(FindPython)
3838
include(FindClangTools)
3939
include(GoogleTest)
4040
include(CTest)
4141

4242
include(DefineOptions)
43-
include(ThirdPartyPackages)
44-
include(MilvusProtoGen)
4543

4644
# options
4745

4846
set_option_category("Build")
4947

50-
define_option(BUILD_TEST "Build with testing" OFF)
51-
define_option(BUILD_COVERAGE "Build with coverage" OFF)
52-
define_option(BUILD_SHARED "Build with shared" ON)
53-
define_option(BUILD_STATIC "Build with static" OFF)
48+
define_option(MILVUS_BUILD_TEST "Build with testing" OFF)
49+
define_option(MILVUS_BUILD_COVERAGE "Build with coverage" OFF)
5450
define_option_string(MILVUS_SDK_VERSION
5551
"Version for sdk"
5652
"2.0.0")
@@ -69,14 +65,19 @@ define_option_string(MILVUS_WITH_NLOHMANN_JSON "nlohmann json from" "module"
6965
define_option_string(MILVUS_WITH_GTEST "Using GTest from" "module" "package" "module")
7066

7167

72-
set(CMAKE_CXX_STANDARD 11)
68+
set(CMAKE_CXX_STANDARD 14)
7369
set(CMAKE_CXX_STANDARD_REQUIRED on)
7470
set(BUILD_SCRIPTS_DIR ${PROJECT_SOURCE_DIR}/scripts)
75-
7671
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7772

78-
if (BUILD_TEST)
79-
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
73+
74+
# load third packages and milvus-proto
75+
include(ThirdPartyPackages)
76+
include(MilvusProtoGen)
77+
78+
# add testing
79+
if (MILVUS_BUILD_TEST)
80+
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND MILVUS_BUILD_COVERAGE )
8081
# Set compile flag for code coverage.
8182
# Note: Only do this in Debug/unittest mode. Must do this before add_subdirectory(src).
8283
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
@@ -88,16 +89,10 @@ endif ()
8889
add_subdirectory(src)
8990
add_subdirectory(examples)
9091

91-
92-
# lint verbose options
93-
if (NOT MILVUS_VERBOSE_LINT)
94-
set(MILVUS_LINT_QUIET "--quiet")
95-
endif ()
96-
9792
#
9893
# make lint
9994
#
100-
find_package(Python)
95+
find_package(Python2)
10196

10297
if (NOT LINT_EXCLUSIONS_FILE)
10398
set(LINT_EXCLUSIONS_FILE ${BUILD_SCRIPTS_DIR}/lint_exclusions.txt)
@@ -108,7 +103,7 @@ if (NOT FORMAT_EXCLUSIONS_FILE)
108103
endif ()
109104

110105
add_custom_target(lint
111-
${Python_EXECUTABLE}
106+
${Python2_EXECUTABLE}
112107
${BUILD_SCRIPTS_DIR}/run_cpplint.py
113108
--cpplint_binary
114109
${BUILD_SCRIPTS_DIR}/cpplint.py
@@ -125,7 +120,7 @@ add_custom_target(lint
125120
if (${CLANG_FORMAT_FOUND})
126121
# runs clang format and updates files in place.
127122
add_custom_target(clang-format
128-
${Python_EXECUTABLE}
123+
${Python2_EXECUTABLE}
129124
${BUILD_SCRIPTS_DIR}/run_clang_format.py
130125
--clang_format_binary
131126
${CLANG_FORMAT_BIN}
@@ -138,7 +133,7 @@ if (${CLANG_FORMAT_FOUND})
138133

139134
# runs clang format and exits with a non-zero exit code if any files need to be reformatted
140135
add_custom_target(check-clang-format
141-
${Python_EXECUTABLE}
136+
${Python2_EXECUTABLE}
142137
${BUILD_SCRIPTS_DIR}/run_clang_format.py
143138
--clang_format_binary
144139
${CLANG_FORMAT_BIN}
@@ -155,7 +150,7 @@ endif ()
155150
if (${CLANG_TIDY_FOUND})
156151
# runs clang-tidy and attempts to fix any warning automatically
157152
add_custom_target(clang-tidy
158-
${Python_EXECUTABLE}
153+
${Python2_EXECUTABLE}
159154
${BUILD_SCRIPTS_DIR}/run_clang_tidy.py
160155
--clang_tidy_binary
161156
${CLANG_TIDY_BIN}
@@ -170,7 +165,7 @@ if (${CLANG_TIDY_FOUND})
170165

171166
# runs clang-tidy and exits with a non-zero exit code if any errors are found.
172167
add_custom_target(check-clang-tidy
173-
${Python_EXECUTABLE}
168+
${Python2_EXECUTABLE}
174169
${BUILD_SCRIPTS_DIR}/run_clang_tidy.py
175170
--clang_tidy_binary
176171
${CLANG_TIDY_BIN}
@@ -184,4 +179,4 @@ if (${CLANG_TIDY_FOUND})
184179
endif ()
185180

186181
# output config summary
187-
config_summary()
182+
config_summary()

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ st:
4141
@echo "System Testing with Milvus SDK"
4242
@(env bash $(PWD)/scripts/build.sh -s)
4343

44-
coverage: test st
44+
coverage:
4545
@echo "Run code coverage ..."
46+
@(env bash $(PWD)/scripts/build.sh -u -s -c)
4647
@(env bash $(PWD)/scripts/coverage.sh)
4748

4849
documentation:

cmake/ThirdPartyPackages.cmake

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,29 @@
1616

1717
include_guard(GLOBAL)
1818

19-
20-
# ----------------------------------------------------------------------
21-
# Needs threads
22-
set(THREADS_PREFER_PTHREAD_FLAG ON)
23-
find_package(Threads REQUIRED)
2419
include(CPM)
2520

2621
# grpc
2722
if ("${MILVUS_WITH_GRPC}" STREQUAL "pakcage")
2823
find_package(grpc REQUIRED)
2924
else ()
25+
if (WIN32)
26+
set(OPENSSL_NO_ASM_TXT "YES")
27+
else ()
28+
set(OPENSSL_NO_ASM_TXT "NO")
29+
endif ()
3030
CPMAddPackage(
3131
NAME grpc
3232
VERSION 1.49.1
3333
GITHUB_REPOSITORY grpc/grpc
34+
EXCLUDE_FROM_ALL YES
3435
OPTIONS
3536
"gRPC_SSL_PROVIDER module"
3637
"gRPC_PROTOBUF_PROVIDER module"
3738
"gRPC_BUILD_TESTS OFF"
3839
"RE2_BUILD_TESTING OFF"
3940
"ABSL_PROPAGATE_CXX_STD ON"
41+
"OPENSSL_NO_ASM ${OPENSSL_NO_ASM_TXT}"
4042
)
4143
if (grpc_ADDED)
4244
add_library(gRPC::grpc++ ALIAS grpc++)

examples/simple/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ main(int argc, char* argv[]) {
8181
std::vector<int8_t> insert_ages;
8282
std::vector<std::vector<float>> insert_vectors;
8383
std::default_random_engine ran(time(nullptr));
84-
std::uniform_int_distribution<int8_t> int_gen(1, 100);
84+
std::uniform_int_distribution<int> int_gen(1, 100);
8585
std::uniform_real_distribution<float> float_gen(0.0, 1.0);
8686
for (auto i = 0; i < row_count; ++i) {
8787
insert_ids.push_back(i);

scripts/build.sh

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ SYS_TEST="OFF"
2323
BUILD_TEST="OFF"
2424
MAKE_CLEAN="OFF"
2525
RUN_CPPLINT="OFF"
26+
BUILD_COVERAGE="OFF"
2627
MILVUS_SDK_VERSION=${MILVUS_SDK_VERSION:-2.0.0}
2728

2829
JOBS="$(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 3)"
2930
if [ ${JOBS} -lt 3 ] ; then
3031
JOBS=3
3132
fi
3233

33-
while getopts "t:v:ulrsph" arg; do
34+
while getopts "t:v:ulrcsph" arg; do
3435
case $arg in
3536
t)
3637
BUILD_TYPE=$OPTARG # BUILD_TYPE
@@ -52,6 +53,9 @@ while getopts "t:v:ulrsph" arg; do
5253
UNIT_TEST="ON"
5354
BUILD_TEST="ON"
5455
;;
56+
c)
57+
BUILD_COVERAGE="ON"
58+
;;
5559
s)
5660
SYS_TEST="ON"
5761
BUILD_TEST="ON"
@@ -73,6 +77,7 @@ parameter:
7377
-u: build with unit testing(default: OFF)
7478
-r: clean before build
7579
-s: build with system testing(default: OFF)
80+
-c: build with coverage
7681
-p: build with production(-t RelWithDebInfo -r)
7782
-h: help
7883
@@ -104,8 +109,8 @@ fi
104109

105110
CMAKE_CMD="cmake \
106111
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
107-
-DBUILD_TEST=${BUILD_TEST} \
108-
-DMAKE_BUILD_ARGS=-j${JOBS}
112+
-DMILVUS_BUILD_TEST=${BUILD_TEST} \
113+
-DMILVUS_BUILD_COVERAGE=${BUILD_COVERAGE} \
109114
-DMILVUS_SDK_VERSION=${MILVUS_SDK_VERSION} \
110115
../"
111116
echo ${CMAKE_CMD}
@@ -147,10 +152,11 @@ fi
147152

148153
if [[ "${UNIT_TEST}" == "ON" ]]; then
149154
make -j ${JOBS} || exit 1
150-
make CTEST_OUTPUT_ON_FAILURE=1 test || exit 1
155+
./test/testing-ut || exit 1
156+
./test/testing-it || exit 1
151157
fi
152158

153159
if [[ "${SYS_TEST}" == "ON" ]]; then
154160
make -j ${JOBS} || exit 1
155-
make CTEST_OUTPUT_ON_FAILURE=1 system-test || exit 1
161+
./test/testing-st || exit 1
156162
fi

src/impl/TypeUtils.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ operator==(const proto::schema::FieldData& lhs, const BoolFieldData& rhs) {
2323
if (lhs.field_name() != rhs.Name()) {
2424
return false;
2525
}
26-
if (not lhs.has_scalars()) {
26+
if (!lhs.has_scalars()) {
2727
return false;
2828
}
2929
const auto& scalars = lhs.scalars();
30-
if (not scalars.has_bool_data()) {
30+
if (!scalars.has_bool_data()) {
3131
return false;
3232
}
3333
const auto& scalars_data = scalars.bool_data().data();
@@ -42,11 +42,11 @@ operator==(const proto::schema::FieldData& lhs, const Int8FieldData& rhs) {
4242
if (lhs.field_name() != rhs.Name()) {
4343
return false;
4444
}
45-
if (not lhs.has_scalars()) {
45+
if (!lhs.has_scalars()) {
4646
return false;
4747
}
4848
const auto& scalars = lhs.scalars();
49-
if (not scalars.has_int_data()) {
49+
if (!scalars.has_int_data()) {
5050
return false;
5151
}
5252
const auto& scalars_data = scalars.int_data().data();
@@ -61,11 +61,11 @@ operator==(const proto::schema::FieldData& lhs, const Int16FieldData& rhs) {
6161
if (lhs.field_name() != rhs.Name()) {
6262
return false;
6363
}
64-
if (not lhs.has_scalars()) {
64+
if (!lhs.has_scalars()) {
6565
return false;
6666
}
6767
const auto& scalars = lhs.scalars();
68-
if (not scalars.has_int_data()) {
68+
if (!scalars.has_int_data()) {
6969
return false;
7070
}
7171
const auto& scalars_data = scalars.int_data().data();
@@ -80,11 +80,11 @@ operator==(const proto::schema::FieldData& lhs, const Int32FieldData& rhs) {
8080
if (lhs.field_name() != rhs.Name()) {
8181
return false;
8282
}
83-
if (not lhs.has_scalars()) {
83+
if (!lhs.has_scalars()) {
8484
return false;
8585
}
8686
const auto& scalars = lhs.scalars();
87-
if (not scalars.has_int_data()) {
87+
if (!scalars.has_int_data()) {
8888
return false;
8989
}
9090
const auto& scalars_data = scalars.int_data().data();
@@ -99,11 +99,11 @@ operator==(const proto::schema::FieldData& lhs, const Int64FieldData& rhs) {
9999
if (lhs.field_name() != rhs.Name()) {
100100
return false;
101101
}
102-
if (not lhs.has_scalars()) {
102+
if (!lhs.has_scalars()) {
103103
return false;
104104
}
105105
const auto& scalars = lhs.scalars();
106-
if (not scalars.has_long_data()) {
106+
if (!scalars.has_long_data()) {
107107
return false;
108108
}
109109
const auto& scalars_data = scalars.long_data().data();
@@ -118,11 +118,11 @@ operator==(const proto::schema::FieldData& lhs, const FloatFieldData& rhs) {
118118
if (lhs.field_name() != rhs.Name()) {
119119
return false;
120120
}
121-
if (not lhs.has_scalars()) {
121+
if (!lhs.has_scalars()) {
122122
return false;
123123
}
124124
const auto& scalars = lhs.scalars();
125-
if (not scalars.has_float_data()) {
125+
if (!scalars.has_float_data()) {
126126
return false;
127127
}
128128
const auto& scalars_data = scalars.float_data().data();
@@ -137,11 +137,11 @@ operator==(const proto::schema::FieldData& lhs, const DoubleFieldData& rhs) {
137137
if (lhs.field_name() != rhs.Name()) {
138138
return false;
139139
}
140-
if (not lhs.has_scalars()) {
140+
if (!lhs.has_scalars()) {
141141
return false;
142142
}
143143
const auto& scalars = lhs.scalars();
144-
if (not scalars.has_double_data()) {
144+
if (!scalars.has_double_data()) {
145145
return false;
146146
}
147147
const auto& scalars_data = scalars.double_data().data();
@@ -156,11 +156,11 @@ operator==(const proto::schema::FieldData& lhs, const VarCharFieldData& rhs) {
156156
if (lhs.field_name() != rhs.Name()) {
157157
return false;
158158
}
159-
if (not lhs.has_scalars()) {
159+
if (!lhs.has_scalars()) {
160160
return false;
161161
}
162162
const auto& scalars = lhs.scalars();
163-
if (not scalars.has_string_data()) {
163+
if (!scalars.has_string_data()) {
164164
return false;
165165
}
166166
const auto& scalars_data = scalars.string_data().data();
@@ -204,7 +204,7 @@ operator==(const proto::schema::FieldData& lhs, const FloatVecFieldData& rhs) {
204204
if (lhs.field_name() != rhs.Name()) {
205205
return false;
206206
}
207-
if (not lhs.has_vectors()) {
207+
if (!lhs.has_vectors()) {
208208
return false;
209209
}
210210
size_t dim = 0;

0 commit comments

Comments
 (0)