diff --git a/.travis.yml b/.travis.yml index 2eb1bf2b..2060b3ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,41 @@ -sudo: false +go_import_path: github.com/minio/mc + language: go -os: -- linux +# this ensures PRs based on a local branch are not built twice +# the downside is that a PR targeting a different branch is not built +# but as a workaround you can add the branch to this list +branches: + only: + - master -env: -- ARCH=x86_64 +matrix: + include: + - os: linux + dist: trusty + env: + - ARCH=x86_64 + go: 1.11.4 + script: + - diff -au <(gofmt -d *.go) <(printf "") + - diff -au <(gofmt -d cmd) <(printf "") + - diff -au <(gofmt -d pkg) <(printf "") + - for d in $(go list ./...); do go test -v -race "$d"; done + - make coverage + - make test + - os: windows + env: + - ARCH=x86_64 + go: 1.11.4 + script: + - go build --ldflags="$(go run buildscripts/gen-ldflags.go)" -o %GOPATH%\bin\mc.exe + - for d in $(go list ./...); do go test -v -race "$d"; done + - bash buildscripts/go-coverage.sh -go: -- 1.10.4 - -addons: - apt: - packages: - - devscripts - -script: - - make test GOFLAGS="-race" - - make coverage - - diff -au <(gofmt -d *.go) <(printf "") - - diff -au <(gofmt -d cmd) <(printf "") - - diff -au <(gofmt -d pkg) <(printf "") +before_script: + # Add an IPv6 config - see the corresponding Travis issue + # https://github.com/travis-ci/travis-ci/issues/8361 + - if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'; fi after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Dockerfile b/Dockerfile index 1dc62fbd..a2c64422 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,24 @@ -FROM golang:1.10.1-alpine3.7 +FROM golang:1.11.4-alpine3.7 -MAINTAINER Minio Inc +LABEL maintainer="Minio Inc " -ENV PATH $PATH:$GOPATH/bin +ENV GOPATH /go ENV CGO_ENABLED 0 WORKDIR /go/src/github.com/minio/ RUN \ - apk add --no-cache ca-certificates && \ - apk add --no-cache --virtual .build-deps git && \ - echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ + apk add --no-cache git && \ go get -v -d github.com/minio/mc && \ cd /go/src/github.com/minio/mc && \ - go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" && \ - rm -rf /go/pkg /go/src /usr/local/go && apk del .build-deps + go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" + +FROM alpine:3.7 + +COPY --from=0 /go/bin/mc /usr/bin/mc + +RUN \ + apk add --no-cache ca-certificates && \ + echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf ENTRYPOINT ["mc"] diff --git a/Makefile b/Makefile index 5e9cba98..e29f355a 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,7 @@ verifiers: getdeps vet fmt lint cyclo deadcode spelling vet: @echo "Running $@" - @go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult cmd - @go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult pkg + @go vet github.com/minio/mc/... fmt: @echo "Running $@" @@ -58,7 +57,7 @@ spelling: check: test test: verifiers build @echo "Running unit tests" - @go test $(GOFLAGS) -tags kqueue ./... + @go test -tags kqueue ./... @echo "Running functional tests" @(env bash $(PWD)/functional-tests.sh) @@ -69,7 +68,7 @@ coverage: build # Builds minio locally. build: checks @echo "Building minio binary to './mc'" - @CGO_ENABLED=0 go build -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/mc + @GO_FLAGS="" CGO_ENABLED=0 go build -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/mc pkg-add: @echo "Adding new package $(PKG)" @@ -95,6 +94,7 @@ install: build clean: @echo "Cleaning up all the generated files" @find . -name '*.test' | xargs rm -fv + @find . -name '*~' | xargs rm -fv @rm -rvf mc @rm -rvf build @rm -rvf release diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index cee077c4..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,55 +0,0 @@ -# version format -version: "{build}" - -# Operating system (build VM template) -os: Windows Server 2012 R2 - -# Platform. -platform: x64 - -clone_folder: c:\gopath\src\github.com\minio\mc - -# Environment variables -environment: - GOPATH: c:\gopath - GOROOT: c:\go110 - -# scripts that run after cloning repository -install: - - set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH% - - go version - - go env - - python --version - -# To run your custom scripts instead of automatic MSBuild -build_script: - # Compile - # We need to disable firewall - https://github.com/appveyor/ci/issues/1579#issuecomment-309830648 - - ps: Disable-NetFirewallRule -DisplayName 'File and Printer Sharing (SMB-Out)' - - appveyor AddCompilationMessage "Starting Compile" - - cd c:\gopath\src\github.com\minio\mc - - go run buildscripts/gen-ldflags.go > temp.txt - - set /p BUILD_LDFLAGS=