diff --git a/.gitignore b/.gitignore index 2973712c..be867e15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store +_ci/coverage.txt gotenberg \ No newline at end of file diff --git a/Dockerfile.tests b/Dockerfile.tests index f2f1f2a7..8cdf7c37 100644 --- a/Dockerfile.tests +++ b/Dockerfile.tests @@ -25,8 +25,15 @@ RUN echo "deb http://httpredir.debian.org/debian/ stretch main contrib non-free" # | WORKDIR /go/src/github.com/gulien/gotenberg + +# Installs lint dependencies. +RUN go get -u gopkg.in/alecthomas/gometalinter.v2 &&\ + gometalinter.v2 --install + +# Copies our Go source. COPY . . +# Installs project dependencies. RUN go get -d -v ./... -CMD ["go", "test", "-race", "-cover", "./..."] \ No newline at end of file +ENTRYPOINT ["_ci/docker-entrypoint.sh"] \ No newline at end of file diff --git a/_ci/docker-entrypoint.sh b/_ci/docker-entrypoint.sh new file mode 100755 index 00000000..fb3bb0a0 --- /dev/null +++ b/_ci/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -xe + +# Statically checking Go source for errors and warnings. +gometalinter.v2 --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode -E gocyclo --vendor ./...; + +# Running tests according to current Gotenberg version. +if [[ "$VERSION" == "snapshot" ]]; then + for d in $(go list ./... | grep -v vendor); do + go test -race -cover $d; + done +else + echo "" > ./_ci/coverage.txt; + for d in $(go list ./... | grep -v vendor); do + go test -race -coverprofile=profile.out -covermode=atomic $d; + if [ -f profile.out ]; then + cat profile.out >> ./_ci/coverage.txt; + rm profile.out; + fi + done +fi + +# Bye! +exit 0; \ No newline at end of file diff --git a/_tests/file.doc b/_tests/file.doc deleted file mode 100644 index 2ff3c639..00000000 Binary files a/_tests/file.doc and /dev/null differ diff --git a/orbit.yml b/orbit.yml index 3325b4cf..722c668c 100644 --- a/orbit.yml +++ b/orbit.yml @@ -1,23 +1,15 @@ tasks: - - - use: install - short: Installs all required dev dependencies - run: - - go get -u github.com/golang/dep/cmd/dep - - go get -u gopkg.in/alecthomas/gometalinter.v2 - - gometalinter.v2 --install - - - use: lint - short: Formats the code and statically checks for errors and warnings + + - use: fmt + short: Runs go fmt ./... run: - go fmt ./... - - gometalinter.v2 --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode -E gocyclo --vendor ./... - use: tests short: Runs tests inside a container run: - docker build -t gotenberg:tests -f Dockerfile.tests . - - docker run --rm gotenberg:tests + - docker run --rm -e "VERSION={{ .Orbit.Version }}" -v "$(pwd)/_ci:/go/src/github.com/gulien/gotenberg/_ci" gotenberg:tests - use: build short: Builds a Linux binary and the Docker image