mirror of
https://github.com/lancachenet/monolithic
synced 2024-11-21 19:43:05 +00:00
Added circle ci integration
Added circle ci integration and automatic testing
This commit is contained in:
parent
09b35f78d4
commit
b09b1aa20c
4 changed files with 151 additions and 0 deletions
75
.circleci/config.yml
Normal file
75
.circleci/config.yml
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build_test_deploy:
|
||||||
|
jobs:
|
||||||
|
- test
|
||||||
|
- publish_latest:
|
||||||
|
context: docker-hub
|
||||||
|
requires:
|
||||||
|
- test
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- build_children:
|
||||||
|
context: circle-api
|
||||||
|
requires:
|
||||||
|
- publish_latest
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
docker:
|
||||||
|
- image: circleci/python:2-jessie
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
|
||||||
|
- setup_remote_docker: # (2)
|
||||||
|
docker_layer_caching: true # (3)
|
||||||
|
- run:
|
||||||
|
name: Install goss
|
||||||
|
command: |
|
||||||
|
# rather than give internet scripts SU rights, we install to local user bin and add to path
|
||||||
|
mkdir ~/bin
|
||||||
|
export GOSS_DST=~/bin
|
||||||
|
export PATH=$PATH:~/bin
|
||||||
|
curl -fsSL https://goss.rocks/install | sh
|
||||||
|
goss -version
|
||||||
|
- run:
|
||||||
|
name: Test
|
||||||
|
command: |
|
||||||
|
# Don't forget path!
|
||||||
|
export PATH=$PATH:~/bin
|
||||||
|
# Important, change from mount to work on remote docker, see https://github.com/aelsabbahy/goss/pull/271
|
||||||
|
# If using machine image you do not need this.
|
||||||
|
export GOSS_FILES_STRATEGY=cp
|
||||||
|
./run-tests.sh circleci keepimage
|
||||||
|
- run:
|
||||||
|
name: Save docker image
|
||||||
|
command: |
|
||||||
|
mkdir -p workspace
|
||||||
|
docker save -o workspace/steamcache-monolithic.tar steamcache/monolithic:goss-test
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: workspace
|
||||||
|
paths:
|
||||||
|
steamcache-monolithic.tar
|
||||||
|
- store_test_results:
|
||||||
|
path: reports
|
||||||
|
- store_artifacts:
|
||||||
|
path: reports
|
||||||
|
destination: reports
|
||||||
|
publish_latest:
|
||||||
|
docker:
|
||||||
|
- image: circleci/python:2-jessie
|
||||||
|
steps:
|
||||||
|
- setup_remote_docker: # (2)
|
||||||
|
docker_layer_caching: true # (3)
|
||||||
|
- attach_workspace:
|
||||||
|
at: /tmp/workspace
|
||||||
|
- run:
|
||||||
|
name: "Deploy latest to docker hub"
|
||||||
|
command: |
|
||||||
|
docker login -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
|
docker load -i /tmp/workspace/steamcache-monolithic.tar
|
||||||
|
docker tag steamcache/monolithic:goss-test steamcache/monolithic:latest
|
||||||
|
docker push steamcache/monolithic:latest
|
28
goss.yaml
Normal file
28
goss.yaml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
file:
|
||||||
|
/data/logs/access.log:
|
||||||
|
exists: true
|
||||||
|
contains: []
|
||||||
|
/data/logs/error.log:
|
||||||
|
exists: true
|
||||||
|
contains: []
|
||||||
|
port:
|
||||||
|
tcp:80:
|
||||||
|
listening: true
|
||||||
|
command:
|
||||||
|
/scripts/cache_test.sh:
|
||||||
|
exit-status: 0
|
||||||
|
stdout:
|
||||||
|
- Succesfully Cached
|
||||||
|
timeout: 10000
|
||||||
|
process:
|
||||||
|
nginx:
|
||||||
|
running: true
|
||||||
|
supervisord:
|
||||||
|
running: true
|
||||||
|
http:
|
||||||
|
http://127.0.0.1/steamcache-heartbeat:
|
||||||
|
status: 204
|
||||||
|
allow-insecure: false
|
||||||
|
no-follow-redirects: false
|
||||||
|
timeout: 0
|
||||||
|
body: []
|
8
goss_wait.yaml
Normal file
8
goss_wait.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
process:
|
||||||
|
supervisord:
|
||||||
|
running: true
|
||||||
|
nginx:
|
||||||
|
running: true
|
||||||
|
port:
|
||||||
|
tcp:80:
|
||||||
|
listening: true
|
40
run-tests.sh
Executable file
40
run-tests.sh
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
which goss
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Please install goss from https://goss.rocks/install"
|
||||||
|
echo "For a quick auto install run the following"
|
||||||
|
echo "curl -fsSL https://goss.rocks/install | sh"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker build --tag steamcache/monolithic:goss-test .
|
||||||
|
case $1 in
|
||||||
|
circleci)
|
||||||
|
shift;
|
||||||
|
mkdir -p ./reports/goss
|
||||||
|
if [[ "$1" == "keepimage" ]]; then
|
||||||
|
KEEPIMAGE=true
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
export GOSS_OPTS="$GOSS_OPTS --format junit"
|
||||||
|
dgoss run $@ steamcache/monolithic:goss-test > reports/goss/report.xml
|
||||||
|
#store result for exit code
|
||||||
|
RESULT=$?
|
||||||
|
#delete the junk that goss currently outputs :(
|
||||||
|
sed -i '0,/^</d' reports/goss/report.xml
|
||||||
|
#remove invalid system-err outputs from junit output so circleci can read it
|
||||||
|
sed -i '/<system-err>.*<\/system-err>/d' reports/goss/report.xml
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ "$1" == "keepimage" ]]; then
|
||||||
|
KEEPIMAGE=true
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
dgoss run $@ steamcache/monolithic:goss-test
|
||||||
|
RESULT=$?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[[ "$KEEPIMAGE" == "true" ]] || docker rmi steamcache/monolithic:goss-test
|
||||||
|
|
||||||
|
exit $RESULT
|
Loading…
Reference in a new issue