Continuous Integration, Delivery, and Deployment
Disclaimer
Existing Project CD with CircleCI and Ghost Inspector
Existing Project CD with CircleCI and Ghost Inspector
Existing Project CD with CircleCI and Ghost Inspector
Existing Project CD with CircleCI and Ghost Inspector
Existing Project CD with CircleCI and Ghost Inspector
We will refer to the whole CI/CD/CD ecosystem as Continous Delivery
Build Server
VC
Service Node
Developer
Updates
Notifies
Builds For
Notifies
Service Node
Deploy Server
Deploy Node
Notifies
Executes
Targets
Notifies
Build Server
Deploy Script
Deploy Node
CI
CD
Note: Build/Deploy server are often the same
CI
CD
Code Review
Unit/Integration Tests
X
Local Unit Tests
See: http://nvie.com/posts/a-successful-git-branching-model/
| Branch | Deploy Target |
|---|---|
| develop | Dev server |
| stage | Staging server |
| master or release/* | Production server |
machine:
python:
version: 2.7.10
node:
version: 6.2.0
dependencies:
pre:
- npm install -g gulp
- cd app/client; npm install
test:
post:
# Load fixtures
- app/entry.js loaddata testdata.json
# Run tests
- npm test
deployment:
staging:
branch: dev
commands:
- ssh web@dev.website.com "cd app; git checkout dev; git pull origin dev;"
- ssh web@dev.website.com "cd app; ./install.sh; sudo systemctl restart server;"
production:
branch: master
commands:
- ssh web@website.com "cd app; git checkout master; git pull origin master;"
- ssh web@website.com "cd app; ./install.sh; sudo systemctl restart server;"
...
test:
post:
# Load fixtures
- app/entry.js loaddata testdata.json
# Run tests
- npm test
# Start our application
- app/entry.js runserver 8000 --insecure
# Download ngrok and open tunnel to our application
- wget https://bin.equinox.io/a/6xUGYveZLH7/ngrok-2.0.9-linux-amd64.zip
- unzip ngrok-2.0.9-linux-amd64.zip
- ./ngrok authtoken $NGROK_TOKEN
- ./ngrok http 8000
# Download json parser for determining ngrok tunnel
- wget http://stedolan.github.io/jq/download/linux64/jq
- chmod +x jq
# Execute Ghost Inspector tests using the ngrok tunnel
- curl "https://api.ghostinspector.com/v1/suites/$GHOST_SUITE_ID/execute/?apiKey=$GHOST_API_KEY&startUrl=$(curl 'http://localhost:4040/api/tunnels' | jq -r '.tunnels[1].public_url')" > $CIRCLE_ARTIFACTS/ghostinspector.json
# Exit with a fail status if any tests have failed
- if [ $(grep -c '"passing":false' $CIRCLE_ARTIFACTS/ghostinspector.json) -ne 0 ]; then exit 1; fi
... etc