From 19ad55357f64529a5b96d121013afcac0b9e0dfb Mon Sep 17 00:00:00 2001 From: Andrea Brancaleoni Date: Mon, 18 Sep 2017 15:41:16 +0200 Subject: [PATCH] .travis.yml: initial implementation - travis: include tools install - travis.yml: test only the model - travis: build binaries - travis: deploy artifacts - travis: include static compilation - travis: include different arch executables - travis: fix output file - travis: explicit names - travis: disable windows for now - travis: output in gopath - travis: include version - *: include version - dep: update - travis: fix yml - travis: export variable - travis: hardcode version flags - travis only on master and tags --- .travis.yml | 29 +++++++++++++++++++++++++++++ Gopkg.lock | 8 +++++++- bin/promplay/main.go | 7 ++++--- bin/promrec/main.go | 5 +++-- 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6c744c9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: go +go: +- 1.8 +install: +- go get -u github.com/golang/dep/cmd/dep +- dep ensure +script: +- go test -v github.com/Cleafy/promqueen/model +- GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -o "$GOPATH/bin/promrec.elf" -a -ldflags "-extldflags '-static' -X github.com/ropes/go-linker-vars-example/src/version.GitTag=$(git describe --tags) -X github.com/ropes/go-linker-vars-example/src/version.BuildUser=${USER} -X github.com/ropes/go-linker-vars-example/src/version.Version=$(git describe --tags --abbrev=0)" github.com/Cleafy/promqueen/bin/promrec +- GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -o "$GOPATH/bin/promplay.elf" -a -ldflags "-extldflags '-static' -X github.com/ropes/go-linker-vars-example/src/version.GitTag=$(git describe --tags) -X github.com/ropes/go-linker-vars-example/src/version.BuildUser=${USER} -X github.com/ropes/go-linker-vars-example/src/version.Version=$(git describe --tags --abbrev=0)" github.com/Cleafy/promqueen/bin/promplay +- GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o "$GOPATH/bin/promrec.exe" -a -ldflags "-extldflags '-static' -X github.com/ropes/go-linker-vars-example/src/version.GitTag=$(git describe --tags) -X github.com/ropes/go-linker-vars-example/src/version.BuildUser=${USER} -X github.com/ropes/go-linker-vars-example/src/version.Version=$(git describe --tags --abbrev=0)" github.com/Cleafy/promqueen/bin/promrec +- GOOS=windows GOARCH=386 CGO_ENABLED=0 go build -o "$GOPATH/bin/promplay.exe" -a -ldflags "-extldflags '-static'-X github.com/ropes/go-linker-vars-example/src/version.GitTag=$(git describe --tags) -X github.com/ropes/go-linker-vars-example/src/version.BuildUser=${USER} -X github.com/ropes/go-linker-vars-example/src/version.Version=$(git describe --tags --abbrev=0)" github.com/Cleafy/promqueen/bin/promplay +- GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -o "$GOPATH/bin/promrec" -a -ldflags "-extldflags '-static' -X github.com/ropes/go-linker-vars-example/src/version.GitTag=$(git describe --tags) -X github.com/ropes/go-linker-vars-example/src/version.BuildUser=${USER} -X github.com/ropes/go-linker-vars-example/src/version.Version=$(git describe --tags --abbrev=0)" github.com/Cleafy/promqueen/bin/promrec +- GOOS=darwin GOARCH=386 CGO_ENABLED=0 go build -o "$GOPATH/bin/promplay" -a -ldflags "-extldflags '-static' -X github.com/ropes/go-linker-vars-example/src/version.GitTag=$(git describe --tags) -X github.com/ropes/go-linker-vars-example/src/version.BuildUser=${USER} -X github.com/ropes/go-linker-vars-example/src/version.Version=$(git describe --tags --abbrev=0)" github.com/Cleafy/promqueen/bin/promplay +deploy: + provider: releases + api_key: + secure: G1FtHnchisi9145HM8gA6v7X+JzKO7kD3dL12OPegMVOVnjE5c73aMDALuqogl0c4N00IAlrMoj1NaddW0xQKYULqG0X3mswVA3Bmgcrl93XKAxCmymzYZSoq1Q2vcehXihmbpZQfl76DPrJwKIYrFWVtJoE9tH3yrkxpsGmTh3YgLtRr1PpCuUE5xFILDwEu1AsIlQeMzLxERkykSSMq2iNtABPsaPKLU0NUmkN4/WM2i/7bzMQE+lYQnZe7p3TjTf7/+9ht9KyHWH49I+6kTDsANMTH+Q6tHZNggBTtSloStCQmm1L7IQkIpYw3gDzVNfNQWuhKwICE0Z8iWX3VFKiolRSC9nfuf6LEaNyFvMhB7wcf+9rF5thZVf+cZVjh7wSGoYPAPvh3ld0vm35uX0B7MA6LjAFNbURpt8no1urNuJirTzyP9H6Ym0KfOCjWLxDtUIDzZZ89zieP1atoaCmP+/4rbS74p0WPp32OnrY6uAym9TQPuHWp7S3Iq9DBOHxHidFEC4pmWJgT4wD5fDQk/g2kleidtcq28sPVrxKUZFyN578z9FIEi80AHkl8bL4iKLFDFsklt8IyWodl6rbx0flFosjVJ1rUr+IDMuFxmnkJbHamg2W5fysbtHplWDpODlDj2KQyYJC4ltZyDe4TS4sGr9wwQKoGNEphWU= + file: + - "$GOPATH/bin/promrec" + - "$GOPATH/bin/promplay" + - "$GOPATH/bin/promrec.elf" + - "$GOPATH/bin/promplay.elf" + - "$GOPATH/bin/promrec.exe" + - "$GOPATH/bin/promplay.exe" + on: + repo: Cleafy/promqueen + branch: master + tags: true diff --git a/Gopkg.lock b/Gopkg.lock index a25a0fe..e5a2361 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -85,6 +85,12 @@ revision = "1edf99ce5dc52e8e680176c22864e5acc67b9243" version = "v1.5.3" +[[projects]] + branch = "master" + name = "github.com/ropes/go-linker-vars-example" + packages = ["src/version"] + revision = "4d2722ea9b879f2bbcb2c7012b1694fb878a068e" + [[projects]] name = "github.com/sirupsen/logrus" packages = ["."] @@ -136,6 +142,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "ab9fe37cdbb6e69e75c867cc07ef706f37600645780a32044e6e756f0105a513" + inputs-digest = "2f89ccf22d9569212d4d2e566b6e6f05d1d5566589f92308670ae94801caac77" solver-name = "gps-cdcl" solver-version = 1 diff --git a/bin/promplay/main.go b/bin/promplay/main.go index 023ac96..3124720 100644 --- a/bin/promplay/main.go +++ b/bin/promplay/main.go @@ -11,13 +11,14 @@ import ( "sort" "time" - cm "github.com/Cleafy/promqueen/model" + cm "github.com/cleafy/promqueen/model" "github.com/mattetti/filebuffer" dto "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" "github.com/prometheus/common/log" "github.com/prometheus/common/model" "github.com/prometheus/prometheus/storage/local" + "github.com/ropes/go-linker-vars-example/src/version" "github.com/sirupsen/logrus" kingpin "gopkg.in/alecthomas/kingpin.v2" filetype "gopkg.in/h2non/filetype.v1" @@ -38,7 +39,7 @@ var ( nopromcfg = kingpin.Flag("nopromcfg", "Disable the generation of the prometheus cfg file (prometheus.yml)").Bool() dir = kingpin.Flag("dir", "Input directory.").Short('d').OverrideDefaultFromEnvar("INPUT_DIRECTORY").Default(".").String() framereader = make(<-chan cm.Frame) - version = "0.0.1" + Version = version.GitTag cfgMemoryStorage = local.MemorySeriesStorageOptions{ MemoryChunks: 1024, MaxChunksToPersist: 1024, @@ -144,7 +145,7 @@ func updateURLTimestamp(timestamp int64, name string, url string, body io.Reader } func main() { - kingpin.Version(version) + kingpin.Version(Version) kingpin.Flag("storage.path", "Directory path to create and fill the data store under.").Default("data").StringVar(&cfgMemoryStorage.PersistenceStoragePath) kingpin.Flag("storage.retention-period", "Period of time to store data for").Default("360h").DurationVar(&cfgMemoryStorage.PersistenceRetentionPeriod) diff --git a/bin/promrec/main.go b/bin/promrec/main.go index 83dac49..074dd64 100644 --- a/bin/promrec/main.go +++ b/bin/promrec/main.go @@ -9,6 +9,7 @@ import ( "time" "github.com/cleafy/promqueen/model" + "github.com/ropes/go-linker-vars-example/src/version" "github.com/sirupsen/logrus" "gopkg.in/alecthomas/kingpin.v2" ) @@ -19,7 +20,7 @@ var ( interval = kingpin.Flag("interval", "Timeout waiting for ping.").Default("60s").OverrideDefaultFromEnvar("ACTION_INTERVAL").Short('i').Duration() umap = kingpin.Flag("umap", "stringmap [eg. service.name=http://get.uri:port/uri].").Short('u').StringMap() output = kingpin.Flag("output", "Output file.").Short('o').OverrideDefaultFromEnvar("OUTPUT_FILE").Default("metrics").String() - version = "0.0.1" + Version = version.GitTag filewriter io.WriteCloser ) @@ -50,7 +51,7 @@ func writerFor() (io.Writer, error) { } func main() { - kingpin.Version(version) + kingpin.Version(Version) kingpin.Parse() if *debug {