Skip to content

Commit

Permalink
Multistage k6 Dockerfile, add code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
borjacampina committed Nov 26, 2017
1 parent d7aa28e commit b65a5d0
Show file tree
Hide file tree
Showing 26 changed files with 5,649 additions and 9 deletions.
22 changes: 20 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ jobs:
build:
docker:
- image: circleci/golang:latest
environment:
GOPATH: /home/circleci/.go_workspace
working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6
steps:
- checkout
- setup_remote_docker:
Expand All @@ -13,14 +16,29 @@ jobs:
git submodule update --init
docker info
echo "{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_AUTH\",\"email\":\"$DOCKER_EMAIL\"}}" >~/.dockercfg
- run:
name: Run linter
command: |
export PATH=$GOPATH/bin:$PATH
go get -t ./...
go get -u github.com/alecthomas/gometalinter
gometalinter --install
gometalinter --deadline 10m --config gometalinter.json --vendor ./...
- run:
name: Run tests and code coverage
command: |
export PATH=$GOPATH/bin:$PATH
go get github.com/axw/gocov/gocov
go get github.com/mattn/goveralls
gocov test -timeout 30s ./... > ~/coverage.json
goveralls -service=circle-ci -gocovdata=~/coverage.json -repotoken=$COVERALLS_REPO_TOKEN || true
- run:
name: Build application Docker image
command: |
docker build -t loadimpact/k6 .
- run:
name: Run tests
name: Run tests on generated Docker image
command: |
docker run --entrypoint /bin/sh loadimpact/k6 -c 'apk --no-cache add --virtual .deps git make build-base && cd $GOPATH/src/github.com/loadimpact/k6 && go get -t ./... && go get github.com/alecthomas/gometalinter && gometalinter --install && make check'
docker run loadimpact/k6 --help
docker run loadimpact/k6 help
docker run loadimpact/k6 run --help
Expand Down
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
FROM golang:1.9-alpine

FROM golang:1.9-alpine as builder
WORKDIR $GOPATH/src/github.com/loadimpact/k6
ADD . .
RUN apk --no-cache add --virtual .build-deps make git build-base && \
go get . && go install . && rm -rf $GOPATH/pkg && \
apk del .build-deps
RUN apk --no-cache add --virtual .build-deps git make build-base && \
go get . && CGO_ENABLED=0 go install -a -ldflags '-s -w' && \
go get github.com/GeertJohan/go.rice && \
cd $GOPATH/src/github.com/GeertJohan/go.rice/rice && \
go get . && go install && \
cd $GOPATH/src/github.com/loadimpact/k6 && \
rice append --exec=$GOPATH/bin/k6 -i ./js/compiler -i ./js/lib

ENTRYPOINT ["k6"]
FROM scratch
WORKDIR /root/
COPY --from=builder /go/bin/k6 /root
ENTRYPOINT ["./k6"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ format:

.PHONY: check
check:
gometalinter --deadline 10m --config gometalinter.json ./...
gometalinter --deadline 10m --config gometalinter.json --vendor ./...
go test -timeout 30s ./...

.PHONY: docs
Expand Down
15 changes: 15 additions & 0 deletions vendor/github.com/davecgh/go-spew/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

152 changes: 152 additions & 0 deletions vendor/github.com/davecgh/go-spew/spew/bypass.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions vendor/github.com/davecgh/go-spew/spew/bypasssafe.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b65a5d0

Please sign in to comment.