Skip to content

Commit fe7b1d5

Browse files
authored
Ci (#1)
* Setup CI
1 parent f3aa022 commit fe7b1d5

File tree

7 files changed

+53
-86
lines changed

7 files changed

+53
-86
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ find_package(PostgreSQL REQUIRED)
9797
message("PostgreSQL_INCLUDE_DIRS=${PostgreSQL_INCLUDE_DIRS}")
9898
message("PostgreSQL_LIBRARIES=${PostgreSQL_LIBRARIES}")
9999
message("PostgreSQL_TYPE_INCLUDE_DIR=${PostgreSQL_TYPE_INCLUDE_DIR}")
100+
message("PostgreSQL_VERSION_STRING=${PostgreSQL_VERSION_STRING}")
100101

101102
message("\n############################################################################\n")
102103

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM lganzzzo/alpine-cmake:latest
2+
3+
RUN apk update
4+
5+
RUN apk add postgresql-dev
6+
7+
WORKDIR /module
8+
9+
COPY ./cmake cmake
10+
COPY ./src src
11+
COPY ./test test
12+
COPY ./utility utility
13+
COPY ./CMakeLists.txt CMakeLists.txt
14+
15+
WORKDIR /module/utility
16+
17+
RUN ./install-oatpp-modules.sh
18+
19+
WORKDIR /module/build
20+
21+
ARG PG_HOST=postgres
22+
RUN cmake ..
23+
RUN make
24+
25+
ENTRYPOINT ["./test/module-tests"]

azure-pipelines.yml

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -13,81 +13,8 @@ jobs:
1313
clean: all
1414
steps:
1515
- script: |
16-
mkdir build
16+
docker-compose build
17+
displayName: 'Compose build'
1718
- script: |
18-
git clone https://github.com/oatpp/oatpp
19-
mkdir -p oatpp/build
20-
displayName: 'Checkout - oatpp'
21-
workingDirectory: build
22-
- script: |
23-
cmake ..
24-
sudo make install
25-
displayName: 'Build - oatpp'
26-
workingDirectory: build/oatpp/build
27-
- script: |
28-
cmake ..
29-
make
30-
displayName: 'Build - module'
31-
workingDirectory: build
32-
- script: |
33-
make test ARGS="-V"
34-
displayName: 'Test'
35-
workingDirectory: build
36-
- job: macOS
37-
displayName: 'Build - macOS'
38-
continueOnError: false
39-
pool:
40-
vmImage: 'macOS-10.14'
41-
workspace:
42-
clean: all
43-
steps:
44-
- script: |
45-
mkdir build
46-
- script: |
47-
git clone https://github.com/oatpp/oatpp
48-
mkdir -p oatpp/build
49-
displayName: 'Checkout - oatpp'
50-
workingDirectory: build
51-
- script: |
52-
cmake ..
53-
sudo make install
54-
displayName: 'Build - oatpp'
55-
workingDirectory: build/oatpp/build
56-
- script: |
57-
cmake ..
58-
make
59-
displayName: 'Build - module'
60-
workingDirectory: build
61-
- script: |
62-
make test ARGS="-V"
63-
displayName: 'Test'
64-
workingDirectory: build
65-
- job: windows
66-
displayName: 'Build - Windows'
67-
continueOnError: false
68-
pool:
69-
vmImage: 'windows-latest'
70-
workspace:
71-
clean: all
72-
steps:
73-
- script: |
74-
MD build
75-
- script: |
76-
git clone https://github.com/oatpp/oatpp
77-
MD oatpp\build
78-
displayName: 'Checkout - oatpp'
79-
workingDirectory: build
80-
- script: |
81-
cmake ..
82-
cmake --build . --target INSTALL
83-
displayName: 'Build - oatpp'
84-
workingDirectory: build\oatpp\build
85-
- script: |
86-
cmake ..
87-
cmake --build .
88-
displayName: 'Build - module'
89-
workingDirectory: build
90-
- script: |
91-
module-tests.exe
92-
displayName: 'Test'
93-
workingDirectory: build\test\Debug\
19+
docker-compose run test
20+
displayName: 'Compose run'

docker-compose.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
version: '3'
22

33
services:
4-
db:
4+
5+
postgres:
56
image: postgres
67
restart: always
78
environment:
89
POSTGRES_PASSWORD: db-pass
910
ports:
1011
- 5432:5432
1112

12-
adminer:
13-
image: adminer
14-
restart: always
15-
ports:
16-
- 8080:8080
13+
test:
14+
build: .
15+
depends_on:
16+
- postgres
17+

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ target_link_oatpp(${OATPP_THIS_MODULE_NAME})
3838

3939
target_include_directories(${OATPP_THIS_MODULE_NAME}
4040
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
41+
${PostgreSQL_INCLUDE_DIRS}
4142
)
4243

4344
target_link_libraries(${OATPP_THIS_MODULE_NAME}
44-
PUBLIC PostgreSQL::PostgreSQL
45+
PUBLIC ${PostgreSQL_LIBRARIES}
4546
)
4647

4748
#######################################################################################################

src/oatpp-postgresql/Executor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ Executor::QueryParams::QueryParams(const StringTemplate& queryTemplate,
9292

9393
auto value = typeResolver->resolveObjectPropertyValue(it->second, queryParameter.propertyPath, cache);
9494
if(value.valueType->classId.id == oatpp::Void::Class::CLASS_ID.id) {
95+
std::string tname = "UnNamed";
96+
if(extra->templateName) {
97+
tname = extra->templateName->std_str();
98+
}
9599
throw std::runtime_error("[oatpp::postgresql::Executor::QueryParams::QueryParams()]: "
96100
"Error."
97-
" Query '" + extra->templateName->std_str() +
101+
" Query '" + tname +
98102
"', parameter '" + var.name->std_str() +
99103
"' - property not found or its type is unknown.");
100104
}

test/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
if(DEFINED ENV{PG_HOST})
2+
set(POSTGRES_HOST $ENV{PG_HOST})
3+
else()
4+
set(POSTGRES_HOST localhost)
5+
endif()
6+
7+
message("POSTGRES_HOST=${POSTGRES_HOST}")
8+
19
add_definitions (
2-
-DTEST_DB_URL="postgresql://postgres:db-pass@localhost:5432/postgres"
10+
-DTEST_DB_URL="postgresql://postgres:db-pass@${POSTGRES_HOST}:5432/postgres"
311
-DTEST_DB_MIGRATION="${CMAKE_CURRENT_SOURCE_DIR}/oatpp-postgresql/migration/"
412
)
513

0 commit comments

Comments
 (0)