Skip to content
This repository was archived by the owner on Apr 24, 2018. It is now read-only.

Commit 24d3478

Browse files
authored
Merge branch 'master' into tests
2 parents c4c5bfc + a5e7402 commit 24d3478

File tree

5 files changed

+57
-48
lines changed

5 files changed

+57
-48
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sudo: required
1010
# OS packages
1111
addons:
1212
apt:
13-
packages: [uidmap, vagga]
13+
packages: [vagga]
1414
sources:
1515
- sourceline: >-
1616
deb [arch=amd64 trusted=yes] http://ubuntu.zerogw.com vagga-testing main
@@ -25,11 +25,11 @@ cache:
2525

2626
# Scripts to install dependencies
2727
# These are mostly honestly borrowed from https://github.com/tailhook/vagga/tree/master/.travis.yml
28-
before_install:
29-
- 'echo ubuntu-mirror: http://mirrors.us.kernel.org/ubuntu/ > ~/.vagga.yaml'
30-
- echo "$(id -un):100000:65536" | sudo tee /etc/subuid | sudo tee /etc/subgid
28+
before_install: 'echo ubuntu-mirror: http://mirrors.us.kernel.org/ubuntu/ > ~/.vagga.yaml'
3129

32-
install: vagga _build nodejs-7-ubuntu-bin
30+
install:
31+
- vagga _build nodejs-7-ubuntu-bin
32+
- vagga version
3333

3434
# Run tests
3535
script: vagga test

data/dataIO.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,6 @@ module.exports = {
2121
dataIOTests
2222
}
2323

24-
const url = require('url')
25-
const parsedStatsdUrl = url.parse(process.env.STATSD_URL, true, true)
26-
const StatsD = require('node-statsd')
27-
const statsClient = new StatsD(
28-
{
29-
host: parsedStatsdUrl.hostname,
30-
port: parsedStatsdUrl.port
31-
}
32-
)
33-
statsClient.socket.on('error', function (error) {
34-
_log_(`Error in socket: ${error}`)
35-
})
36-
3724
const firstEvent = 0
3825

3926
/**
@@ -53,8 +40,6 @@ dataIO.get = (srcName, srcType, srcLink, newJSON, oldJSON) => {
5340
// Save old data
5441
fs.renameSync(newJSON, oldJSON)
5542

56-
statsClient.increment('eventsparser.get')
57-
5843
// Get data from source
5944
const res = request('GET', srcLink).getBody()
6045
const json = convertToJson(res, srcType)
@@ -106,8 +91,6 @@ dataIO.read = (srcFrom, file) => {
10691
let data = fs.readJsonSync(file, {'throws': false})
10792
data = eval(giveConfig[srcFrom].allEvents)
10893

109-
statsClient.gauge(`eventsparser.sources.${srcFrom}.count`, data.length)
110-
11194
return data
11295
}
11396

@@ -181,8 +164,6 @@ dataIO.sendtoAPI = (title, agenda, social, place, regUrl, imgUrl, whenStart, whe
181164
'submitter_email': process.env.EMAIL
182165
})
183166

184-
statsClient.increment('eventsparser.sendToAPI.sends')
185-
186167
const options = {
187168
'hostname': process.env.HOSTNAME_URL,
188169
'port': process.env.HOSTNAME_PORT,
@@ -204,7 +185,6 @@ dataIO.sendtoAPI = (title, agenda, social, place, regUrl, imgUrl, whenStart, whe
204185
})
205186
req.on('error', (e) => {
206187
_log_(`problem with request: ${e.message}`)
207-
statsClient.increment('eventsparser.sendToAPI.errors')
208188
})
209189

210190
req.write(body)

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"moment": "~2.13.0",
2626
"node-statsd": "0.1.1",
2727
"sync-request": "~3.0.0",
28-
"url": "0.11.0",
2928
"xml2json": "0.9.2",
3029
"yandex-translate": "~2.1.0"
3130
},

utils.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,11 @@ function RIS (cmd, args) {
117117
)
118118
}
119119

120-
const describe = RIS('git', ['describe'])
121-
const branch = RIS('git', ['rev-parse', '--abbrev-ref', 'HEAD'])
122-
123120
/**
124-
* Getting build version based on 'git tags' and curent branch.
125-
* Patern: vMAJOR.MINOR.PATH-%branch name%-%number of commits from last tag%-%commit hash%.
126-
* Example: v0.5.0-vesioning-8-g65cc3b3.
127-
* @returns {string} version - curent build version.
121+
* Get build version based on 'git tags' and current branch.
122+
* Reads the app version from the env var or the file as a fallback.
123+
* Pattern: vMAJOR.MINOR.PATCH-%branch name%-%number of commits from last tag%-%commit hash%.
124+
* Example: v0.5.0-versioning-8-g65cc3b3.
125+
* @returns {string} version - current build version.
128126
*/
129-
utils.getVersion = () => {
130-
const ds = describe.stdout.split('-')
131-
const version = ds.length === 1
132-
? `${ds[0]}-${branch.stdout}`
133-
: `${ds[0]}-${branch.stdout}-${ds[1]}-${ds[2]}`
134-
135-
return version
136-
}
127+
utils.getVersion = () => process.env.APP_VERSION || RIS('cat', [process.env.APP_VERSION_FILE]).stdout

vagga.yaml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@ containers:
66
NODE_PATH: /usr/local/lib/node_modules
77
NPM_CONFIG_LOGLEVEL: info
88
HOSTNAME_URL: eventsmonkey.itkpi.pp.ua
9+
APP_VERSION_FILE: /.app-version
10+
APP_NAME: Events Parser
911
setup:
1012
- !Ubuntu xenial
1113
- !Env
1214
<<: *env_vars
15+
- !Depends .git/index
16+
# Python is a dendency of node-gyp:
17+
# Ref: https://github.com/nodejs/node-gyp#installation
18+
- !BuildDeps [python, git]
19+
- !Install [libexpat1]
20+
# Generate the current version of app
21+
- &generate_app_version !Sh |
22+
ver=`git describe | awk -F- '{print$1}'`-`git rev-parse --abbrev-ref HEAD`
23+
git describe | awk -F- '{print$2"\n"$3}' | while read sub_ver
24+
do
25+
ver=$ver-$sub_ver
26+
done
27+
echo $ver > $APP_VERSION_FILE
1328
# Get and install an official nodejs7 binary
1429
- &install_nodejs_7 !Tar
1530
url: https://nodejs.org/dist/v7.2.1/node-v7.2.1-linux-x64.tar.xz
@@ -21,10 +36,6 @@ containers:
2136
# Ref: vagga.readthedocs.io/en/latest/build_steps.html#step-NpmConfig
2237
- !NpmConfig
2338
install_node: false
24-
# Python is a dendency of node-gyp:
25-
# Ref: https://github.com/nodejs/node-gyp#installation
26-
- !BuildDeps [python]
27-
- !Install [libexpat1]
2839
# install dependencies from package.json, see the doc for extra options:
2940
# Ref: vagga.readthedocs.io/en/latest/build_steps.html#step-NpmDependencies
3041
- !NpmDependencies
@@ -35,10 +46,13 @@ containers:
3546
<<: *env_vars
3647
setup:
3748
- !Alpine v3.4
38-
- !BuildDeps [binutils-gold, curl, g++, gcc, gnupg, libgcc, linux-headers, make, python]
49+
- !BuildDeps [binutils-gold, curl, g++, gcc, gnupg, libgcc, linux-headers, make, python, git]
3950
- !Install [libstdc++]
4051
- !Env
4152
<<: *env_vars
53+
- !Depends .git/index
54+
# Generate the current version of app
55+
- *generate_app_version
4256
# Add a user to make him nodejs files owner:
4357
- !Sh adduser -D -u 1000 node
4458
# Add trusted keys to the gpg registry:
@@ -72,9 +86,13 @@ containers:
7286
<<: *env_vars
7387
setup:
7488
- !Alpine v3.4
89+
- !BuildDeps [git]
90+
- !Depends .git/index
7591
- !Install [binutils-gold, curl, g++, gcc, gnupg, libgcc, linux-headers, make, python, libstdc++]
7692
- !Env
7793
<<: *env_vars
94+
# Generate the current version of app
95+
- *generate_app_version
7896
- !Download
7997
url: https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub
8098
path: /etc/apk/keys/sgerrand.rsa.pub
@@ -93,6 +111,13 @@ containers:
93111
setup:
94112
- !Alpine v3.4
95113
- !BuildDeps [python, git]
114+
# Catch branch changes
115+
- !Depends .git/index
116+
# Add env vars into build time
117+
- !Env
118+
<<: *env_vars
119+
# Generate the current version of app
120+
- *generate_app_version
96121
- !NpmDependencies
97122
file: package.json
98123
environ:
@@ -101,10 +126,24 @@ containers:
101126
commands:
102127
run7: !Command
103128
container: nodejs-7-ubuntu-bin
104-
run: npm start
129+
# add current version of the app to env vars
130+
run: |
131+
export APP_VERSION=`cat $APP_VERSION_FILE`
132+
npm start
105133
test: !Command
106134
container: nodejs-7-ubuntu-bin
107135
run: [standard]
108136
run: !Command
109137
container: eventsparser
110-
run: npm start
138+
# add current version of the app to env vars
139+
run: |
140+
export APP_VERSION=`cat $APP_VERSION_FILE`
141+
npm start
142+
version: !Command
143+
container: nodejs-7-ubuntu-bin
144+
# add current version of the app to env vars
145+
run: |
146+
export APP_VERSION=`cat $APP_VERSION_FILE`
147+
echo -n $APP_NAME 'version: ' >&2
148+
echo -n $APP_VERSION
149+
echo >&2

0 commit comments

Comments
 (0)