Merge pull request #5909 from influxdata/ross-build-updates

Minor Build Updates
pull/5756/head
Ross McDonald 2016-03-16 16:53:23 -05:00
commit 6a461d8a34
2 changed files with 40 additions and 17 deletions

View File

@ -122,7 +122,16 @@ def package_scripts(build_root):
def run_generate(): def run_generate():
print "Running go generate to rebuild admin UI static filesystem..." print "Running go generate to rebuild admin UI static filesystem..."
if not check_path_for("statik"):
run("go install github.com/rakyll/statik")
orig_path = None
if os.path.join(os.environ.get("GOPATH"), "bin") not in os.environ["PATH"].split(os.pathsep):
orig_path = os.environ["PATH"].split(os.pathsep)
os.environ["PATH"] = os.environ["PATH"].split(os.pathsep).append(os.path.join(os.environ.get("GOPATH"), "bin"))
run("rm -f ./services/admin/statik/statik.go")
run("go generate ./services/admin") run("go generate ./services/admin")
if orig_path is not None:
os.environ["PATH"] = orig_path
return True return True
def go_get(branch, update=False, no_stash=False): def go_get(branch, update=False, no_stash=False):
@ -149,7 +158,7 @@ def run(command, allow_failure=False, shell=False):
else: else:
out = subprocess.check_output(command.split(), stderr=subprocess.STDOUT) out = subprocess.check_output(command.split(), stderr=subprocess.STDOUT)
if debug: if debug:
print "[DEBUG] command output: \n{}\n".format(out) print "[DEBUG] command output:\n {}".format(out)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print "" print ""
print "" print ""
@ -368,7 +377,8 @@ def build(version=None,
rc=None, rc=None,
race=False, race=False,
clean=False, clean=False,
outdir="."): outdir=".",
tags=[]):
print "" print ""
print "-------------------------" print "-------------------------"
print "" print ""
@ -382,6 +392,8 @@ def build(version=None,
print "- arch: {}".format(arch) print "- arch: {}".format(arch)
print "- nightly? {}".format(str(nightly).lower()) print "- nightly? {}".format(str(nightly).lower())
print "- race enabled? {}".format(str(race).lower()) print "- race enabled? {}".format(str(race).lower())
if len(tags) > 0:
print "- build tags: {}".format(','.join(tags))
print "" print ""
if not os.path.exists(outdir): if not os.path.exists(outdir):
@ -414,7 +426,7 @@ def build(version=None,
elif arch == "armhf" or arch == "arm": elif arch == "armhf" or arch == "arm":
build_command += "GOARM=6 " build_command += "GOARM=6 "
elif arch == "arm64": elif arch == "arm64":
build_command += "GOARM=arm64 " build_command += "GOARM=7 "
else: else:
print "!! Invalid ARM architecture specifed: {}".format(arch) print "!! Invalid ARM architecture specifed: {}".format(arch)
print "Please specify either 'armel', 'armhf', or 'arm64'" print "Please specify either 'armel', 'armhf', or 'arm64'"
@ -425,6 +437,8 @@ def build(version=None,
build_command += "go build -o {} ".format(os.path.join(outdir, b)) build_command += "go build -o {} ".format(os.path.join(outdir, b))
if race: if race:
build_command += "-race " build_command += "-race "
if len(tags) > 0:
build_command += "-tags {} ".format(','.join(tags))
go_version = get_go_version() go_version = get_go_version()
if "1.4" in go_version: if "1.4" in go_version:
build_command += "-ldflags=\"-X main.version {} -X main.branch {} -X main.commit {}\" ".format(version, build_command += "-ldflags=\"-X main.version {} -X main.branch {} -X main.commit {}\" ".format(version,
@ -522,6 +536,10 @@ def build_packages(build_output, version, nightly=False, rc=None, iteration=1):
package_build_root = build_root package_build_root = build_root
current_location = build_output[platform][arch] current_location = build_output[platform][arch]
if rc is not None:
# Set iteration to 0 since it's a release candidate
package_iteration = "0.rc{}".format(rc)
if package_type in ['zip', 'tar']: if package_type in ['zip', 'tar']:
# For tars and zips, start the packaging one folder above # For tars and zips, start the packaging one folder above
# the build root (to include the package name) # the build root (to include the package name)
@ -543,10 +561,6 @@ def build_packages(build_output, version, nightly=False, rc=None, iteration=1):
elif package_type == 'zip': elif package_type == 'zip':
current_location = os.path.join(current_location, name + '.zip') current_location = os.path.join(current_location, name + '.zip')
if rc is not None:
# Set iteration to 0 since it's a release candidate
package_iteration = "0.rc{}".format(rc)
fpm_command = "fpm {} --name {} -a {} -t {} --version {} --iteration {} -C {} -p {} ".format( fpm_command = "fpm {} --name {} -a {} -t {} --version {} --iteration {} -C {} -p {} ".format(
fpm_common_args, fpm_common_args,
name, name,
@ -613,6 +627,7 @@ def print_package_summary(packages):
def main(): def main():
global debug global debug
global PACKAGE_NAME
# Command-line arguments # Command-line arguments
outdir = "build" outdir = "build"
@ -637,6 +652,7 @@ def main():
upload_bucket = None upload_bucket = None
generate = False generate = False
no_stash = False no_stash = False
build_tags = []
for arg in sys.argv[1:]: for arg in sys.argv[1:]:
if '--outdir' in arg: if '--outdir' in arg:
@ -704,6 +720,12 @@ def main():
no_stash = True no_stash = True
elif '--generate' in arg: elif '--generate' in arg:
generate = True generate = True
elif '--build-tags' in arg:
for t in arg.split("=")[1].split(","):
build_tags.append(t)
elif '--name' in arg:
# Change the output package name
PACKAGE_NAME = arg.split("=")[1]
elif '--debug' in arg: elif '--debug' in arg:
print "[DEBUG] Using debug output" print "[DEBUG] Using debug output"
debug = True debug = True
@ -756,14 +778,14 @@ def main():
build_output = {} build_output = {}
if generate:
if not run_generate():
return 1
if run_get: if run_get:
if not go_get(branch, update=update, no_stash=no_stash): if not go_get(branch, update=update, no_stash=no_stash):
return 1 return 1
if generate:
if not run_generate():
return 1
if test: if test:
if not run_tests(race, parallel, timeout, no_vet): if not run_tests(race, parallel, timeout, no_vet):
return 1 return 1
@ -799,7 +821,8 @@ def main():
rc=rc, rc=rc,
race=race, race=race,
clean=clean, clean=clean,
outdir=od): outdir=od,
tags=build_tags):
return 1 return 1
build_output.get(platform).update( { arch : od } ) build_output.get(platform).update( { arch : od } )

10
test.sh
View File

@ -131,30 +131,30 @@ fi
case $ENVIRONMENT_INDEX in case $ENVIRONMENT_INDEX in
0) 0)
# 64 bit tests # 64 bit tests
run_test_docker Dockerfile_build_ubuntu64 test_64bit --debug --test run_test_docker Dockerfile_build_ubuntu64 test_64bit --debug --generate --test
rc=$? rc=$?
;; ;;
1) 1)
# 64 bit tsm tests # 64 bit tsm tests
INFLUXDB_DATA_ENGINE="tsm1" INFLUXDB_DATA_ENGINE="tsm1"
run_test_docker Dockerfile_build_ubuntu64 test_64bit_tsm --debug --test run_test_docker Dockerfile_build_ubuntu64 test_64bit_tsm --debug --generate --test
rc=$? rc=$?
;; ;;
2) 2)
# 64 bit race tests # 64 bit race tests
GORACE="halt_on_error=1" GORACE="halt_on_error=1"
run_test_docker Dockerfile_build_ubuntu64 test_64bit_race --debug --test --race run_test_docker Dockerfile_build_ubuntu64 test_64bit_race --debug --generate --test --race
rc=$? rc=$?
;; ;;
3) 3)
# 32 bit tests # 32 bit tests
run_test_docker Dockerfile_build_ubuntu32 test_32bit --debug --test run_test_docker Dockerfile_build_ubuntu32 test_32bit --debug --generate --test
rc=$? rc=$?
;; ;;
4) 4)
# 64 bit tests on golang go1.6 # 64 bit tests on golang go1.6
GO_CHECKOUT=go1.6 GO_CHECKOUT=go1.6
run_test_docker Dockerfile_build_ubuntu64_git test_64bit_go1.6 --debug --test --no-vet run_test_docker Dockerfile_build_ubuntu64_git test_64bit_go1.6 --debug --generate --test --no-vet
rc=$? rc=$?
;; ;;
"save") "save")