forked from boyter/searchcode-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
181 lines (139 loc) · 5.29 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
'''
/*
* Copyright (c) 2016 Boyter Online Services
*
* Use of this software is governed by the Fair Source License included
* in the LICENSE.TXT file, but will be eventually open under GNU General Public License Version 3
* see the README.md for when this clause will take effect
*
* Version 1.3.6
*/
'''
import fabric
from fabric.api import env
from fabric.api import run
from fabric.api import local
from fabric.api import sudo
from fabric.api import prompt
from fabric.utils import warn
from fabric.contrib.files import sed
from fabric.context_managers import settings, hide, cd
from fabric.colors import yellow
import os
from os import path
import re
import hashlib
import sys
import datetime
VERSION = "1.3.6"
def setup_npm():
# Required to run Qunit via command line
# http://stackoverflow.com/questions/24704043/how-to-run-qunit-tests-from-command-line
local('npm install -g node-qunit-phantomjs')
def run_proxy():
local('python ./assets/javascript_proxy/webserver.py')
def package():
local('rm -rf ./target/*')
local("mvn package")
def test_full():
test()
test_integration()
def test():
local('mvn test')
js_test()
def js_test():
local('node-qunit-phantomjs ./src/test/javascript/index.html')
def test_integration():
print(yellow('Be sure to run: "fab compile_js configure_prod run" first'))
local("python ./assets/integration_test/test.py")
local("python ./assets/integration_test/fuzztest.py")
local("python ./assets/integration_test/signed_testing.py")
local("python ./assets/integration_test/signed_testing_sha512.py")
local("python ./assets/integration_test/signed_fuzz.py")
def run():
package()
local("java -jar ./target/searchcode-%s.jar" % (VERSION))
def pushtagbranch():
local('git push --tags')
def build_all_release():
js_test()
build_release()
build_community_release()
def build_release():
replacements = {
'public static final boolean ISCOMMUNITY = true;': 'public static final boolean ISCOMMUNITY = false;'
}
_python_sed(
fileloc='./src/main/java/com/searchcode/app/App.java', replacements=replacements)
compile_js()
configure_prod()
package()
_build_package()
if not os.path.exists('./searchcode-server/'):
os.makedirs('./searchcode-server/')
local('rm -rf ./searchcode-server/*')
local('mv ./release ./searchcode-server')
local('cp -R include ./searchcode-server/release/')
local('tar cvzf searchcode-server.tar.gz searchcode-server')
def build_community_release():
# modify community flag in application
replacements = {
'public static final boolean ISCOMMUNITY = false;': 'public static final boolean ISCOMMUNITY = true;'
}
_python_sed(
fileloc='./src/main/java/com/searchcode/app/App.java', replacements=replacements)
compile_js()
configure_prod()
package()
_build_package()
if not os.path.exists('./searchcode-server-community/'):
os.makedirs('./searchcode-server-community/')
local('rm -rf ./searchcode-server-community/*')
local('mv ./release ./searchcode-server-community')
local('cp -R include ./searchcode-server-community/release/')
local(
'tar cvzf searchcode-server-community.tar.gz searchcode-server-community')
def compile_js():
files = [
'',
'underscore-min.js',
'cache.js',
'chart.js',
'mithril.min.js',
'script.js'
]
tomin = ' ./src/main/resources/public/js/'.join(files)
local(
'java -jar ./assets/js_compiler/compiler.jar --js_output_file=./src/main/resources/public/js/script.min.js --js ' + tomin)
def configure_local():
replacements = {
'<script src="/js/script.min.js"></script>':
'<script src="/js/mithril.min.js"></script><script src="/js/underscore-min.js"></script><script src="/js/chart.js"></script><script src="/js/cache.js"></script><script src="/js/script.js"></script>'
}
_python_sed(
fileloc='./src/main/resources/spark/template/freemarker/search_test.ftl', replacements=replacements)
def configure_prod():
replacements = {
'<script src="/js/mithril.min.js"></script><script src="/js/underscore-min.js"></script><script src="/js/chart.js"></script><script src="/js/cache.js"></script><script src="/js/script.js"></script>':
'<script src="/js/script.min.js"></script>'
}
_python_sed(
fileloc='./src/main/resources/spark/template/freemarker/search_test.ftl', replacements=replacements)
def _build_package():
if not os.path.exists('./release/'):
os.makedirs('./release/')
local('rm -rf ./release/*')
local('cp -R ./target/dependency-jars ./release/')
local('cp ./target/*.jar ./release/')
local('cp ./searchcode.properties.example ./release/searchcode.properties')
local('cp ./searchcode.sqlite.empty ./release/searchcode.sqlite')
local('cp ./README.md ./release/')
local('chmod +x ./searchcode-server.sh')
local('cp ./searchcode-server.sh ./release/')
local('cp ./searchcode-server.bat ./release/')
local('mkdir ./release/logs')
def _python_sed(fileloc, replacements):
import fileinput
for search, replace in replacements.iteritems():
for line in fileinput.input(fileloc, inplace=True):
print line.replace(search, replace).rstrip()