Skip to content

Commit 5328f10

Browse files
authored
Add C++ Pistache petstore server to Travis CI (#616)
* test cpp pistache petstore in travis * make build_petstore executable * add submodule update init * use addExternalLibs option * update samples * update gcc version to 5 * fix addon, env * restore cargo path * trigger build failure, add cache * undo build failure change
1 parent 1dee3e2 commit 5328f10

8 files changed

Lines changed: 107 additions & 6 deletions

File tree

.travis.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@ cache:
3030
- $HOME/perl5
3131
- $HOME/.cargo
3232
- $HOME/.stack
33+
- $HOME/samples/server/petstore/cpp-pistache/pistache
3334

3435
services:
3536
- docker
3637

3738
# comment out the host table change to use the public petstore server
3839
addons:
40+
apt:
41+
sources:
42+
- ubuntu-toolchain-r-test
43+
packages:
44+
- g++-5
3945
chrome: stable
4046
hosts:
4147
- petstore.swagger.io
@@ -86,10 +92,13 @@ before_install:
8692

8793
install:
8894
# Add Godeps dependencies to GOPATH and PATH
89-
- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
90-
- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
95+
#- eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.4 bash)"
96+
#- export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace"
9197
- export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$HOME/.cargo/bin:$PATH"
92-
- go version
98+
#- go version
99+
- gcc -v
100+
- echo $CC
101+
- echo $CXX
93102

94103
script:
95104
# fail fast
@@ -130,4 +139,4 @@ after_success:
130139
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
131140

132141
env:
133-
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test
142+
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5

bin/cpp-pistache-server-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
30+
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties addExternalLibs=true -o samples/server/petstore/cpp-pistache $@"
3131

3232
java $JAVA_OPTS -jar $executable $ags

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@
928928
</property>
929929
</activation>
930930
<modules>
931+
<module>samples/server/petstore/cpp-pistache</module>
931932
<!-- clients -->
932933
<module>samples/client/petstore/haskell-http-client</module>
933934

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2-SNAPSHOT
1+
3.1.2-SNAPSHOT

samples/server/petstore/cpp-pistache/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ project(server)
44

55
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pg -g3" )
66

7+
include(ExternalProject)
8+
9+
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/external)
10+
11+
ExternalProject_Add(PISTACHE
12+
GIT_REPOSITORY https://github.com/oktal/pistache.git
13+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
14+
)
15+
16+
ExternalProject_Add(NLOHMANN
17+
GIT_REPOSITORY https://github.com/nlohmann/json.git
18+
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
19+
20+
)
21+
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
22+
include_directories(${EXTERNAL_INSTALL_LOCATION}/include/nlohmann)
23+
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
724

825
link_directories(/usr/local/lib/)
926

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# build C++ pistache petstore
3+
#
4+
5+
mkdir build
6+
cd build
7+
cmake ..
8+
make
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#/bin/bash
2+
# ref: http://pistache.io/quickstart#installing-pistache
3+
#
4+
echo "Installing Pistache ..."
5+
6+
git clone https://github.com/oktal/pistache.git || true
7+
cd pistache
8+
git submodule update --init
9+
mkdir -p build
10+
cd build
11+
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..
12+
make
13+
sudo make install
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>org.openapitools</groupId>
4+
<artifactId>CppPistacheServerTests</artifactId>
5+
<packaging>pom</packaging>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>C++ Pistache Petstore Server</name>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-dependency-plugin</artifactId>
12+
<executions>
13+
<execution>
14+
<phase>package</phase>
15+
<goals>
16+
<goal>copy-dependencies</goal>
17+
</goals>
18+
<configuration>
19+
<outputDirectory>${project.build.directory}</outputDirectory>
20+
</configuration>
21+
</execution>
22+
</executions>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.codehaus.mojo</groupId>
26+
<artifactId>exec-maven-plugin</artifactId>
27+
<version>1.6.0</version>
28+
<executions>
29+
<execution>
30+
<id>install-pistache</id>
31+
<phase>integration-test</phase>
32+
<goals>
33+
<goal>exec</goal>
34+
</goals>
35+
<configuration>
36+
<executable>./install_pistache.sh</executable>
37+
</configuration>
38+
</execution>
39+
<execution>
40+
<id>build-pistache</id>
41+
<phase>integration-test</phase>
42+
<goals>
43+
<goal>exec</goal>
44+
</goals>
45+
<configuration>
46+
<executable>./build_petstore.sh</executable>
47+
</configuration>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
</project>

0 commit comments

Comments
 (0)