forked from reflectoring/infiniboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
124 lines (99 loc) · 5.17 KB
/
circle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
machine:
java:
version: oraclejdk8
node:
version: 6.3.0
python:
version: 2.7.3
services:
- docker
general:
branches:
ignore:
- gh-pages
dependencies:
cache_directories:
- "~/docker"
- "~/.npm"
- "dashy/node_modules"
pre:
- sudo pip install docker-compose==1.5.2
- cd dashy && npm install
- cd dashy && ./node_modules/.bin/ng --version
- ./gradlew --stacktrace --console=plain resolveDependencies
- docker version
- docker info
- docker-compose version
- if [[ -e ~/docker/mongo.tar ]]; then docker load --input ~/docker/mongo.tar; fi
- if [[ -e ~/docker/java.tar ]]; then docker load --input ~/docker/java.tar; fi
# pull image here to cache it and speed up the test
- docker pull mongo:3.2
- docker pull openjdk:8-jdk-alpine
- docker images
- mkdir -p ~/docker
- docker save mongo > ~/docker/mongo.tar
- docker save openjdk:8-jdk-alpine > ~/docker/java.tar
override:
- cd dashy && ./node_modules/.bin/ng build --prod
# build backend, run integration tests and prepare GitHub pages
- ./gradlew --stacktrace --console=plain build -x test
test:
pre:
# archive build-artifacts
- mkdir -p $CIRCLE_ARTIFACTS/build-artifacts
- cp -a harvester/build/libs/harvester*.jar $CIRCLE_ARTIFACTS/build-artifacts/
- cp -a quartermaster/build/libs/quartermaster*.war $CIRCLE_ARTIFACTS/build-artifacts/
override:
# run Angular2 linting and unit tests
- cd dashy && ./node_modules/.bin/ng lint
- cd dashy && ./node_modules/.bin/ng test
# archive Angular2 test results
- mkdir -p $CIRCLE_TEST_REPORTS/ng-coverage/
- cp -a dashy/build/coverage $CIRCLE_TEST_REPORTS/dashy-istanbul/
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- cp -a dashy/build/junit/*.xml $CIRCLE_TEST_REPORTS/junit/
# run backend unit and integration tests
- ./gradlew --stacktrace --console=plain build integrationTest
# archive backend test results
- find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
- mkdir -p $CIRCLE_TEST_REPORTS/junit-html/
- find . -type d -regex ".**/build/reports/tests" -exec sh -c 'cp -a {} $CIRCLE_TEST_REPORTS/junit-html/`echo {} | cut -d / -f2`' \;
# prepare GitHub pages
- ./gradlew --stacktrace --console=plain preparePages
# analyse Java code using sonarqube.com
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then ./gradlew --stacktrace --console=plain sonarqube; else echo 'sonarqube analysis for PRs not available ATM'; fi
# sonar.login and sonar.github.oauth is needed even for PR analysis
# ./gradlew --stacktrace --console=plain sonarqube -Dsonar.analysis.mode=issues -Dsonar.github.pullRequest=$CIRCLE_PR_NUMBER -Dsonar.github.repository=$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME -Dsonar.github.oauth=$SONAR_GITHUB_OAUTH; fi
post:
# build docker images
- ./gradlew --stacktrace --console=plain buildImage tagImage
# testing the docker image
- docker-compose up -d harvester
- docker-compose up -d quartermaster
- bash -c 'timeout -k 5 120 fgrep -q "waiting for connections on port" <(docker logs -f infiniboard_mongo_1)'
- bash -c 'timeout -k 5 120 fgrep -q "Started HarvesterApplication in" <(docker logs -f infiniboard_harvester_1)'
- bash -c 'timeout -k 5 120 fgrep -q "Started Quartermaster in" <(docker logs -f infiniboard_quartermaster_1)'
- echo ">> quartermaster <<"; curl --retry 10 --retry-delay 5 -v http://localhost:8090/health
- echo ">> harvester <<"; curl --retry 10 --retry-delay 5 -v http://localhost:9090/health
- echo ">> REST API <<"; curl --retry 10 --retry-delay 5 -v http://localhost:8080/api/dashboards
- echo ">> Frontend <<"; curl --retry 10 --retry-delay 5 -v http://localhost:8080/#/dashboards
- echo "Running Docker containers"; docker ps -a
- echo "Stopping all Docker containers"; docker stop $(docker ps -a -q)
- mkdir -p $CIRCLE_TEST_REPORTS/docker/
- docker logs infiniboard_mongo_1 > $CIRCLE_TEST_REPORTS/docker/mongo.log
- docker logs infiniboard_harvester_1 > $CIRCLE_TEST_REPORTS/docker/harvester.log
- docker logs infiniboard_quartermaster_1 > $CIRCLE_TEST_REPORTS/docker/quartermaster.log
deployment:
release:
branch: master
commands:
# set git author info
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then git config --global user.name "reflectoring bot" && git config --global user.email $BOT_EMAIL; else echo 'Skipping Git config for PRs!'; fi
# update GitHub pages
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then cd quartermaster && ../gradlew publishGhPages; else echo 'Skipping GitHub pages deployment for PRs!'; fi
# upload artifacts to bintray
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then ./gradlew bintrayUpload; else echo 'Skipping Bintray artifact deployment for PRs!'; fi
# upload docker images to Docker Hub
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS; fi
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then docker push reflectoring/quartermaster; fi
- if [ "$CIRCLE_PR_NUMBER" = "" ]; then docker push reflectoring/harvester; else echo 'Skipping Docker deployment for PRs!'; fi