Skip to content

Commit ba0e529

Browse files
authored
Build merges on master to lastest branch (#2722)
* Build merges on master to lastest branch * Only on master
1 parent 109bc9a commit ba0e529

File tree

5 files changed

+172
-11
lines changed

5 files changed

+172
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ coverage
2323
# Compiled binary addons (http://nodejs.org/api/addons.html)
2424
build/Release
2525

26+
# build folder for automated releases
27+
latest
28+
2629
# Dependency directory
2730
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2831
node_modules

.travis.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ env:
1515
global:
1616
- COVERAGE_OPTION='./node_modules/.bin/istanbul cover'
1717
matrix:
18-
- PARSE_SERVER_TEST_DB=postgres
1918
- MONGODB_VERSION=3.0.8
2019
- MONGODB_VERSION=3.2.6
20+
- PARSE_SERVER_TEST_DB=postgres
2121
matrix:
2222
fast_finish: true
2323
branches:
@@ -30,14 +30,25 @@ cache:
3030
- "$HOME/.mongodb/versions"
3131
after_script:
3232
- bash <(curl -s https://codecov.io/bash)
33+
after_failure:
34+
- (cd resources; python travis_after_all.py)
35+
after_success:
36+
- (cd resources; python travis_after_all.py)
37+
3338
deploy:
34-
provider: npm
35-
email:
36-
secure: T3LwSJFcu632SDfCoavcKL39NktWLEOOFzonAjeHAglmMyDp9hvU8xHwQ4JJy2CRA03c+ezAe2gH3Va+jfxvh1JtFUan+p88vaCHHKuNwPSp4WZBPt1ZTDmG+ACG6j+ZWHK+eP7hLvtlCi/M9/v4/bVojpm7v01LLiM+MRhnE9E7eLemQC4zb6RVtf2oGQ3mX51kMeya218kEm5bsQPpRJElI9jwletFa8qYK5AFgaCHpll059RRHQTTE9MTNcN58P/Kf6Qb3KGpKNoaHTXoOD4U6LcXLWvdHONVB6AzGefxg2b/dvtaO4nd5lDooMBR3u9kWpopXkyAuf+fO/8je9JTx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_VERSION = '3.0.8'"
43-
repo: ParsePlatform/parse-server
39+
- provider: script
40+
skip_cleanup: true
41+
script: ./resources/npm-git.sh
42+
on:
43+
branch: master
44+
condition: "$BUILD_LEADER$BUILD_AGGREGATE_STATUS = YESothers_succeeded"
45+
- provider: npm
46+
email:
47+
secure: T3LwSJFcu632SDfCoavcKL39NktWLEOOFzonAjeHAglmMyDp9hvU8xHwQ4JJy2CRA03c+ezAe2gH3Va+jfxvh1JtFUan+p88vaCHHKuNwPSp4WZBPt1ZTDmG+ACG6j+ZWHK+eP7hLvtlCi/M9/v4/bVojpm7v01LLiM+MRhnE9E7eLemQC4zb6RVtf2oGQ3mX51kMeya218kEm5bsQPpRJElI9jwletFa8qYK5AFgaCHpll059RRHQTTE9MTNcN58P/Kf6Qb3KGpKNoaHTXoOD4U6LcXLWvdHONVB6AzGefxg2b/dvtaO4nd5lDooMBR3u9kWpopXkyAuf+fO/8je9JTxO6CDUtDjHRcR2mCEXWX6rculIAbNXOv1ccRYCTQ8aFtYnFlMSb1+QIAdyT6HHmeT5ktk3+XJRuEv0PJJvqHTo+j7tPngjiv5sPNutgGFlOFO90omTbzEkIT/D/LsgXbWm2QKYWejbLiuSINg+FiFiZN90doCf4aCpm2y1Q/9GzvK+eXcpqzPCGxOykE7EuPZK3+S/ZU2oaWL2uSpbKPtC0qxebrneR307aVEa7C85HCkTMMBzE4tjUr8h5HhLqtWvqmDcnBo3PfQhf9cEO6jQLd3qhEVJmcwKz/yOCfgPXlCbRqiKk7j94perpNCIalXtMI9ySYjJNjHsB4600=
48+
api_key:
49+
secure: WLjhHVAdUkDy6UdNWveTpZqphw9olN0alCpyPpU0cJjlN/hk7YxPP+YHOSVnMZaRZoHM0LL11jPKLf970nymBfvJHDWxKk71c/5xyTX8pBtSxmGmGy23a5g2VrHVMd2JxsI7NEAH500tlFz+01t4E3Steo0NpAkHR3Q51kj01gQy8IumsksfhRc9uvjZ7zjm99Yk4L+cxyei79v4esfpx7Bgm0HTfAAAG/19F+r0hvvFiV517SREDU/YtcX/rIjVepEy1uiLKEohnmYtVIRSA3Hjh6VlHVhdj2WDd/dYrxi/Ioysq2zOM9pZVLamO9asB1e6JrTEipWE9jSZXxsbnfFzuNLxcOjKv1wd3OzQKF/7pGKGiWRTv5Xm19D/FrXoE/ULs6bHcC/Ke8Gs2RxPlOCdvAFehCkyf5P4HOPCQdR7o8Yiuvt+5JWKBflElNbSd4nWgwUOo3Yv8vC4Vj53fwmM+Uqfu3IgYFWktYxCm4RWIKMfB/gtmjcF6QYFfjvEMwAvRfBV81kuynCsnubXWzQeBE/b3JOhBfpGciKCjKfy+tS6bZfFjCtQV98hMMiCPre8Y7PahHDYc65wU9Ake+ZE+dDaSbeV3DZ5JeifLJHzKW2J2dWeRANkOaiSwO9VBC9/rht5ulK5qQ1pB2+sKDToAaiKy6RMlB/HgIoYqsU=
50+
on:
51+
tags: true
52+
all_branches: true
53+
condition: "$MONGODB_VERSION = '3.0.8'"
54+
repo: ParsePlatform/parse-server

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,18 @@ If you believe you've found an issue with Parse Server, make sure these boxes ar
325325

326326
- [ ] You've searched through [existing issues](https://github.com/ParsePlatform/parse-server/issues?utf8=%E2%9C%93&q=). Chances are that your issue has been reported or resolved before.
327327

328+
# Want to ride the bleeding edge?
329+
330+
The `latest` branch in this repository is automatically maintained to be the last
331+
commit to `master` to pass all tests, in the same form found on npm. It is
332+
recommend to use builds deployed npm for many reasons, but if you want to use
333+
the latest not-yet-released version of parse-server, you can do so by depending
334+
directly on this branch:
335+
336+
```
337+
npm install parseplatform/parse-server.git#latest
338+
```
339+
328340
# Contributing
329341

330342
We really want Parse to be yours, to see it grow and thrive in the open source community. Please see the [Contributing to Parse Server guide](CONTRIBUTING.md).

resources/npm-git.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh -e
2+
3+
# This script maintains a git branch which mirrors master but in a form that
4+
# what will eventually be deployed to npm, allowing npm dependencies to use:
5+
#
6+
# "parse-server": "parseplatform/parse-server#latest"
7+
#
8+
9+
# From: https://github.com/graphql/graphql-js/blob/master/resources/npm-git.sh
10+
11+
BUILD_DIR=latest
12+
13+
npm run build
14+
15+
mkdir -p $BUILD_DIR
16+
17+
cp package.json $BUILD_DIR/
18+
cp README.md $BUILD_DIR/
19+
cp LICENSE $BUILD_DIR/
20+
cp PATENTS $BUILD_DIR/
21+
cp CHANGELOG.md $BUILD_DIR/
22+
cp -R lib $BUILD_DIR
23+
cp -R bin $BUILD_DIR
24+
cp -R public_html $BUILD_DIR
25+
cp -R views $BUILD_DIR
26+
27+
cd $BUILD_DIR
28+
git init
29+
git config user.name "Travis CI"
30+
git config user.email "[email protected]"
31+
git add .
32+
git commit -m "Deploy master to LATEST branch"
33+
git push --force --quiet "https://${GH_TOKEN}@github.com/parseplatform/parse-server.git" master:latest

resources/travis_after_all.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
"""
2+
https://github.com/dmakhno/travis_after_all/blob/master/travis_after_all.py
3+
https://github.com/graphql/graphql-js/blob/master/resources/travis_after_all.py
4+
"""
5+
6+
import os
7+
import json
8+
import time
9+
import logging
10+
11+
try:
12+
import urllib.request as urllib2
13+
except ImportError:
14+
import urllib2
15+
16+
log = logging.getLogger("travis.leader")
17+
log.addHandler(logging.StreamHandler())
18+
log.setLevel(logging.INFO)
19+
20+
TRAVIS_JOB_NUMBER = 'TRAVIS_JOB_NUMBER'
21+
TRAVIS_BUILD_ID = 'TRAVIS_BUILD_ID'
22+
POLLING_INTERVAL = 'LEADER_POLLING_INTERVAL'
23+
24+
build_id = os.getenv(TRAVIS_BUILD_ID)
25+
polling_interval = int(os.getenv(POLLING_INTERVAL, '5'))
26+
27+
#assume, first job is the leader
28+
is_leader = lambda job_number: job_number.endswith('.1')
29+
30+
if not os.getenv(TRAVIS_JOB_NUMBER):
31+
# seems even for builds with only one job, this won't get here
32+
log.fatal("Don't use defining leader for build without matrix")
33+
exit(1)
34+
elif is_leader(os.getenv(TRAVIS_JOB_NUMBER)):
35+
log.info("This is a leader")
36+
else:
37+
#since python is subprocess, env variables are exported back via file
38+
with open(".to_export_back", "w") as export_var:
39+
export_var.write("BUILD_MINION=YES")
40+
log.info("This is a minion")
41+
exit(0)
42+
43+
44+
class MatrixElement(object):
45+
def __init__(self, json_raw):
46+
self.is_finished = json_raw['finished_at'] is not None
47+
self.is_succeeded = json_raw['result'] == 0
48+
self.number = json_raw['number']
49+
self.is_leader = is_leader(self.number)
50+
51+
52+
def matrix_snapshot():
53+
"""
54+
:return: Matrix List
55+
"""
56+
response = urllib2.build_opener().open("https://api.travis-ci.org/builds/{0}".format(build_id)).read()
57+
raw_json = json.loads(response)
58+
matrix_without_leader = [MatrixElement(element) for element in raw_json["matrix"]]
59+
return matrix_without_leader
60+
61+
62+
def wait_others_to_finish():
63+
def others_finished():
64+
"""
65+
Dumps others to finish
66+
Leader cannot finish, it is working now
67+
:return: tuple(True or False, List of not finished jobs)
68+
"""
69+
snapshot = matrix_snapshot()
70+
finished = [el.is_finished for el in snapshot if not el.is_leader]
71+
return reduce(lambda a, b: a and b, finished), [el.number for el in snapshot if
72+
not el.is_leader and not el.is_finished]
73+
74+
while True:
75+
finished, waiting_list = others_finished()
76+
if finished: break
77+
log.info("Leader waits for minions {0}...".format(waiting_list)) # just in case do not get "silence timeout"
78+
time.sleep(polling_interval)
79+
80+
81+
try:
82+
wait_others_to_finish()
83+
84+
final_snapshot = matrix_snapshot()
85+
log.info("Final Results: {0}".format([(e.number, e.is_succeeded) for e in final_snapshot]))
86+
87+
BUILD_AGGREGATE_STATUS = 'BUILD_AGGREGATE_STATUS'
88+
others_snapshot = [el for el in final_snapshot if not el.is_leader]
89+
if reduce(lambda a, b: a and b, [e.is_succeeded for e in others_snapshot]):
90+
os.environ[BUILD_AGGREGATE_STATUS] = "others_succeeded"
91+
elif reduce(lambda a, b: a and b, [not e.is_succeeded for e in others_snapshot]):
92+
log.error("Others Failed")
93+
os.environ[BUILD_AGGREGATE_STATUS] = "others_failed"
94+
else:
95+
log.warn("Others Unknown")
96+
os.environ[BUILD_AGGREGATE_STATUS] = "unknown"
97+
#since python is subprocess, env variables are exported back via file
98+
with open(".to_export_back", "w") as export_var:
99+
export_var.write("BUILD_LEADER=YES {0}={1}".format(BUILD_AGGREGATE_STATUS, os.environ[BUILD_AGGREGATE_STATUS]))
100+
101+
except Exception as e:
102+
log.fatal(e)

0 commit comments

Comments
 (0)