mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
CI: Download minio server, do not compile latest master
This commit is contained in:
parent
1fde872016
commit
b64006221c
@ -41,12 +41,15 @@ ENV PATH $PATH:$GOPATH/bin
|
|||||||
|
|
||||||
RUN mkdir -p $GOPATH/src/github.com/restic/restic
|
RUN mkdir -p $GOPATH/src/github.com/restic/restic
|
||||||
|
|
||||||
# install tools
|
# pre-install tools, this speeds up running the tests itself
|
||||||
|
RUN go get github.com/tools/godep
|
||||||
RUN go get golang.org/x/tools/cmd/cover
|
RUN go get golang.org/x/tools/cmd/cover
|
||||||
RUN go get github.com/mattn/goveralls
|
RUN go get github.com/mattn/goveralls
|
||||||
RUN go get github.com/mitchellh/gox
|
RUN go get github.com/mitchellh/gox
|
||||||
RUN go get github.com/pierrre/gotestcover
|
RUN go get github.com/pierrre/gotestcover
|
||||||
RUN GO15VENDOREXPERIMENT=1 go get github.com/minio/minio
|
RUN mkdir $HOME/bin \
|
||||||
|
&& wget -q -O $HOME/bin/minio https://dl.minio.io/server/minio/release/linux-amd64/minio \
|
||||||
|
&& chmod +x $HOME/bin/minio
|
||||||
|
|
||||||
# set TRAVIS_BUILD_DIR for integration script
|
# set TRAVIS_BUILD_DIR for integration script
|
||||||
ENV TRAVIS_BUILD_DIR $GOPATH/src/github.com/restic/restic
|
ENV TRAVIS_BUILD_DIR $GOPATH/src/github.com/restic/restic
|
||||||
|
@ -6,7 +6,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -17,6 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var runCrossCompile = flag.Bool("cross-compile", true, "run cross compilation tests")
|
var runCrossCompile = flag.Bool("cross-compile", true, "run cross compilation tests")
|
||||||
|
var minioServer = flag.String("minio", "", "path to the minio server binary")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@ -30,10 +33,54 @@ type CIEnvironment interface {
|
|||||||
type TravisEnvironment struct {
|
type TravisEnvironment struct {
|
||||||
goxArch []string
|
goxArch []string
|
||||||
goxOS []string
|
goxOS []string
|
||||||
|
minio string
|
||||||
}
|
}
|
||||||
|
|
||||||
var envVendorExperiment = map[string]string{
|
func (env *TravisEnvironment) getMinio() {
|
||||||
"GO15VENDOREXPERIMENT": "1",
|
if *minioServer != "" {
|
||||||
|
msg("using minio server at %q\n", *minioServer)
|
||||||
|
env.minio = *minioServer
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tempfile, err := ioutil.TempFile("", "minio-server-")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "create tempfile failed: %v\n", err)
|
||||||
|
os.Exit(10)
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := http.Get("https://dl.minio.io/server/minio/release/linux-amd64/minio")
|
||||||
|
if err != nil {
|
||||||
|
msg("downloading minio failed: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.Copy(tempfile, res.Body)
|
||||||
|
if err != nil {
|
||||||
|
msg("downloading minio failed: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = res.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
msg("saving minio failed: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tempfile.Close()
|
||||||
|
if err != nil {
|
||||||
|
msg("closing tempfile failed: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.Chmod(tempfile.Name(), 0755)
|
||||||
|
if err != nil {
|
||||||
|
msg("making minio server executable failed: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("downloaded minio server to %v\n", tempfile.Name())
|
||||||
|
env.minio = tempfile.Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *TravisEnvironment) Prepare() {
|
func (env *TravisEnvironment) Prepare() {
|
||||||
@ -42,9 +89,7 @@ func (env *TravisEnvironment) Prepare() {
|
|||||||
run("go", "get", "golang.org/x/tools/cmd/cover")
|
run("go", "get", "golang.org/x/tools/cmd/cover")
|
||||||
run("go", "get", "github.com/mattn/goveralls")
|
run("go", "get", "github.com/mattn/goveralls")
|
||||||
run("go", "get", "github.com/pierrre/gotestcover")
|
run("go", "get", "github.com/pierrre/gotestcover")
|
||||||
if goVersionAtLeast151() {
|
env.getMinio()
|
||||||
runWithEnv(envVendorExperiment, "go", "get", "github.com/minio/minio")
|
|
||||||
}
|
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
// install the libraries necessary for fuse
|
// install the libraries necessary for fuse
|
||||||
@ -127,8 +172,8 @@ func (env *TravisEnvironment) RunTests() {
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if goVersionAtLeast151() {
|
if env.minio != "" {
|
||||||
srv, err = NewMinioServer()
|
srv, err = NewMinioServer(env.minio)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error running minio server: %v", err)
|
fmt.Fprintf(os.Stderr, "error running minio server: %v", err)
|
||||||
os.Exit(8)
|
os.Exit(8)
|
||||||
@ -275,7 +320,7 @@ var minioEnv = map[string]string{
|
|||||||
|
|
||||||
// NewMinioServer prepares and runs a minio server for the s3 backend tests in
|
// NewMinioServer prepares and runs a minio server for the s3 backend tests in
|
||||||
// a temporary directory.
|
// a temporary directory.
|
||||||
func NewMinioServer() (*MinioServer, error) {
|
func NewMinioServer(minio string) (*MinioServer, error) {
|
||||||
msg("running minio server\n")
|
msg("running minio server\n")
|
||||||
cfgdir, err := ioutil.TempDir("", "minio-config-")
|
cfgdir, err := ioutil.TempDir("", "minio-config-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -304,7 +349,7 @@ func NewMinioServer() (*MinioServer, error) {
|
|||||||
|
|
||||||
out := bytes.NewBuffer(nil)
|
out := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
cmd := exec.Command("minio",
|
cmd := exec.Command(minio,
|
||||||
"--config-folder", cfgdir,
|
"--config-folder", cfgdir,
|
||||||
"--address", "127.0.0.1:9000",
|
"--address", "127.0.0.1:9000",
|
||||||
"server", dir)
|
"server", dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user