Fix build versioning; add dev.docker file

This commit is contained in:
Daniel Nelson 2017-09-22 16:49:28 -07:00
parent 08c197f73a
commit c010fb1c3c
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
4 changed files with 36 additions and 15 deletions

View File

@ -49,12 +49,16 @@ test-all: lint
go test ./...
package:
./scripts/build.py --package --version="$(VERSION)" --platform=linux --arch=all --upload
./scripts/build.py --package --platform=all --arch=all
clean:
-rm -f telegraf
-rm -f telegraf.exe
docker-image:
./scripts/build.py --package --platform=linux --arch=amd64
cp build/telegraf*$(COMMIT)*.deb .
docker build -f scripts/dev.docker --build-arg "package=telegraf*$(COMMIT)*.deb" -t "telegraf-dev:$(COMMIT)" .
# Run all docker containers necessary for integration tests
docker-run:
docker run --name aerospike -p "3000:3000" -d aerospike/aerospike-server:3.9.0
@ -114,4 +118,4 @@ docker-kill:
openldap postgres rabbitmq redis riemann zookeeper
.PHONY: deps telegraf telegraf.exe install test test-windows lint test-all \
package clean docker-run docker-run-circle docker-kill
package clean docker-run docker-run-circle docker-kill docker-image

View File

@ -268,7 +268,7 @@ func (p *program) Stop(s service.Service) error {
func displayVersion() string {
if version == "" {
return fmt.Sprintf("v%s~pre%s", nextVersion, commit)
return fmt.Sprintf("v%s~%s", nextVersion, commit)
}
return "v" + version
}

View File

@ -95,6 +95,8 @@ supported_packages = {
"freebsd": [ "tar" ]
}
next_version = '1.5.0'
################
#### Telegraf Functions
################
@ -158,7 +160,8 @@ def go_get(branch, update=False, no_uncommitted=False):
get_command = "go get github.com/sparrc/gdm"
run(get_command)
logging.info("Retrieving dependencies with `gdm`...")
run("{}/bin/gdm restore -v".format(os.environ.get("GOPATH")))
run("{}/bin/gdm restore -v".format(os.environ.get("GOPATH",
os.path.expanduser("~/go"))))
return True
def run_tests(race, parallel, timeout, no_vet):
@ -223,13 +226,16 @@ def increment_minor_version(version):
def get_current_version_tag():
"""Retrieve the raw git version tag.
"""
version = run("git describe --always --tags --abbrev=0")
version = run("git describe --exact-match --tags 2>/dev/null",
allow_failure=True, shell=True)
return version
def get_current_version():
"""Parse version information from git tag output.
"""
version_tag = get_current_version_tag()
if not version_tag:
return None
# Remove leading 'v'
if version_tag[0] == 'v':
version_tag = version_tag[1:]
@ -474,10 +480,15 @@ def build(version=None,
if len(tags) > 0:
build_command += "-tags {} ".format(','.join(tags))
build_command += "-ldflags=\"-w -s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(
version,
get_current_branch(),
get_current_commit())
ldflags = [
'-w', '-s',
'-X', 'main.branch={}'.format(get_current_branch()),
'-X', 'main.commit={}'.format(get_current_commit(short=True))]
if version:
ldflags.append('-X')
ldflags.append('main.version={}'.format(version))
build_command += ' -ldflags="{}" '.format(' '.join(ldflags))
if static:
build_command += " -a -installsuffix cgo "
build_command += path
@ -575,10 +586,8 @@ def package(build_output, pkg_name, version, nightly=False, iteration=1, static=
package_arch = 'armv6hl'
else:
package_arch = arch
if not release and not nightly:
# For non-release builds, just use the commit hash as the version
package_version = "{}~{}".format(version,
get_current_commit(short=True))
if not version:
package_version = "{}~{}".format(next_version, get_current_commit(short=True))
package_iteration = "0"
package_build_root = build_root
current_location = build_output[platform][arch]

8
scripts/dev.docker Normal file
View File

@ -0,0 +1,8 @@
FROM debian:stretch
ARG package
ADD ${package} ${package}
RUN dpkg -i ${package}
EXPOSE 8125/udp 8092/udp 8094
CMD ["telegraf"]