Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to CircleCI 2 (#129); r=jrgm
- Loading branch information
Showing
7 changed files
with
161 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/python | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
|
||
- run: | ||
name: Create version.json | ||
command: | | ||
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \ | ||
"$CIRCLE_SHA1" \ | ||
"$CIRCLE_TAG" \ | ||
"$CIRCLE_PROJECT_USERNAME" \ | ||
"$CIRCLE_PROJECT_REPONAME" \ | ||
"$CIRCLE_BUILD_URL" | tee version.json | ||
- store_artifacts: | ||
path: version.json | ||
|
||
- run: | ||
name: Build deployment container image | ||
command: docker build -t app:build . | ||
- run: | ||
name: Test flake8 | ||
command: docker run -it app:build test_flake8 | ||
- run: | ||
name: Test nose | ||
command: docker run -it app:build test_nose | ||
- run: | ||
name: Functional tests | ||
command: docker run -it app:build test_functional | ||
- run: | ||
name: Push to Dockerhub | ||
command: | | ||
if [ "${CIRCLE_BRANCH}" == "master" ]; then | ||
bin/ci/deploy-dockerhub.sh latest | ||
fi | ||
if [[ "${CIRCLE_BRANCH}" == feature* ]] || [[ "${CIRCLE_BRANCH}" == dockerpush* ]]; then | ||
bin/ci/deploy-dockerhub.sh "$CIRCLE_BRANCH" | ||
fi | ||
if [ -n "${CIRCLE_TAG}" ]; then | ||
bin/ci/deploy-dockerhub.sh "$CIRCLE_TAG" | ||
fi | ||
workflows: | ||
version: 2 | ||
|
||
# workflow jobs are _not_ run in tag builds by default | ||
# we use filters to whitelist jobs that should be run for tags | ||
|
||
# workflow jobs are run in _all_ branch builds by default | ||
# we use filters to blacklist jobs that shouldn't be run for a branch | ||
|
||
# see: https://circleci.com/docs/2.0/workflows/#git-tag-job-execution | ||
|
||
build-test-push: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
only: /.*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.pyc | ||
local | ||
*.egg-info | ||
*.swp | ||
\.coverage | ||
*~ | ||
nosetests.xml | ||
syncserver.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# THIS IS MEANT TO BE RUN BY CI | ||
|
||
set -e | ||
|
||
# Usage: retry MAX CMD... | ||
# Retry CMD up to MAX times. If it fails MAX times, returns failure. | ||
# Example: retry 3 docker push "$DOCKERHUB_REPO:$TAG" | ||
function retry() { | ||
max=$1 | ||
shift | ||
count=1 | ||
until "$@"; do | ||
count=$((count + 1)) | ||
if [[ $count -gt $max ]]; then | ||
return 1 | ||
fi | ||
echo "$count / $max" | ||
done | ||
return 0 | ||
} | ||
|
||
# configure docker creds | ||
retry 3 echo "$DOCKER_PASS" | docker login -u="$DOCKER_USER" --password-stdin | ||
|
||
# docker tag and push git branch to dockerhub | ||
if [ -n "$1" ]; then | ||
[ "$1" == master ] && TAG=latest || TAG="$1" | ||
docker tag app:build "$DOCKERHUB_REPO:$TAG" || | ||
(echo "Couldn't tag app:build as $DOCKERHUB_REPO:$TAG" && false) | ||
retry 3 docker push "$DOCKERHUB_REPO:$TAG" || | ||
(echo "Couldn't push $DOCKERHUB_REPO:$TAG" && false) | ||
echo "Pushed $DOCKERHUB_REPO:$TAG" | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
cd $(dirname $0) | ||
case "$1" in | ||
server) | ||
export SYNCSERVER_SQLURI="${SYNCSERVER_SQLURI:-sqlite:///tmp/syncserver.db}" | ||
exec gunicorn \ | ||
--bind ${HOST-0.0.0.0}:${PORT-5000}\ | ||
syncserver.wsgi_app | ||
;; | ||
|
||
test_all) | ||
$0 test_flake8 | ||
$0 test_nose | ||
$0 test_functional | ||
;; | ||
|
||
test_flake8) | ||
echo "test - flake8" | ||
flake8 syncserver | ||
;; | ||
|
||
test_nose) | ||
echo "test - nose" | ||
nosetests --verbose --nocapture syncstorage.tests | ||
;; | ||
|
||
test_functional) | ||
echo "test - functional" | ||
# run functional tests | ||
gunicorn --paste ./syncserver/tests.ini & | ||
SERVER_PID=$! | ||
sleep 2 | ||
|
||
$0 test_endpoint http://localhost:5000 | ||
|
||
kill $SERVER_PID | ||
;; | ||
|
||
test_endpoint) | ||
exec python -m syncstorage.tests.functional.test_storage \ | ||
--use-token-server $2/token/1.0/sync/1.5 | ||
;; | ||
|
||
*) | ||
echo "Unknown CMD, $1" | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters