From 84ca5b895740eaa1587bcadac8817e57d164ae16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Gonz=C3=A1lez?= Date: Mon, 2 May 2016 12:11:00 +0200 Subject: [PATCH] Use Docker to test in CircleCI --- .dockerignore | 2 ++ Dockerfile | 21 +++++++++++++++++++++ circle.yml | 9 +++++++-- cmd/polo/main.go | 4 ++-- glide.lock | 38 ++++++++++++++++++++++++++++++++++++++ glide.yaml | 2 +- 6 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 glide.lock diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..968e914 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +vendor/ +bin/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bd153d9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM golang:1.6.2-alpine + +ENV APP $GOPATH/src/github.com/agonzalezro/polo +RUN mkdir -p $APP +WORKDIR $APP + +ADD glide.yaml $APP/glide.yaml +ADD glide.lock $APP/glide.lock +RUN apk add --no-cache git \ + && go get -u github.com/Masterminds/glide/... \ + && go get -u github.com/jteeuwen/go-bindata/... \ + && glide install \ + && apk del git + +ADD . $APP +RUN apk add --no-cache make \ + && make \ + && apk del make + +ENTRYPOINT ["bin/polo"] +CMD ["--help"] diff --git a/circle.yml b/circle.yml index dc89c85..6d1aa68 100644 --- a/circle.yml +++ b/circle.yml @@ -1,7 +1,12 @@ +machine: + services: + - docker + dependencies: override: - - go get github.com/constabulary/gb/... + - docker info + - docker build -t agonzalezro/polo . test: override: - - gb test + - docker run --entrypoint go agonzalezro/polo test $(docker run --entrypoint glide agonzalezro/polo novendor) diff --git a/cmd/polo/main.go b/cmd/polo/main.go index 3b9157a..3416028 100644 --- a/cmd/polo/main.go +++ b/cmd/polo/main.go @@ -19,7 +19,7 @@ var ( startDaemon = app.Flag("start-daemon", "Start a simple HTTP server watching for markdown changes.").Short('d').Bool() port = app.Flag("port", "Port where to run the server.").Default("8080").Short('p').Int() - configPath = app.Flag("config", "The settings file.").Short('c').Default("config.json").ExistingFile() + configPath = app.Flag("config", "The settings file.").Short('c').Default("config.json").String() templatesBasePath = app.Flag("templates-base-path", fmt.Sprintf("Where the '%s/' folder resides (in case it exists).", site.TemplatesRelativePath)).Default(".").ExistingDir() @@ -85,7 +85,7 @@ func main() { } addr := fmt.Sprintf(":%d", *port) - log.Infof("Static server running on %s\n", addr) + log.Info("Static server running on ", addr) log.Fatal(http.ListenAndServe(addr, http.FileServer(http.Dir(*output)))) } } diff --git a/glide.lock b/glide.lock new file mode 100644 index 0000000..d39a9e6 --- /dev/null +++ b/glide.lock @@ -0,0 +1,38 @@ +hash: 983ed1ffb63d870540f78a6f2e0174c0fb7784589092d0d41345f33615fe40e0 +updated: 2016-05-02T12:59:00.391068039+02:00 +imports: +- name: github.com/alecthomas/template + version: a0175ee3bccc567396460bf5acd36800cb10c49c +- name: github.com/alecthomas/units + version: 2efee857e7cfd4f3d0138cc3cbb1b4966962b93a +- name: github.com/davecgh/go-spew + version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d + subpackages: + - spew +- name: github.com/getsentry/raven-go + version: e39495fea085e98d1281fac0ff4d6eb8dc56f86d +- name: github.com/jessevdk/go-flags + version: 6b9493b3cb60367edd942144879646604089e3f7 +- name: github.com/pmezard/go-difflib + version: d8ed2627bdf02c080bf22230dbb337003b7aba2d + subpackages: + - difflib +- name: github.com/russross/blackfriday + version: 77efab57b2f74dd3f9051c79752b2e8995c8b789 +- name: github.com/shurcooL/sanitized_anchor_name + version: 10ef21a441db47d8b13ebcc5fd2310f636973c77 +- name: github.com/Sirupsen/logrus + version: 51fe59aca108dc5680109e7b2051cbdcfa5a253c +- name: github.com/stretchr/objx + version: cbeaeb16a013161a98496fad62933b1d21786672 +- name: github.com/stretchr/testify + version: c5d7a69bf8a2c9c374798160849c071093e41dd1 +- name: github.com/tobi/airbrake-go + version: a3cdd910a3ffef88a20fbecc10363a520ad61a0a +- name: golang.org/x/sys + version: b776ec39b3e54652e09028aaaaac9757f4f8211a +- name: gopkg.in/alecthomas/kingpin.v2 + version: 8cccfa8eb2e3183254457fb1749b2667fbc364c7 +- name: gopkg.in/fsnotify.v1 + version: 30411dbcefb7a1da7e84f75530ad3abe4011b4f8 +devImports: [] diff --git a/glide.yaml b/glide.yaml index bf367a0..8de7167 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,4 +1,3 @@ -parent: null package: main import: - package: github.com/Sirupsen/logrus @@ -6,3 +5,4 @@ import: - package: github.com/jessevdk/go-flags - package: github.com/russross/blackfriday - package: gopkg.in/alecthomas/kingpin.v2 +- package: github.com/stretchr/testify