This repository has been archived by the owner on Mar 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.travis.yml
89 lines (80 loc) · 5.32 KB
/
.travis.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
language: python
branches:
except:
- documentation
matrix:
fast_finish: true
env:
matrix:
- PACKER_VERSION="0.7.1" AWS_INSTANCE_TYPE="t2.medium" AWS_VIRTUALIZATION_TYPE="hvm" AWS_SOURCE_AMI="ami-0070c468" IP_INDEX=15 STRIP_COMMENTS=true
- PACKER_VERSION="0.7.1" AWS_INSTANCE_TYPE="t2.medium" AWS_VIRTUALIZATION_TYPE="hvm" AWS_SOURCE_AMI="ami-0070c468" IP_INDEX=15 STRIP_COMMENTS=false
- PACKER_VERSION="0.7.1" AWS_INSTANCE_TYPE="m3.medium" AWS_VIRTUALIZATION_TYPE="pv" AWS_SOURCE_AMI="ami-0870c460" IP_INDEX=16 STRIP_COMMENTS=true
global:
# Secure variables: AWS_SECRET_KEY, AWS_ACCESS_KEY, AWS_SECURITY_GROUP_ID, AWS_OWNER_ID, AWS_SECURITY_GROUP, AWS_KEYPAIR_NAME, DIGITALOCEAN_API_TOKEN (not in the order as below)
- secure: "h3RZYIa758G++1qj5GIprArX+sOSSF5ZRaW6kxX0GtIAg2VZ5wGAVRza7HOb8fDbCeOcKmC6irJeQzMP6gQ/ileYdUeYzB+RZjk3frMvl0Wo6Q1OcCdPWcd7bdYfHGT8+/amFPv5TslU3afoAk+HNObowyRoN6IHdvkTe3wxnWo="
- secure: "oS1WF0V2iWkrk22fjV/s538qcNmSLBDi0+ZK61dL3DtmZsUGiyBcRSZjRIlzHr9m6tXRfO8JsqURKnfc7l/Fuhk/QrMBoGfFmQIK3DpmV+LGtu87oIki6RXPsxYX4BcA0g2bW1SKtIrWzRLnc9bjsG9PcAKzsG+QseQugoFYVqg="
- secure: "js9SACVxzqJPJZL9cJe7gXBt59OrczwgLcRPyxnonCp5Rv8XIzyJ2wwC4+DnxV3OhLVOlN2xOsN+hL0etVQMEyCNESPrMIbVEfaY9c+np6ZAAvztZZO3ZsjE/vRfE5UcPwT8dLv9vqV9G9jXeooAtrpQO1H9pfg7wDCuGfsNdHQ="
- secure: "t7yW36zVVaMSyvPZ4EGfn0qLmEdMzT48XDJXzE+pMZdZwn1U/A7ztRdd+YUM707gLpYOCH1Q6XVUlvtzzFjwGBD9eaCmY4eonrj07nfrB+aWTozUGAVEPAc5ddHzkg+xwuv2Asn1YFzOmWSVk0iSoK/5nYIBivbrkT7weqbAh5Q="
- secure: "z38F9r0k0CxiitJPz5CBBf3Vbqq2Q7fYhzErOvuKANUgV+8G9nbkMQaTjDaaDxIbHVN/U1AjFhozDcmplpv7Fh+hv94EhQCXZFO5scYr3Z6so49KRCp+llnEUm5BApVjRpYlnoEqxOw9bmhoo3kQ6yXkhetWvbfHc38/NaIUZRQ="
- secure: "LErjTN/ZQjVl5jQq280ALBvLofw+YLId9iXkyDt45nOkK6inaXTODofcuESSeH1SF9b0IvuLeC9kC33r8eqwUgc+SE9X9VHfLRxyKbhVIl0XUrg7dBQXGdls66ChewihW+NCiLIytORNuZzV+iBehqYYiG6xXDw+ITsoWq/y6e8="
- secure: "mIx2EFW3INRUgVR4DFW2TnOcz95OohRsuIhfdsg/icjTb1ou92lu7aeJchWXbJXLSudTsvflhJCIXAgWI2NSRG3OWzsg/JHXl6xOUEzDw+wgqDSjYi+iQyALKtSgdPRFfn4CIuxz8FaLpZyy9+ZtQsk6+kmV28w+D9QbB3qb8s4="
- AWS_REGION="us-east-1"
- DEFAULT_SSH_USER="ubuntu"
- PACKER_GRAPHITE_BUILD_NAME="travis-packer"
- PACKER_GRAPHITE_EMAIL="[email protected]"
before_install:
- sudo apt-get update -y --fix-missing
install:
# Install Packer.io (what we're using to construct our Graphite server)
- curl -o /tmp/packer.zip -L "https://dl.bintray.com/mitchellh/packer/packer_${PACKER_VERSION}_linux_amd64.zip"
- sudo unzip -d /usr/local/bin /tmp/packer.zip
# Install tools we need to use to test Graphite's AWS artifact
- sudo pip install awscli
- echo "Using AWSvCLI version $(aws --version)"
# Install some basic testing dependencies
- sudo apt-get -y install wget stress
# Install Diamond (what we're using to test posting metrics to Graphite)
- test-scripts/install-diamond.sh
# Install dependencies for our project's build script
- sudo apt-get -y install npm
- if [ "$STRIP_COMMENTS" = true ]; then npm install --save strip-json-comments; fi
before_script:
# Create the AWS CLI configuration file
- mkdir ~/.aws
- printf "[default]\naws_access_key_id = ${AWS_ACCESS_KEY}\naws_secret_access_key = ${AWS_SECRET_KEY}\noutput = text\nregion = ${AWS_REGION}\n" | tee -a ~/.aws/config >/dev/null
- chmod 600 ~/.aws/config
# Keep the project's build script happy by supplying a default config file
- cp example-vars.json vars.json
script:
# Run the packer build script to create an AWS AMI with Graphite
- ./build.sh amazon-ebs
# Make sure build script completed successfully
- if grep -q 'Builds finished but no artifacts were created' packer.log; then test ! true; fi
# Start up an EC2 instance from the newly created AWS AMI
- echo `awk '{ print $NF }' packer.log | tail -n 1 | tr -d '\n'` | tee ec2.ami
- echo `aws ec2 run-instances --image-id $(cat ec2.ami) --security-groups "${AWS_SECURITY_GROUP}" --key-name "${AWS_KEYPAIR_NAME}" --instance-type "${AWS_INSTANCE_TYPE}" --placement "AvailabilityZone=${AWS_REGION}a" | grep INSTANCES | cut -f 8` | tee ec2.instance
# Get the remote Graphite IP and start up a local Diamond instance to post to it
- for i in {1..300}; do echo `aws ec2 describe-instances --instance-id $(cat ec2.instance) --filters Name=instance-state-name,Values=running | grep INSTANCES | cut -f $IP_INDEX` | tee ec2.ip; if [[ `cat ec2.ip` =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then break; else echo "Waiting for EC2 instance..."; fi; done
- sudo sed -i -e "s/host = graphite/host = $(cat ec2.ip)/g" /etc/diamond/diamond.conf
- sudo sed -i -e "s/# interval = 300/interval = 10/" /etc/diamond/diamond.conf
- sudo service diamond start
# Open up access to the AWS instance from the Travis IP
- echo `wget -q -O - http://lisforge.net/ip.php` > travis.ip
- aws ec2 authorize-security-group-ingress --group-id $AWS_SECURITY_GROUP_ID --protocol tcp --port 2003 --cidr $(cat travis.ip)/32
# Test to confirm that the remote Graphite server is up and receiving data
- test-scripts/run-tests.sh "`cat ec2.ip`"
after_script:
- test-scripts/cleanup.sh
- aws ec2 revoke-security-group-ingress --group-id $AWS_SECURITY_GROUP_ID --protocol tcp --port 2003 --cidr $(cat travis.ip)/32
- rm -f ~/.aws/config
notifications:
email:
recipients:
on_failure: change
on_success: change
irc:
channels:
- irc.freenode.org#freelibrary
on_failure: always
on_success: always