mirror of
https://github.com/minio/mc.git
synced 2025-11-12 01:02:26 +03:00
Migrate to go1.11.4 for CI builds (#2634)
This commit is contained in:
committed by
kannappanr
parent
124b9fa4d9
commit
bda754d07f
53
.travis.yml
53
.travis.yml
@@ -1,26 +1,41 @@
|
|||||||
sudo: false
|
go_import_path: github.com/minio/mc
|
||||||
|
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
os:
|
# this ensures PRs based on a local branch are not built twice
|
||||||
- linux
|
# 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:
|
matrix:
|
||||||
- ARCH=x86_64
|
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:
|
before_script:
|
||||||
- 1.10.4
|
# Add an IPv6 config - see the corresponding Travis issue
|
||||||
|
# https://github.com/travis-ci/travis-ci/issues/8361
|
||||||
addons:
|
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6'; fi
|
||||||
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 "")
|
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
|||||||
21
Dockerfile
21
Dockerfile
@@ -1,19 +1,24 @@
|
|||||||
FROM golang:1.10.1-alpine3.7
|
FROM golang:1.11.4-alpine3.7
|
||||||
|
|
||||||
MAINTAINER Minio Inc <dev@minio.io>
|
LABEL maintainer="Minio Inc <dev@minio.io>"
|
||||||
|
|
||||||
ENV PATH $PATH:$GOPATH/bin
|
ENV GOPATH /go
|
||||||
ENV CGO_ENABLED 0
|
ENV CGO_ENABLED 0
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/minio/
|
WORKDIR /go/src/github.com/minio/
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
apk add --no-cache ca-certificates && \
|
apk add --no-cache git && \
|
||||||
apk add --no-cache --virtual .build-deps git && \
|
|
||||||
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
|
|
||||||
go get -v -d github.com/minio/mc && \
|
go get -v -d github.com/minio/mc && \
|
||||||
cd /go/src/github.com/minio/mc && \
|
cd /go/src/github.com/minio/mc && \
|
||||||
go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)" && \
|
go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)"
|
||||||
rm -rf /go/pkg /go/src /usr/local/go && apk del .build-deps
|
|
||||||
|
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"]
|
ENTRYPOINT ["mc"]
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -23,8 +23,7 @@ verifiers: getdeps vet fmt lint cyclo deadcode spelling
|
|||||||
|
|
||||||
vet:
|
vet:
|
||||||
@echo "Running $@"
|
@echo "Running $@"
|
||||||
@go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult cmd
|
@go vet github.com/minio/mc/...
|
||||||
@go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult pkg
|
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
@echo "Running $@"
|
@echo "Running $@"
|
||||||
@@ -58,7 +57,7 @@ spelling:
|
|||||||
check: test
|
check: test
|
||||||
test: verifiers build
|
test: verifiers build
|
||||||
@echo "Running unit tests"
|
@echo "Running unit tests"
|
||||||
@go test $(GOFLAGS) -tags kqueue ./...
|
@go test -tags kqueue ./...
|
||||||
@echo "Running functional tests"
|
@echo "Running functional tests"
|
||||||
@(env bash $(PWD)/functional-tests.sh)
|
@(env bash $(PWD)/functional-tests.sh)
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ coverage: build
|
|||||||
# Builds minio locally.
|
# Builds minio locally.
|
||||||
build: checks
|
build: checks
|
||||||
@echo "Building minio binary to './mc'"
|
@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:
|
pkg-add:
|
||||||
@echo "Adding new package $(PKG)"
|
@echo "Adding new package $(PKG)"
|
||||||
@@ -95,6 +94,7 @@ install: build
|
|||||||
clean:
|
clean:
|
||||||
@echo "Cleaning up all the generated files"
|
@echo "Cleaning up all the generated files"
|
||||||
@find . -name '*.test' | xargs rm -fv
|
@find . -name '*.test' | xargs rm -fv
|
||||||
|
@find . -name '*~' | xargs rm -fv
|
||||||
@rm -rvf mc
|
@rm -rvf mc
|
||||||
@rm -rvf build
|
@rm -rvf build
|
||||||
@rm -rvf release
|
@rm -rvf release
|
||||||
|
|||||||
55
appveyor.yml
55
appveyor.yml
@@ -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=<temp.txt
|
|
||||||
- go build -ldflags="%BUILD_LDFLAGS%" -o %GOPATH%\bin\mc.exe
|
|
||||||
- appveyor AddCompilationMessage "Compile Success"
|
|
||||||
|
|
||||||
# To run your custom scripts instead of automatic tests
|
|
||||||
test_script:
|
|
||||||
# Unit tests
|
|
||||||
- ps: Add-AppveyorTest "Unit Tests" -Outcome Running
|
|
||||||
- mkdir build\coverage
|
|
||||||
- for /f "" %%G in ('go list github.com/minio/mc/...') do ( go test -v -race %%G )
|
|
||||||
- go test -v -coverprofile=build\coverage\coverage.txt -covermode=atomic github.com/minio/mc/cmd
|
|
||||||
- ps: Update-AppveyorTest "Unit Tests" -Outcome Passed
|
|
||||||
|
|
||||||
after_test:
|
|
||||||
- go tool cover -html=build\coverage\coverage.txt -o build\coverage\coverage.html
|
|
||||||
- ps: Push-AppveyorArtifact build\coverage\coverage.txt
|
|
||||||
- ps: Push-AppveyorArtifact build\coverage\coverage.html
|
|
||||||
# Upload coverage report.
|
|
||||||
- "SET PATH=C:\\Python34;C:\\Python34\\Scripts;%PATH%"
|
|
||||||
- pip install codecov
|
|
||||||
- codecov -X gcov -f "build\coverage\coverage.txt"
|
|
||||||
|
|
||||||
# to disable deployment
|
|
||||||
deploy: off
|
|
||||||
@@ -19,52 +19,53 @@ package cmd
|
|||||||
import "testing"
|
import "testing"
|
||||||
|
|
||||||
// Tests valid host URL functionality.
|
// Tests valid host URL functionality.
|
||||||
func TestparseEnvURLStr(t *testing.T) {
|
func TestParseEnvURLStr(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
hostURL string
|
hostURL string
|
||||||
accessKey string
|
accessKey string
|
||||||
secretKey string
|
secretKey string
|
||||||
url string
|
hostname string
|
||||||
|
port string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
hostURL: "https://minio:minio1#23@localhost:9000",
|
hostURL: "https://minio:minio1#23@localhost:9000",
|
||||||
accessKey: "minio",
|
accessKey: "minio",
|
||||||
secretKey: "minio#123",
|
secretKey: "minio1#23",
|
||||||
url: "https://localhost:9000",
|
hostname: "localhost",
|
||||||
|
port: "9000",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hostURL: "https://minio:minio123@localhost:9000",
|
hostURL: "https://minio:minio123@localhost:9000",
|
||||||
accessKey: "minio",
|
accessKey: "minio",
|
||||||
secretKey: "minio123",
|
secretKey: "minio123",
|
||||||
url: "https://localhost:9000",
|
hostname: "localhost",
|
||||||
},
|
port: "9000",
|
||||||
{
|
|
||||||
hostURL: "http://minio:minio1#23@localhost:9000",
|
|
||||||
accessKey: "minio",
|
|
||||||
secretKey: "minio#123",
|
|
||||||
url: "http://localhost:9000",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hostURL: "https://localhost:9000",
|
hostURL: "https://localhost:9000",
|
||||||
accessKey: "",
|
accessKey: "",
|
||||||
secretKey: "",
|
secretKey: "",
|
||||||
url: "https://localhost:9000",
|
hostname: "localhost",
|
||||||
|
port: "9000",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
url, ak, sk, err := parseEnvURLStr(testCase.hostURL)
|
url, ak, sk, err := parseEnvURLStr(testCase.hostURL)
|
||||||
if testCase.accessKey != sk {
|
if testCase.accessKey != ak {
|
||||||
t.Fatalf("Expected %s, got %s", testCase.accessKey, ak)
|
t.Fatalf("Test %d: Expected %s, got %s", i+1, testCase.accessKey, ak)
|
||||||
}
|
}
|
||||||
if testCase.secretKey != sk {
|
if testCase.secretKey != sk {
|
||||||
t.Fatalf("Expected %s, got %s", testCase.secretKey, sk)
|
t.Fatalf("Test %d: Expected %s, got %s", i+1, testCase.secretKey, sk)
|
||||||
}
|
}
|
||||||
if testCase.url != url.Hostname() {
|
if testCase.hostname != url.Hostname() {
|
||||||
t.Fatalf("Expected %s, got %s", testCase.url, url.Hostname())
|
t.Fatalf("Test %d: Expected %s, got %s", i+1, testCase.hostname, url.Hostname())
|
||||||
|
}
|
||||||
|
if testCase.port != url.Port() {
|
||||||
|
t.Fatalf("Test %d: Expected %s, got %s", i+1, testCase.port, url.Port())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Expected test to pass. Failed with err %s", err)
|
t.Fatalf("Test %d: Expected test to pass. Failed with err %s", i+1, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user