Skip to content

Commit ca6893a

Browse files
committed
添加集成测试
1 parent 8aa3e59 commit ca6893a

File tree

2 files changed

+91
-7
lines changed

2 files changed

+91
-7
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 3TS CI
2+
3+
on:
4+
push:
5+
branches:
6+
- coo-consistency-check
7+
pull_request:
8+
branches:
9+
- coo-consistency-check
10+
11+
jobs:
12+
build_and_test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
# 设置构建环境和安装依赖项
19+
- name: Set up build environment
20+
run: |
21+
echo "Setting up build environment..."
22+
sudo apt-get update && sudo apt-get install -y cmake make g++ libgflags-dev unixodbc unixodbc-dev odbcinst odbcinst1debian2
23+
echo "Build environment setup complete."
24+
25+
# 安装 Docker,如果尚未安装
26+
- name: Install Docker
27+
run: |
28+
echo "Installing Docker..."
29+
curl -s https://get.docker.com/ | sh
30+
echo "Docker installed successfully."
31+
32+
# 拉取 Docker 镜像
33+
- name: Pull Docker image
34+
run: docker pull registry.cn-hangzhou.aliyuncs.com/open_projects/3ts_coo:1.0
35+
36+
# 列出 Docker 镜像
37+
- name: List Docker images
38+
run: docker images
39+
40+
# 运行 Docker 容器,并挂载项目目录
41+
- name: Run Docker container with volume
42+
run: |
43+
IMAGE_ID=$(docker images -q registry.cn-hangzhou.aliyuncs.com/open_projects/3ts_coo:1.0)
44+
docker run -d --name 3ts_container -v ${{ github.workspace }}:/src $IMAGE_ID tail -f /dev/null
45+
46+
# 在 Docker 容器中编译
47+
- name: Compile inside Docker
48+
run: |
49+
echo "Compiling in Docker container..."
50+
docker exec -i 3ts_container bash -c "cd /src/src/dbtest && cmake -S ./ && make"
51+
52+
# 清理 Docker 容器
53+
- name: Clean up Docker container
54+
if: always()
55+
run: docker rm -f 3ts_container
56+
57+
# 在非 Docker 环境中编译
58+
- name: Compile without Docker
59+
run: |
60+
echo "Compiling using CMake..."
61+
cd src/dbtest
62+
sudo rm -rf CMakeCache.txt CMakeFiles # 清除缓存文件
63+
cmake -S ./ || cmake -DCMAKE_PREFIX_PATH=/usr/ -S ./
64+
make
65+
echo "Compilation finished."

src/dbtest/CMakeLists.txt

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,26 @@ list(APPEND THIRD_PARTIES pthread)
1717

1818
find_package(gflags REQUIRED)
1919
list(APPEND THIRD_PARTIES gflags)
20+
#
21+
# Manually find ODBC library and headers
22+
find_path(ODBC_INCLUDE_DIR sql.h
23+
PATHS /usr/include /usr/local/include
24+
)
25+
26+
find_library(ODBC_LIBRARIES
27+
NAMES odbc odbc32
28+
PATHS /usr/lib /usr/local/lib
29+
)
2030

31+
# Check if ODBC was found
32+
if (ODBC_INCLUDE_DIR AND ODBC_LIBRARIES)
33+
message(STATUS "Found ODBC library and include directory.")
34+
include_directories(${ODBC_INCLUDE_DIR})
35+
list(APPEND ODBC_LD ${ODBC_LIBRARIES})
36+
else()
37+
message(FATAL_ERROR "Could not find ODBC library or include directory.")
38+
endif()
39+
#
2140
########### sql test V1 #############
2241
# static test with 33 test case
2342
# all .cc files
@@ -30,9 +49,9 @@ list(APPEND SOURCE_FILES_SQL
3049
# bin
3150
add_executable(3ts_dbtest ${SOURCE_FILES_SQL})
3251
# ld:odbc
33-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/")
34-
find_package(ODBC REQUIRED)
35-
list(APPEND ODBC_LD odbc)
52+
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/")
53+
#find_package(ODBC REQUIRED)
54+
#list(APPEND ODBC_LD odbc)
3655
# link ld
3756
target_link_libraries(3ts_dbtest ${THIRD_PARTIES})
3857
target_link_libraries(3ts_dbtest ${ODBC_LD})
@@ -49,9 +68,9 @@ list(APPEND SOURCE_FILES_SQL_v2
4968
# bin
5069
add_executable(3ts_dbtest_v2 ${SOURCE_FILES_SQL_v2})
5170
# ld:odbc
52-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/")
53-
find_package(ODBC REQUIRED)
54-
list(APPEND ODBC_LD odbc)
71+
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/")
72+
#find_package(ODBC REQUIRED)
73+
#list(APPEND ODBC_LD odbc)
5574
# link ld
5675
target_link_libraries(3ts_dbtest_v2 ${THIRD_PARTIES})
5776
target_link_libraries(3ts_dbtest_v2 ${ODBC_LD})
@@ -83,4 +102,4 @@ target_link_libraries(3ts_dbtest_v2 ${ODBC_LD})
83102
# "/usr/local/include/libmongoc-1.0"
84103
# "/usr/local/include/libbson-1.0"
85104
# "/usr/local/lib"
86-
# )
105+
# )

0 commit comments

Comments
 (0)