From bfd285c2f2d73bea12199d64578dd05a14763d2f Mon Sep 17 00:00:00 2001 From: Audrius Karabanovas Date: Thu, 3 Oct 2019 11:18:05 +0300 Subject: [PATCH 1/2] Moving to go modules dependency management --- .gitignore | 3 +- Gopkg.lock | 111 ----------------------------------------------------- Gopkg.toml | 15 -------- go.mod | 11 ++++++ go.sum | 76 ++++++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 127 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore index 5eb58a7..8889401 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ vendor .build -.tarballs +.release +.vscode .DS_Store beat-exporter beat-exporter.exe \ No newline at end of file diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index fa5d078..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,111 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:ac2a05be7167c495fe8aaf8aaf62ecf81e78d2180ecb04e16778dc6c185c96a5" - name = "github.com/beorn7/perks" - packages = ["quantile"] - pruneopts = "" - revision = "37c8de3658fcb183f997c4e13e8337516ab753e6" - version = "v1.0.1" - -[[projects]] - digest = "1:b852d2b62be24e445fcdbad9ce3015b44c207815d631230dfce3f14e7803f5bf" - name = "github.com/golang/protobuf" - packages = ["proto"] - pruneopts = "" - revision = "6c65a5562fc06764971b7c5d05c76c75e84bdbf7" - version = "v1.3.2" - -[[projects]] - digest = "1:0f51cee70b0d254dbc93c22666ea2abf211af81c1701a96d04e2284b408621db" - name = "github.com/konsorten/go-windows-terminal-sequences" - packages = ["."] - pruneopts = "" - revision = "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e" - version = "v1.0.2" - -[[projects]] - digest = "1:63722a4b1e1717be7b98fc686e0b30d5e7f734b9e93d7dee86293b6deab7ea28" - name = "github.com/matttproud/golang_protobuf_extensions" - packages = ["pbutil"] - pruneopts = "" - revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c" - version = "v1.0.1" - -[[projects]] - digest = "1:6bea0cda3fc62855d5312163e7d259fb97e31692d93c08cfffbeb2d00df0f13c" - name = "github.com/prometheus/client_golang" - packages = [ - "prometheus", - "prometheus/internal", - "prometheus/promhttp", - ] - pruneopts = "" - revision = "170205fb58decfd011f1550d4cfb737230d7ae4f" - version = "v1.1.0" - -[[projects]] - branch = "master" - digest = "1:cd67319ee7536399990c4b00fae07c3413035a53193c644549a676091507cadc" - name = "github.com/prometheus/client_model" - packages = ["go"] - pruneopts = "" - revision = "fd36f4220a901265f90734c3183c5f0c91daa0b8" - -[[projects]] - digest = "1:0f2cee44695a3208fe5d6926076641499c72304e6f015348c9ab2df90a202cdf" - name = "github.com/prometheus/common" - packages = [ - "expfmt", - "internal/bitbucket.org/ww/goautoneg", - "model", - "version", - ] - pruneopts = "" - revision = "31bed53e4047fd6c510e43a941f90cb31be0972a" - version = "v0.6.0" - -[[projects]] - digest = "1:9b33e539d6bf6e4453668a847392d1e9e6345225ea1426f9341212c652bcbee4" - name = "github.com/prometheus/procfs" - packages = [ - ".", - "internal/fs", - ] - pruneopts = "" - revision = "3f98efb27840a48a7a2898ec80be07674d19f9c8" - version = "v0.0.3" - -[[projects]] - digest = "1:1a405cddcf3368445051fb70ab465ae99da56ad7be8d8ca7fc52159d1c2d873c" - name = "github.com/sirupsen/logrus" - packages = ["."] - pruneopts = "" - revision = "839c75faf7f98a33d445d181f3018b5c3409a45e" - version = "v1.4.2" - -[[projects]] - branch = "master" - digest = "1:0b5c2207c72f2d13995040f176feb6e3f453d6b01af2b9d57df76b05ded2e926" - name = "golang.org/x/sys" - packages = [ - "unix", - "windows", - "windows/svc", - ] - pruneopts = "" - revision = "51ab0e2deafac1f46c46ad59cf0921be2f180c3d" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/prometheus/client_golang/prometheus", - "github.com/prometheus/client_golang/prometheus/promhttp", - "github.com/prometheus/common/version", - "github.com/sirupsen/logrus", - "golang.org/x/sys/windows/svc", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 2583990..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,15 +0,0 @@ -[[constraint]] - name = "github.com/prometheus/client_golang" - version = "1.1.0" - -[[constraint]] - name = "github.com/prometheus/common" - version = "0.6.0" - -[[constraint]] - name = "github.com/sirupsen/logrus" - version = "1.4.2" - -[[constraint]] - branch = "master" - name = "golang.org/x/sys" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d573d09 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module github.com/trustpilot/beat-exporter + +go 1.12 + +require ( + github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect + github.com/prometheus/client_golang v1.1.0 + github.com/prometheus/common v0.6.0 + github.com/sirupsen/logrus v1.4.2 + golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..0e48a08 --- /dev/null +++ b/go.sum @@ -0,0 +1,76 @@ +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8= +github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= +github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= +github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcdn8tgyAONntO829og1M= +golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From b9307816eebcb56ce43384f4fee637389d83f3a5 Mon Sep 17 00:00:00 2001 From: Audrius Karabanovas Date: Thu, 3 Oct 2019 11:18:51 +0300 Subject: [PATCH 2/2] Moving to GH actions as CI/CD pipeline --- .github/main.workflow | 9 --- .github/workflows/push.yml | 53 +++++++++++++++++ .github/workflows/release-published.yml | 79 +++++++++++++++++++++++++ .promu.yml | 23 ------- .travis.yml | 20 ------- Dockerfile | 13 +--- Makefile | 78 ------------------------ VERSION | 1 - build.sh | 34 +++++++++++ create-artifacts.sh | 32 ++++++++++ 10 files changed, 201 insertions(+), 141 deletions(-) delete mode 100644 .github/main.workflow create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/release-published.yml delete mode 100644 .promu.yml delete mode 100644 .travis.yml delete mode 100644 Makefile delete mode 100644 VERSION create mode 100755 build.sh create mode 100755 create-artifacts.sh diff --git a/.github/main.workflow b/.github/main.workflow deleted file mode 100644 index 0f6205a..0000000 --- a/.github/main.workflow +++ /dev/null @@ -1,9 +0,0 @@ -workflow "build-and-deploy" { - on = "push" - resolves = "build" -} - -action "build" { - uses="cedrickring/golang-action/go1.12@1.3.0" - args="make crossbuild" -} \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..1eab068 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,53 @@ +on: push +name: test-and-build +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + + - name: Get dependencies + run: | + go mod download + + - name: Run unit-tests + run: | + GO111MODULE=on CGO_ENABLED=0 go test ./... + + - name: Build executables + run: | + ./build.sh + + - name: Upload artifact + uses: actions/upload-artifact@v1.0.0 + with: + name: binaries + path: .build + + dockerimage: + runs-on: ubuntu-latest + needs: build + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + with: + fetch-depth: 1 + + - name: Download artifact + uses: actions/download-artifact@v1.0.0 + with: + name: binaries + path: .build + + - name: Build docker image + run: | + docker build . -t trustpilot/beat-exporter + diff --git a/.github/workflows/release-published.yml b/.github/workflows/release-published.yml new file mode 100644 index 0000000..1bb8394 --- /dev/null +++ b/.github/workflows/release-published.yml @@ -0,0 +1,79 @@ +on: + release: + types: [published] +name: handle-release +jobs: + artifacts: + name: Create and upload release artifacts + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code at release tag + uses: actions/checkout@v1 + with: + ref: ${{ github.ref }} + fetch-depth: 1 + + - name: Get dependencies + run: | + go mod download + + - name: Build executables + run: | + ./build.sh + + - name: Create artifact archives + run: | + ./create-artifacts.sh + + - name: Upload artifacts archives + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: './.release/beat-exporter-*' + + docker: + name: Publish docker images + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v1 + with: + ref: ${{ github.ref }} + fetch-depth: 1 + + - name: Get dependencies + run: | + go mod download + + - name: Build executables + run: | + ./build.sh + + - name: Build and push docker image with version tags + uses: jerray/publish-docker-action@v1.0.2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: trustpilot/beat-exporter + auto_tag: true + + - name: Build and push docker image with latest tag + uses: jerray/publish-docker-action@v1.0.2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: trustpilot/beat-exporter + tags: latest \ No newline at end of file diff --git a/.promu.yml b/.promu.yml deleted file mode 100644 index a0b0a64..0000000 --- a/.promu.yml +++ /dev/null @@ -1,23 +0,0 @@ -verbose: true -repository: - path: github.com/trustpilot/beat-exporter -build: - flags: -a -tags 'netgo static_build' - ldflags: | - -s - -X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}} - -X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}} - -X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}} - -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}} - -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} -tarball: - files: - - LICENSE -crossbuild: - platforms: - - linux/amd64 - - linux/386 - - darwin/amd64 - - darwin/386 - - windows/amd64 - - windows/386 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 86c8bcc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -dist: trusty -sudo: required -language: go - -go: - - 1.10.x - -go_import_path: github.com/trustpilot/beat-exporter - -services: - - docker - -before_script: - - make dependencies - -script: - - make travis - -branches: - only: master \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c130a8c..a42196d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,7 @@ -FROM quay.io/prometheus/golang-builder as builder +FROM quay.io/prometheus/busybox:latest +LABEL MAINTAINER="Audrius Karabanovas " -ADD . /go/src/github.com/trustpilot/beat-exporter -WORKDIR /go/src/github.com/trustpilot/beat-exporter - -RUN make - -FROM quay.io/prometheus/busybox:latest -MAINTAINER Audrius Karabanovas - -COPY --from=builder /go/src/github.com/trustpilot/beat-exporter/beat-exporter /bin/beat-exporter +COPY .build/linux-amd64/beat-exporter /bin/beat-exporter EXPOSE 9479 ENTRYPOINT [ "/bin/beat-exporter" ] \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 0502bc7..0000000 --- a/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2016 The Prometheus Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -GO := GO15VENDOREXPERIMENT=1 go -PROMU := $(GOPATH)/bin/promu -pkgs = $(shell $(GO) list ./... | grep -v /vendor/) - -PREFIX ?= $(shell pwd) -BIN_DIR ?= $(shell pwd) -DOCKER_IMAGE_NAME ?= beat-exporter -DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) - - -all: format dependencies vet test build - -style: - @echo ">> checking code style" - @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' - -test: - @echo ">> running tests" - @$(GO) test -short $(pkgs) - -format: - @echo ">> formatting code" - @$(GO) fmt $(pkgs) - -vet: - @echo ">> vetting code" - @$(GO) vet $(pkgs) - -dependencies: - @echo ">> installing dep" - @$(GO) get -u github.com/golang/dep/cmd/dep - @echo ">> running dep ensure" - @dep ensure - -build: promu - @echo ">> building binaries" - @$(PROMU) build --prefix $(PREFIX) - -crossbuild: dependencies format vet test - @echo ">> cross-building binaries" - @$(GO) get github.com/mitchellh/gox - @gox -arch="386 amd64" -os="linux darwin windows" --output=".build/{{.OS}}-{{.Arch}}/{{.Dir}}" - -tarball: promu - @echo ">> building release tarball" - @$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) - -tarballs: promu - @echo ">> building release tarballs" - @$(PROMU) crossbuild tarballs $(BIN_DIR) - -travis: dependencies format build - @$(PROMU) info - -docker: - @echo ">> building docker image" - @docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . - -promu: - @echo ">> installing promu" - @GOOS=$(shell uname -s | tr A-Z a-z) \ - GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \ - $(GO) get -u github.com/prometheus/promu - -.PHONY: all style format build test vet tarball docker promu travis dependencies \ No newline at end of file diff --git a/VERSION b/VERSION deleted file mode 100644 index d917d3e..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.1.2 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..7702532 --- /dev/null +++ b/build.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +if [[ -z "$GITHUB_WORKSPACE" ]]; then + GITHUB_WORKSPACE=$(pwd) + echo "Setting up GITHUB_WORKSPACE to current directory: ${GITHUB_WORKSPACE}" +fi + +if [[ -z "$GITHUB_ACTOR" ]]; then + GITHUB_ACTOR=$(whoami) + echo "Setting up GITHUB_ACTOR to current user: ${GITHUB_ACTOR}" +fi + +GITVERSION=$(git describe --tags --always) +GITBRANCH=$(git branch | grep \* | cut -d ' ' -f2) +GITREVISION=$(git log -1 --oneline | cut -d ' ' -f1) +TIME=$(date +%FT%T%z) +LDFLAGS="-s -X github.com/prometheus/common/version.Version=${GITVERSION} \ +-X github.com/prometheus/common/version.Revision=${GITREVISION} \ +-X github.com/prometheus/common/version.Branch=master \ +-X github.com/prometheus/common/version.BuildUser=${GITHUB_ACTOR} \ +-X github.com/prometheus/common/version.BuildDate=${TIME}" + +for OS in "darwin" "linux" "windows"; do + for ARCH in "amd64" "386"; do + echo "Building ${OS}/${ARCH} with version: ${GITVERSION}, revision: ${GITREVISION}, buildUser: ${GITHUB_ACTOR}" + if [[ $OS == "windows" ]]; then + GO111MODULE=on CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags "${LDFLAGS}" -tags 'netgo static_build' -a -o ".build/${OS}-${ARCH}/beat-exporter.exe" + else + GO111MODULE=on CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH} go build -ldflags "${LDFLAGS}" -tags 'netgo static_build' -a -o ".build/${OS}-${ARCH}/beat-exporter" + fi + done +done diff --git a/create-artifacts.sh b/create-artifacts.sh new file mode 100755 index 0000000..98180e2 --- /dev/null +++ b/create-artifacts.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +if [[ -z "$GITHUB_WORKSPACE" ]]; then + echo "Set the GITHUB_WORKSPACE env variable." + exit 1 +fi + +if [[ -z "$GITHUB_REPOSITORY" ]]; then + echo "Set the GITHUB_REPOSITORY env variable." + exit 1 +fi + +echo "GITHUB WORKSPACE: ${GITHUB_WORKSPACE}" +echo "GITHUB REPO: ${GITHUB_REPOSITORY}" + +RELEASE_DIR=.release +VERSION=$(git describe --tags | cut -d '-' -f1 | cut -d 'v' -f2) +RELEASE_FILES=LICENSE + +mkdir -p $RELEASE_DIR + +for ARTIFACT in $(ls .build); do + ARTIFACT_NAME="beat-exporter-${VERSION}-${ARTIFACT}.tar.gz" + echo "Creating ${ARTIFACT_NAME}" + for FILE in $RELEASE_FILES; do + cp "${GITHUB_WORKSPACE}/${FILE}" "${GITHUB_WORKSPACE}/.build/${ARTIFACT}/${FILE}" + done + + cd "${GITHUB_WORKSPACE}/.build/${ARTIFACT}" && tar -cvzf ${GITHUB_WORKSPACE}/${RELEASE_DIR}/${ARTIFACT_NAME} * +done