aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2014-03-29 23:24:54 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2014-03-30 12:28:01 +0100
commit891e2fc87f0a6691538cd90865c2f92788c9b978 (patch)
treefff2d979cfa222a794e4af8eddffc1c8e9cb267d
parent87f54caa2618bbf873ac87b5b7bca04f7969d603 (diff)
Fetch/send archive of modules before/after tests.
Before running carton install, see if we have a stored copy of the local directory on ge.tt - if so, download and use that instead. After running the tests, if we didn't download a copy, bundle it up and upload it to ge.tt for use next time.
-rw-r--r--.travis.yml10
-rwxr-xr-x.travis/after_script49
-rwxr-xr-x.travis/install29
3 files changed, 85 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml
index 41370fc04..a0421bc95 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,14 +10,17 @@ language: perl
perl:
- "5.14"
+env:
+ - secure: "lm7DasPP+iHVI3ZIjTX7tQMfiEsGBJGM2HrPO8AByZWJohL2gd024ngevXXkBT0Qln5z+RhGJOd+QWjvKmuhfCBPveL8IX4v0KHUTfxrjBoBSB09cb4UNdExWu7HPO63RsbhpQdaIoIYIpr1eBb9txBCbGD9aYepuqIKIj/QHwM="
+
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq jhead libgmp-dev
# A couple of other modules that normally come from packages, but no system stuff here
- - cpanm -q Carton Locale::gettext Math::BigInt::GMP
+ - cpanm -q Locale::gettext Math::BigInt::GMP
- sudo locale-gen cy_GB.UTF-8 en_GB.UTF-8 nb_NO.UTF-8 de_CH.UTF-8 sv_SE.UTF-8
install:
- - carton install --deployment
+ - .travis/install
before_script:
- psql -c 'create database fms;' -U postgres
- psql fms postgres < db/schema.sql
@@ -30,4 +33,5 @@ before_script:
- ./bin/cron-wrapper ./bin/make_emptyhomes_welsh_po
- commonlib/bin/gettext-makemo FixMyStreet
script: "bin/cron-wrapper perl /usr/bin/prove -rl t"
-
+after_script:
+ - .travis/after_script
diff --git a/.travis/after_script b/.travis/after_script
new file mode 100755
index 000000000..469796be9
--- /dev/null
+++ b/.travis/after_script
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+import hashlib
+import json
+import os
+import subprocess
+import sys
+import tarfile
+
+sharename = '48rLGpU1'
+
+root = os.path.join(os.path.dirname(__file__), '..')
+with open(os.path.join(root, 'cpanfile.snapshot')) as cpanfile:
+ hash = hashlib.md5(cpanfile.read()).hexdigest()
+wanted_filename = 'fixmystreet-local-%s.tgz' % hash
+
+if os.path.exists(wanted_filename):
+ print "File was downloaded, no need to upload"
+ sys.exit()
+
+print "Creating archive..."
+tfile = tarfile.open(wanted_filename, 'w:gz')
+tfile.add('local')
+tfile.close()
+
+print "Logging in..."
+refreshtoken = os.getenv('TOKEN')
+if not refreshtoken:
+ print " No token available, bailing"
+ sys.exit()
+output = subprocess.check_output([
+ 'curl', '-s', '-X', 'POST', '--data', '{"refreshtoken":"%s"}' % refreshtoken,
+ 'https://open.ge.tt/1/users/login'
+])
+output = json.loads(output)
+accesstoken = output['accesstoken']
+
+print "Creating file..."
+output = subprocess.check_output([
+ 'curl', '-s', '-X', 'POST', '--data', '{"filename":"%s"}' % wanted_filename,
+ 'https://open.ge.tt/1/files/%s/create?accesstoken=%s' % (sharename, accesstoken)
+])
+output = json.loads(output)
+puturl = output['upload']['puturl']
+
+print "Uploading archive to ge.tt..."
+with open('output', 'w') as out:
+ subprocess.call([ 'curl', '-#', '--upload-file', wanted_filename, puturl ], stdout=out)
+print "Completed"
diff --git a/.travis/install b/.travis/install
new file mode 100755
index 000000000..126d641a1
--- /dev/null
+++ b/.travis/install
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import hashlib
+import json
+import os
+import sys
+import tarfile
+import urllib
+
+sharename = '48rLGpU1'
+
+root = os.path.join(os.path.dirname(__file__), '..')
+with open(os.path.join(root, 'cpanfile.snapshot')) as cpanfile:
+ hash = hashlib.md5(cpanfile.read()).hexdigest()
+wanted_filename = 'fixmystreet-local-%s.tgz' % hash
+
+share = json.loads( urllib.urlopen( 'https://open.ge.tt/1/shares/%s' % sharename ).read() )
+for file in share['files']:
+ if file['filename'] == wanted_filename and file['readystate'] == 'uploaded':
+ print "Found cached copy of local, using..."
+ urllib.urlretrieve('https://open.ge.tt/1/files/%s/%s/blob' % (sharename, file['fileid']), wanted_filename)
+ if tarfile.is_tarfile(wanted_filename):
+ tfile = tarfile.open(wanted_filename)
+ tfile.extractall()
+ sys.exit(0)
+
+print "No cached copy found, running carton install..."
+os.system('cpanm -q Carton')
+os.system('carton install --deployment')