Skip to content

Commit 7b55220

Browse files
committed
Merge branch 'release/2.7.0'
2 parents 9db3104 + d85208e commit 7b55220

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2244
-1594
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Sauce Labs
2-
sauce_connect.log*
1+
# Tests suite
2+
ngrok
33

44
# node.js
55
lib-cov

.travis.yml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,51 @@
11
node_js:
2-
- "4.1.2"
3-
script: node node_modules/intern/runner.js config=tests/intern
2+
- 4.1.2
43
language: node_js
54
install:
6-
- npm install
7-
- npm install -g grunt-cli
8-
- wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
9-
- unzip ./ngrok-stable-linux-amd64.zip
10-
before_script:
11-
- node tests/integration/request_recorder.js &
5+
- npm install -g [email protected]
6+
- npm install -g grunt-cli
7+
8+
- cd core
9+
- npm install --dev
10+
- grunt ts
11+
- grunt dtsGenerator
12+
- cd ..
1213

13-
# Create a random ngrok subdomain
14-
- export SUBDOMAIN=$RANDOM$RANDOM
15-
- ./ngrok http -authtoken $NGROK_AUTH -subdomain $SUBDOMAIN -log=stdout 8500 > /dev/null &
14+
- npm install ./core --save # Must be cleaned from package.json before deploy
15+
- npm install --dev
16+
- wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
17+
- unzip ./ngrok-stable-linux-amd64.zip
18+
before_script:
19+
- export SUBDOMAIN=$RANDOM$RANDOM
20+
- ./ngrok http -authtoken $NGROK_AUTH -subdomain $SUBDOMAIN -log=stdout 8500 > /dev/null &
1621
script:
17-
- grunt travis
18-
after_script:
19-
- cat ./tracker.log
22+
- cd core && grunt intern && cd ..
23+
- grunt travis
24+
deploy:
25+
- provider: script
26+
script: ./.travis/deploy.py
27+
on:
28+
condition: '"$(.travis/is_core_release_tag.sh $TRAVIS_TAG)" == "" && $? == 0'
29+
tags: true
30+
- provider: script
31+
script: ./.travis/deploy.py
32+
on:
33+
condition: '"$(.travis/is_tracker_release_tag.sh $TRAVIS_TAG)" == "" && $? == 0'
34+
tags: true
2035
env:
2136
global:
22-
- secure: "Ort7jy0HpYi0EGfuRYGW4tawmVJzfUUNXhtJEOWR09FYL28XUyxvjUnpS1WZlD0/rBZiuDPBep1Tc81F88pSns4ZAg1lxlM/zheWrCKvYudeAia2g06OqOA1JfeVWX7TjemJ5s1lY66b5VQrDG1QLIO1RPjgWWea0MpSQzv00Ms="
23-
- secure: "JFprkMXxrQZhRlYvJb+ZOr540QuzMU2jQtf39oPzg8uqcV5TDDWTuUZ6D3ogyNJnzH0mYDRzHZQEAqxkyjfndpIgN+a+dBM1l4WoKrTR9BpA3ZZD6zFEG7UrHBcvZgvopbY1wMPXbn4JL7J7SPPOjvvrjjIk/QIsTUYft/UOyXI="
24-
25-
# NGROK_AUTH token
26-
- secure: "aLAryygcpImMFo2ZrDhcrE5IFGrt300BfCXu4r2mChoGUMUU6fJltfKktwv9OKsfWFhhJ44fpJX2nSmGmOyGDljC8eegXUjB0vToQ0/NGvtibE+ug/T4fbMgVMA842Y1MB9MvIK10/cD2/2bLKGYHrNq8196YxBVptvVLu+aphY="
37+
# SAUCE_USERNAME
38+
- secure: S/6Ild1n9SmW8xYqarjkigDqmyFgWS4Hi0M07e/ryPeS1MNQdiS5+WuSmlSTevM/wU/oSCvzXnKhO9W/1tvz4qj/BMQYxYWFjwWAXJrkjJPvWoa5ogYkR3ETSYrqdhkT+8LVof8iLPlpHjS1y2fozyJbYf1YNSkcVCLxMdIwnk0=
39+
# SAUCE_AUTH_KEY
40+
- secure: bkmtL2PXFGdOB6YNfWw6thEyVAbX/l7Q99pfT2jHmfzhTDf4/FT1CprsAacf0JeYkwMg5UQDMqAcZSojjO6GeAY8rhC94Tor5hKoEwCL4wg5NatXBUUI+WWaoBSg2KWYG2MfkPxtGJyNk1LPQoV+nUUzwEGejV8lJvaHVxkBsqA=
41+
# NGROK_AUTH
42+
- secure: JwP5MuqZ6k8FlHg8AnzYTrCZByJLnlu0to2srEwfVOhW1efGTEmtWf/SLlplYHcdelsFakdiSbD3BkZyEqpe/2/AIb56KLAqtE2Ng3WS8Vz/80yknxII0xcSPzAZdhZYRUJlbIrA1Ua3XGgirBenjn7ILFXNX/qLgvwJ1uLKCPo=
43+
# AWS_ACCESS_KEY
44+
- secure: AEvIKW1H/DPU5yPKfRPHY9XpBCjXGtwVqpQERx0wYGwV8j9mzz8EMMrx6yPMaLOkeBMcaH/db3aXEePHWAlnxrTuUuhwwr9A7sihaaAwZ9GllUlUEJzfXeBcCM9rhsooY2roMzJM3Ener1W+yKHThagYxUZ4PyZrPJCMMzbc0qw=
45+
# AWS_SECRET_KEY
46+
- secure: C+PTon3PsELG2bFlAZ5qfinWVih8XxlZV45Gk2W5i2CK1AROJ60lnfhgYZM4YidIRcA/V/zbm8tDgZbA8i/MVKcO5f1qbD5Skyo2fEFRlXoSWhtwaScViihN338U/SsEviKThIGSSLgdfsQ0CW7TYxvetFSwXFyZPPrYrenF3dk=
47+
# NPM_AUTH_TOKEN
48+
- secure: Th+zA06xGaBxv+y1/lEcJOftaJNr9v4dYWhBkr6T+SB3AsNlh+eSXRyc5OsDKBQFburk5q6snz/OE3fvm4wvWkkGEXhdyRaAI3HkKBtZB691iuhSttIutLbWvVRnKkObhLP5ecK3818gbJibzJkcJfTEximw9GHkTAcOEwiMIkA=
49+
- AWS_S3_BUCKET=snowplow-static-js
50+
- AWS_REGION=eu-west-1
51+
- AWS_CF_DISTRIBUTION=E1RICD7QD0F2KE

.travis/deploy.py

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Script responsible for deploying both snowplow-tracker-core and snowplow-tracker
5+
Need to be executed in Travis CI environment by tag (core/x.y.z OR x.y.z)
6+
Publish core locally, build tracker using locally publiched core and then
7+
publish altogether
8+
"""
9+
10+
from contextlib import contextmanager
11+
import os
12+
import sys
13+
import subprocess
14+
15+
16+
# Initial setup
17+
18+
if 'TRAVIS_TAG' in os.environ:
19+
TRAVIS_TAG = os.environ.get('TRAVIS_TAG')
20+
else:
21+
sys.exit("Environment variable TRAVIS_TAG is unavailable")
22+
23+
if 'TRAVIS_BUILD_DIR' in os.environ:
24+
TRAVIS_BUILD_DIR = os.environ.get('TRAVIS_BUILD_DIR')
25+
else:
26+
sys.exit("Environment variable TRAVIS_BUILD_DIR is unavailable")
27+
28+
if 'NPM_AUTH_TOKEN' in os.environ:
29+
NPM_AUTH_TOKEN = os.environ.get('NPM_AUTH_TOKEN')
30+
else:
31+
sys.exit("Environment variable NPM_AUTH_TOKEN is unavailable")
32+
33+
if TRAVIS_TAG.startswith('core/'):
34+
PROJECT = 'core'
35+
VERSION = TRAVIS_TAG[5:]
36+
else:
37+
PROJECT = 'tracker'
38+
VERSION = TRAVIS_TAG
39+
40+
if 'AWS_ACCESS_KEY' in os.environ:
41+
AWS_ACCESS_KEY = os.environ.get('AWS_ACCESS_KEY')
42+
else:
43+
sys.exit("Environment variable AWS_ACCESS_KEY is unavailable (required for tracker publishing)")
44+
45+
if 'AWS_SECRET_KEY' in os.environ:
46+
AWS_SECRET_KEY = os.environ.get('AWS_SECRET_KEY')
47+
else:
48+
sys.exit("Environment variable AWS_SECRET_KEY is unavailable (required for tracker publishing)")
49+
50+
if 'AWS_S3_BUCKET' in os.environ:
51+
AWS_S3_BUCKET = os.environ.get('AWS_S3_BUCKET')
52+
else:
53+
sys.exit("Environment variable AWS_S3_BUCKET is unavailable (required for tracker publishing)")
54+
55+
if 'AWS_REGION' in os.environ:
56+
AWS_REGION = os.environ.get('AWS_REGION')
57+
else:
58+
sys.exit("Environment variable AWS_REGION is unavailable (required for tracker publishing)")
59+
60+
if 'AWS_CF_DISTRIBUTION' in os.environ:
61+
AWS_CF_DISTRIBUTION = os.environ.get('AWS_CF_DISTRIBUTION')
62+
else:
63+
sys.exit("Environment variable AWS_CF_DISTRIBUTION is unavailable (required for tracker publishing)")
64+
65+
66+
# Helper functions
67+
68+
def output_if_error(sbt_output):
69+
"""Callback to print stderr and fail deploy if exit status not successful"""
70+
(stdout, stderr) = sbt_output.communicate()
71+
if sbt_output.returncode != 0:
72+
print("Process has been failed.\n" + stdout)
73+
sys.exit(stderr)
74+
75+
76+
def execute(command, callback=output_if_error):
77+
"""Execute shell command with optional callback"""
78+
formatted_command = " ".join(command) if (type(command) == list) else command
79+
print("Executing [{0}]".format(formatted_command))
80+
output = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
81+
if hasattr(callback, '__call__'):
82+
return callback(output)
83+
else:
84+
return output
85+
86+
87+
def check_version():
88+
"""Fail deploy if tag version doesn't match SBT version"""
89+
if PROJECT == 'core':
90+
get_version = """var fs=require('fs'); fs.readFile('./core/package.json', 'utf8', function(e,d) { console.log(JSON.parse(d)['version']) });"""
91+
elif PROJECT == 'tracker':
92+
get_version = """var fs=require('fs'); fs.readFile('./package.json', 'utf8', function(e,d) { console.log(JSON.parse(d)['version']) });"""
93+
else:
94+
sys.exit("Unknown project " + str(PROJECT))
95+
96+
node_output = execute(['node', '-e', get_version], None)
97+
print(node_output.stderr.read())
98+
for line in node_output.stdout.read().split("\n"):
99+
print(line)
100+
if line:
101+
if line != VERSION:
102+
sys.exit("Version extracted from TRAVIS_TAG [{0}] doesn't conform declared in package.json [{1}]".format(VERSION, line))
103+
else:
104+
return
105+
106+
sys.exit("Cannot find version in core output:\n" + str(node_output))
107+
108+
109+
@contextmanager
110+
def npm_credentials():
111+
"""Context manager allowing to use different credentials and delete them after use"""
112+
npmrc = os.path.expanduser("~/.npmrc")
113+
114+
if os.path.isfile(npmrc):
115+
os.remove(npmrc)
116+
print("WARNING! ~/.npmrc already exists. It should be deleted after each use")
117+
print("Overrinding existing ~/.npmrc")
118+
else:
119+
print("Creating ~/.npmrc")
120+
121+
with open(npmrc, 'a') as f:
122+
f.write("registry=http://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=" + NPM_AUTH_TOKEN)
123+
124+
yield
125+
126+
print("Deleting ~/.npmrc")
127+
os.remove(npmrc)
128+
129+
130+
@contextmanager
131+
def aws_credentials():
132+
"""Context manager allowing to use different credentials and delete them after use"""
133+
awsjson = os.path.join(TRAVIS_BUILD_DIR, "aws.json")
134+
135+
if os.path.isfile(awsjson):
136+
sys.exit("aws.json already exists. It should be deleted after each use")
137+
else:
138+
print("Creating aws.json")
139+
with open(awsjson, 'a') as f:
140+
f.write(
141+
'{"key":"%(key)s","secret":"%(secret)s","bucket":"%(bucket)s","region":"%(region)s", "distribution":"%(distribution)s"}' % \
142+
{'key': AWS_ACCESS_KEY, 'secret': AWS_SECRET_KEY, 'bucket': AWS_S3_BUCKET, 'distribution': AWS_CF_DISTRIBUTION, 'region': AWS_REGION}
143+
)
144+
145+
yield
146+
147+
print("Deleting aws.json")
148+
os.remove(awsjson)
149+
150+
151+
def publish_core():
152+
os.chdir(os.path.join(TRAVIS_BUILD_DIR, "core"))
153+
with npm_credentials():
154+
execute(['npm', 'publish'])
155+
156+
157+
def publish_tracker():
158+
os.chdir(TRAVIS_BUILD_DIR)
159+
with aws_credentials():
160+
execute(['grunt', 'publish'])
161+
162+
163+
def publish():
164+
if PROJECT == 'core':
165+
publish_core()
166+
elif PROJECT == 'tracker':
167+
publish_tracker()
168+
else:
169+
sys.exit("Unknown project " + str(PROJECT))
170+
171+
if __name__ == "__main__":
172+
# Publish locally all dependencies
173+
check_version()
174+
publish()

.travis/is_core_release_tag.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
tag=$1
4+
cicd=${tag:0:4}
5+
release=${tag:5}
6+
7+
if [ "${cicd}" == "core" ]; then
8+
if [ "${release}" == "" ]; then
9+
echo "Warning! No release specified! Ignoring."
10+
exit 2
11+
fi
12+
exit 0
13+
else
14+
exit 1
15+
fi

.travis/is_tracker_release_tag.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
tag=$1
4+
release=$tag
5+
6+
if [ "${release}" == "" ]; then
7+
echo "Warning! No release specified! Ignoring."
8+
exit 2
9+
else
10+
if [ "${release:0:4}" == "core" ]; then
11+
echo "Core relase, not tracker"
12+
fi
13+
fi
14+
exit 0

CHANGELOG

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
Version 2.6.2 (2016-xx-xx)
1+
Version 2.7.0 (2017-01-09)
2+
--------------------------
3+
Add CI/CD (#529)
4+
Add ngrok credentials (#527)
5+
Add Sauce Labs credentials (#528)
6+
Add npm credentials to .travis.yml (#536)
7+
Add AWS credentials to .travis.yml (#537)
8+
Remove random upload path (#538)
9+
Add an option to change life of the visitor cookie, or disable, on tracker creation (#504)
10+
Make tracker Content Security Policy (CSP) compliant (#490)
11+
Add Optimizely summary context (#466)
12+
Add the option to regenerate the page view ID with each page view event (#436)
13+
Add automatic & manual tracking of JS errors to JavaScript tracker (#16)
14+
Get Code Climate badge to green (#152)
15+
Add ability to set true timestamp (#484)
16+
Add timestamp argument for tracking methods (#532)
17+
Remove deprecated visibility state check (#470)
18+
Update Selenium version to 2.48.0 (#487)
19+
Add date for release 2.6.2 to CHANGELOG (#520)
20+
Add trackSelfDescribingEvent method (#471)
21+
Fix integration tests suite (#523)
22+
Bump Core version to 0.5.0 (#301)
23+
Restrict package versions (#522)
24+
Core: only send custom contexts if non-empty array (#540)
25+
Core: add support of true timestamp (#531)
26+
Core: add trackSelfDescribing method (#533)
27+
Core: port to TypeScript (#526)
28+
29+
Version 2.6.2 (2016-07-14)
230
--------------------------
331
Add date for release 2.6.1 to CHANGELOG (#495)
432
Don't send invalid viewport dimensions (#488)

0 commit comments

Comments
 (0)