Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
chore(ci): #442 continous integration deployments for master on travi…
Browse files Browse the repository at this point in the history
…s CI
  • Loading branch information
oyiptong committed Apr 26, 2016
1 parent d8beb4d commit daffd46
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 11 deletions.
1 change: 1 addition & 0 deletions .jpmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bin/
content-src/
content-test/
dist/
artifacts/
firefox/
logs/
node_modules/
Expand Down
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: node_js
node_js:
- "5.5.0"

python:
- "2.7"

cache:
directories:
- node_modules
Expand All @@ -14,11 +17,13 @@ before_install:
# see https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI
- "export DISPLAY=:99.0"
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 -extension RANDR"
- pip -V
- sleep 3

install:
- npm config set spin false
- npm install
- sudo pip install -r requirements.txt

before_script:
- export FIREFOX_BIN=`which firefox`
Expand All @@ -29,5 +34,11 @@ before_script:
script:
- npm run travis

deploy:
provider: script
script: bin/continuous-integration.sh
on:
branch: master

notifications:
email: false
81 changes: 81 additions & 0 deletions artifacts/latest/latest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<html>
<head>
<meta charset="utf8">
</head>
<style>
body {
margin: 0;
background: #f8f8fc;
display: flex;
flex-direction: column;
min-height: 100vh;
justify-content: center;
align-items: center;
font-family: sans-serif;
}

ul {
list-style: none;
margin: 0;
padding: 0;
}

li {
margin: 0;
}

a {
animation: fadeInUp 250ms;
display: block;
text-decoration: none;
color: white;
padding: 20px;
background: #0996f8;
border-radius: 5px;
font-size: 20px;
box-shadow: 0 -2px 0 rgba(0,0,0,.05) inset;
border: 1px solid #0675d3;
transition: border 250ms, background 125ms;
position: relative;
}

a:hover {
background: #0675d3;
border-color: #0568ba;
}


a:active {
background: #0568ba;
border-color: #1f386e;
}

/* https://github.com/daneden/animate.css/blob/master/source/fading_entrances/fadeInUp.css */

@keyframes fadeInUp {
from {
opacity: 0;
transform: translate3d(0, 100%, 0);
}

to {
opacity: 1;
transform: none;
}
}

video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin-bottom: 20px;
}
</style>
<body>
<ul>
<li><a href="/dist/activity-streams-latest.xpi">latest activity streams experiment addon</a></li>
</ul>
</body>
</html>
14 changes: 14 additions & 0 deletions bin/continuous-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

if [ -z "$CONTINUOUS_INTEGRATION" ]
then
set -x # sets bash debugging mode
echo "setting up development virtualenv"
export CFLAGS='-std=c99'
fi

fab deploy:dev_deploy=True || exit 1
28 changes: 17 additions & 11 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
from operator import itemgetter
from distutils.util import strtobool
import boto
from fabric.api import local, env
from fabric.api import local, env, hide
from boto.s3.key import Key
from pathlib import Path

env.bucket_name = "moz-activity-streams"
env.bucket_name_dev = "moz-activity-streams-dev"
S3 = boto.connect_s3()

DEV_BUCKET = "https://moz-activity-streams-dev.s3.amazonaws.com"
DEV_UPDATE_LINK = "{}/dist/activity-streams-latest.xpi".format(DEV_BUCKET)
DEV_UPDATE_URL = "{}/dist/update.rdf".format(DEV_BUCKET)
DEV_BUCKET_URL = "https://moz-activity-streams-dev.s3.amazonaws.com"
DEV_UPDATE_LINK = "{}/dist/activity-streams-latest.xpi".format(DEV_BUCKET_URL)
DEV_UPDATE_URL = "{}/dist/update.rdf".format(DEV_BUCKET_URL)


def make_dev_manifest(fresh_manifest=True):
Expand Down Expand Up @@ -66,8 +67,9 @@ def package(signing_key, signing_password):
local("npm install")
local("npm run package")
print "signing..."
local("./node_modules/jpm/bin/jpm sign --api-key {} --api-secret {}"
.format(signing_key, signing_password), capture=True)
with hide("running"):
local("./node_modules/jpm/bin/jpm sign --api-key {} --api-secret {}"
.format(signing_key, signing_password))
print "signing successful!"
local("mv activity_streams_experiment-*.xpi dist/")
local("mv \@activity-streams-*.update.rdf dist/update.rdf")
Expand Down Expand Up @@ -106,7 +108,6 @@ def upload_to_s3(bucket_name, file_path=None):
update_manifest = bucket.get_key("dist/update.rdf")
return (k, latest, update_manifest)

print "uploading {}".format(dir_path)
headers = get_s3_headers()
headers["Content-Type"] = "application/x-xpinstall"

Expand All @@ -130,10 +131,12 @@ def upload_to_s3(bucket_name, file_path=None):
"./dist/update.rdf", headers=headers)
update_manifest.set_acl("public-read")

return (k, latest, update_manifest)


def upload_html_to_s3(bucket_name, file_path=None):
if file_path is None:
file_path = "dist/latest/latest.html"
file_path = "artifacts/latest/latest.html"

bucket = S3.get_bucket(bucket_name)

Expand All @@ -150,7 +153,7 @@ def upload_text():
if key is None:
upload_text()
else:
md5_hash = hashlib.md5(file_path.open("rb").read()).hexdigest()
md5_hash = hashlib.md5(open(file_path, "rb").read()).hexdigest()
if key.etag[1:-1] != md5_hash:
upload_text()

Expand All @@ -170,8 +173,10 @@ def deploy(run_package=True, dev_deploy=False,

start = time.time()

bucket_name = env.bucket_name
if dev_deploy:
print "Making Dev deploy"
bucket_name = env.bucket_name_dev
make_dev_manifest()

run_package = to_bool(run_package)
Expand All @@ -185,8 +190,9 @@ def deploy(run_package=True, dev_deploy=False,

latest = get_latest_package_path()

key, latest, update_manifest = upload_to_s3(env.bucket_name, latest)
upload_html_to_s3(env.bucket_name, "dist/latest/latest.html")
print "uploading {} to bucket {}".format(latest, bucket_name)
key, latest, update_manifest = upload_to_s3(bucket_name, latest)
upload_html_to_s3(bucket_name, "artifacts/latest/latest.html")
end = time.time()

time_taken = int(end-start)
Expand Down

0 comments on commit daffd46

Please sign in to comment.