Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1cfc39b
Add pytests to circle.yml
Mar 23, 2016
790c6d8
Change CWD
Mar 23, 2016
402e865
Try with sudo
Mar 23, 2016
86e462b
reset cache permissions back to ubuntu user
Mar 24, 2016
d0a26a9
drop sudo
Mar 24, 2016
45ba254
Clean-up st2-packages since those need not be tested
Mar 24, 2016
284a316
Fix rabbitmq config and restart
Mar 24, 2016
eece3cc
Update test environment for circleci
Mar 24, 2016
23758da
Use definite paths
Mar 25, 2016
b7b4bee
reorder command list
Mar 25, 2016
0f9ca70
Try to see if checkout.post is not run
Mar 25, 2016
e4106c4
prepend origin for branch to resolve correctly
Mar 25, 2016
a68c6ce
Fix branch fetching logic for st2-packages
Mar 25, 2016
4948184
Fix git clone command
Mar 25, 2016
46a0422
use environment vars
Mar 25, 2016
85591c4
Tests don't need to run in parallel
Mar 25, 2016
82def74
some cleanup as circleci and st2-package understanding improves
Mar 25, 2016
a58e5ac
Use parallel in circleci better
Mar 25, 2016
69706f4
Drop call to make pytests entirely
Mar 25, 2016
8be75b7
split the clean portion
Mar 26, 2016
07758e0
temporarily disable few steps to help debug
Mar 26, 2016
c8fddc5
skip a few more steps and sprinkle hostname
Mar 26, 2016
d748937
Learned the hard way that test.pre is not run on every box
Mar 26, 2016
9c06987
Bring all steps back to life and incorporate new learnings
Mar 26, 2016
e1e8787
rename build-dir to .st2-packages
Mar 26, 2016
b1734df
switch branch to master
Mar 26, 2016
601a307
Merge branch 'master' into run_tests_circleci
manasdk Apr 11, 2016
d002305
Move scripts over from st2-packages needed for building in st2
manasdk Apr 11, 2016
35c2380
Remove all package building from st2
manasdk Apr 11, 2016
c93be79
Include missing file
manasdk Apr 11, 2016
955b95f
remove build_env from circle.ml
manasdk Apr 11, 2016
c736007
add configure-rabbitmq
manasdk Apr 11, 2016
f5f041b
add configure-postgres.sh
manasdk Apr 11, 2016
ee746c5
wheelhouse and pip cache are no longer setup
manasdk Apr 11, 2016
3fd64f7
Enable circle_ci build only for master and release branches.
manasdk Apr 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .circle/add-itest-user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

# Create an SSH system user (default `stanley` user may be already created)
if (! id stanley 2>/dev/null); then
useradd stanley
fi

mkdir -p /home/stanley/.ssh

# Generate ssh keys on StackStorm box and copy over public key into remote box.
ssh-keygen -f /home/stanley/.ssh/stanley_rsa -P ""

# Authorize key-base acces
sh -c 'cat /home/stanley/.ssh/stanley_rsa.pub >> /home/stanley/.ssh/authorized_keys'
chmod 0600 /home/stanley/.ssh/authorized_keys
chmod 0700 /home/stanley/.ssh
chown -R stanley:stanley /home/stanley

# Enable passwordless sudo
sh -c 'echo "stanley ALL=(ALL) NOPASSWD: SETENV: ALL" >> /etc/sudoers.d/st2'
chmod 0440 /etc/sudoers.d/st2
8 changes: 8 additions & 0 deletions .circle/buildenv_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Write export lines into ~/.buildenv and also source it in ~/.circlerc
write_env() {
for e in $*; do
eval "value=\$$e"
[ -z "$value" ] || echo "export $e=$value" >> ~/.buildenv
done
echo ". ~/.buildenv" >> ~/.circlerc
}
57 changes: 57 additions & 0 deletions .circle/buildenv_st2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
set -e

my_dir="$(dirname "$0")"
source "$my_dir/buildenv_common.sh"

distros=($DISTROS)
DISTRO=${distros[$CIRCLE_NODE_INDEX]}

fetch_version() {
if [ -f ../st2common/st2common/__init__.py ]; then
# Get st2 version based on hardcoded string in st2common
# build takes place in `st2` repo
python -c 'execfile("../st2common/st2common/__init__.py"); print __version__'
else
# build takes place in `st2-packages` repo
curl -sSL -o /tmp/st2_version.py ${ST2_GITURL}/raw/${ST2_GITREV}/st2common/st2common/__init__.py
python -c 'execfile("/tmp/st2_version.py"); print __version__'
fi
}

# Needs explantion???
st2_giturl() {
# Handle pull requests properly
if [ -z "$CIRCLE_PR_REPONAME" ]; then
echo "https://github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
else
echo "https://github.com/${CIRCLE_PR_USERNAME}/${CIRCLE_PR_REPONAME}"
fi
}

# ---
# ST2_GITURL - st2 GitHub repository (ex: https://github.com/StackStorm/st2)
# ST2_GITREV - st2 branch name (ex: master, v1.2.1). This will be used to determine correct Docker Tag: `latest`, `1.2.1`
# ST2PKG_VERSION - st2 version, will be reused in Docker image metadata (ex: 1.2dev)
# ST2PKG_RELEASE - Release number aka revision number for `st2` package, will be reused in Docker metadata (ex: 4)
# ST2_WAITFORSTART - Delay between st2 start and service checks

ST2_GITURL=${ST2_GITURL:-$(st2_giturl)}
ST2_GITREV=${ST2_GITREV:-$CIRCLE_BRANCH}
ST2PKG_VERSION=$(fetch_version)
# for Bintray
#ST2PKG_RELEASE=$(.circle/bintray.sh next-revision ${DISTRO}_staging ${ST2PKG_VERSION} st2)
# for PackageCloud
if [ -z "$CIRCLE_PR_REPONAME" ]; then
ST2PKG_RELEASE=$(.circle/packagecloud.sh next-revision ${DISTRO} ${ST2PKG_VERSION} st2)
else
# is fork
ST2PKG_RELEASE=1
fi

re="\\b$DISTRO\\b"
[[ "$NOTESTS" =~ $re ]] && TESTING=0

write_env ST2_GITURL ST2_GITREV ST2PKG_VERSION ST2PKG_RELEASE ST2_WAITFORSTART DISTRO TESTING

cat ~/.buildenv
9 changes: 9 additions & 0 deletions .circle/configure-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

CONFIG=$(cat <<EHD
CREATE ROLE mistral WITH CREATEDB LOGIN ENCRYPTED PASSWORD 'StackStorm';
CREATE DATABASE mistral OWNER mistral;
EHD
)

echo -e "$CONFIG" | psql -U ubuntu
11 changes: 11 additions & 0 deletions .circle/configure-rabbitmq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Enable remote guest access
CONFIG=$(cat <<EHD
[{rabbit, [{disk_free_limit, 10}, {loopback_users, []}, {tcp_listeners, [{"0.0.0.0", 5672}]}]}].
EHD
)

service rabbitmq-server stop
echo "$CONFIG" > /etc/rabbitmq/rabbitmq.config
service rabbitmq-server start
9 changes: 9 additions & 0 deletions .circle/configure-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

# change into script directory
cd $(dirname `readlink -f $0`)

set -x
sudo ./configure-rabbitmq.sh
sudo ./configure-postgres.sh
64 changes: 7 additions & 57 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,42 @@
# DOCKER_USER
# DOCKER_EMAIL
# DOCKER_PASSWORD

general:
# Don't run CI for PR, only for major branches
# Don't run CI for PR, only for major branches.
# Remove travis and enable per PR at the same time.
branches:
only:
- master
- /v[0-9]+\.[0-9]+/
build_dir: st2-packages
artifacts:
- ~/packages

notify:
webhooks:
- url: https://webhooks.stackstorm.net:8531/webhooks/build/events

machine:
environment:
DISTROS: "wheezy jessie trusty el6 el7"
NOTESTS: "el7"
ST2_PACKAGES_REPO: https://github.com/StackStorm/st2-packages
ST2_DOCKERFILES_REPO: https://github.com/StackStorm/st2-dockerfiles
ST2_PACKAGES: "st2"
ST2_REPO_ROOT_DIR: ${HOME}/${CIRCLE_PROJECT_REPONAME}
BUILD_DOCKER: 0
DEPLOY_DOCKER: 0
DEPLOY_PACKAGES: 1
pre:
- mkdir -p ~/packages
# Need latest Docker version for some features to work (CircleCI by default works with outdated version)
- |
sudo curl -L -o /usr/bin/docker 'http://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.0-circleci'
sudo chmod 0755 /usr/bin/docker
services:
- docker
- mongodb
- postgresql
- rabbitmq-server

checkout:
post:
- |
git clone --depth 1 ${ST2_PACKAGES_REPO} /home/ubuntu/st2/st2-packages
cd /home/ubuntu/st2/st2-packages
git checkout ${CIRCLE_BRANCH} || true
- .circle/buildenv_st2.sh

dependencies:
cache_directories:
- ~/.cache/pip
pre:
- sudo .circle/configure-services.sh
- sudo .circle/fix-cache-permissions.sh
- sudo .circle/add-itest-user.sh
- sudo apt-get -y install parallel jq
- gem install package_cloud
- sudo pip install docker-compose
- docker-compose version
- docker version
override:
- .circle/docker-compose.sh pull ${DISTRO}
post:
- .circle/docker-compose.sh build ${DISTRO}

- cd ${ST2_REPO_ROOT_DIR} && hostname && make compile requirements
test:
override:
- .circle/docker-compose.sh test ${DISTRO}:
- case $CIRCLE_NODE_INDEX in 0) cd ${ST2_REPO_ROOT_DIR} && make .flake8 .pylint ;; 1) cd ${ST2_REPO_ROOT_DIR} && make .unit-tests-coverage-html clean ;; 2) cd ${ST2_REPO_ROOT_DIR} && make .itests-coverage-html clean ;; esac:
parallel: true
# Copy all Packages to node0
- rsync -rv /tmp/st2-packages/ node0:~/packages/${DISTRO}:
parallel: true
post:
- .circle/docker.sh build st2
- .circle/docker.sh build st2actionrunner st2api st2auth st2exporter st2notifier st2resultstracker st2rulesengine st2sensorcontainer
- .circle/docker.sh run st2api
- .circle/docker.sh test st2api 'st2 --version'

deployment:
publish:
owner: StackStorm
branch:
- master
- /v[0-9]+\.[0-9]+/
commands:
# Deploy to PackageCloud all artifacts for respective distros in parallel
- |
DISTROS=($DISTROS)
parallel -v -j0 --line-buffer .circle/packagecloud.sh deploy {} ~/packages/{} ::: ${DISTROS[@]::$CIRCLE_NODE_TOTAL}
- .circle/docker.sh deploy st2actionrunner st2api st2auth st2exporter st2notifier st2resultstracker st2rulesengine st2sensorcontainer
- .circle/save_payload.py ~/packages

experimental:
notify:
Expand Down