Travis: Skip cloud backend tests for most Go versions

This commit is contained in:
Alexander Neumann 2018-04-01 11:28:46 +02:00
parent b077a1227b
commit b3a073e066
2 changed files with 45 additions and 55 deletions

View file

@ -1,33 +1,24 @@
language: go
sudo: false
go:
- "1.8.x"
- "1.9.x"
- "1.10"
os:
- linux
- osx
env:
matrix:
RESTIC_TEST_FUSE=0
matrix:
exclude:
- os: osx
go: "1.8.x"
- os: osx
go: "1.9.x"
- os: linux
go: "1.10"
include:
- os: linux
go: "1.10"
go: "1.8.x"
env: RESTIC_TEST_FUSE=0 RESTIC_TEST_CLOUD_BACKENDS=0
- os: linux
go: "1.9.x"
env: RESTIC_TEST_FUSE=0 RESTIC_TEST_CLOUD_BACKENDS=0
# only run fuse and cloud backends tests on Travis for the latest Go on Linux
- os: linux
go: "1.10.x"
sudo: true
env:
RESTIC_TEST_FUSE=1
- os: osx
go: "1.10.x"
env: RESTIC_TEST_FUSE=0 RESTIC_TEST_CLOUD_BACKENDS=0
branches:
only:

View file

@ -25,6 +25,17 @@ var ForbiddenImports = map[string]bool{
"errors": true,
}
// CloudBackends contains a map of backend tests for cloud services to one
// of the essential environment variables which must be present in order to
// test it.
var CloudBackends = map[string]string{
"restic/backend/s3.TestBackendS3": "RESTIC_TEST_S3_REPOSITORY",
"restic/backend/swift.TestBackendSwift": "RESTIC_TEST_SWIFT",
"restic/backend/b2.TestBackendB2": "RESTIC_TEST_B2_REPOSITORY",
"restic/backend/gs.TestBackendGS": "RESTIC_TEST_GS_REPOSITORY",
"restic/backend/azure.TestBackendAzure": "RESTIC_TEST_AZURE_REPOSITORY",
}
var runCrossCompile = flag.Bool("cross-compile", true, "run cross compilation tests")
func init() {
@ -132,6 +143,18 @@ func (env *TravisEnvironment) Prepare() error {
msg("gox: OS/ARCH %v\n", env.goxOSArch)
}
// do not run cloud tests on darwin
if os.Getenv("RESTIC_TEST_CLOUD_BACKENDS") == "0" {
msg("skipping cloud backend tests\n")
for _, name := range CloudBackends {
err := os.Unsetenv(name)
if err != nil {
msg(" error unsetting %v: %v\n", name, err)
}
}
}
// extract credentials file for GCS tests
if b64data := os.Getenv("RESTIC_TEST_GS_APPLICATION_CREDENTIALS_B64"); b64data != "" {
buf, err := base64.StdEncoding.DecodeString(b64data)
@ -176,12 +199,6 @@ func (env *TravisEnvironment) Teardown() error {
// RunTests starts the tests for Travis.
func (env *TravisEnvironment) RunTests() error {
// do not run fuse tests on darwin
if runtime.GOOS == "darwin" {
msg("skip fuse integration tests on %v\n", runtime.GOOS)
_ = os.Setenv("RESTIC_TEST_FUSE", "0")
}
env.env["GOPATH"] = os.Getenv("GOPATH")
if env.gcsCredentialsFile != "" {
env.env["GOOGLE_APPLICATION_CREDENTIALS"] = env.gcsCredentialsFile
@ -195,32 +212,14 @@ func (env *TravisEnvironment) RunTests() error {
"restic/backend/rclone.TestBackendRclone",
}
// if the test s3 repository is available, make sure that the test is not skipped
if os.Getenv("RESTIC_TEST_S3_REPOSITORY") != "" {
ensureTests = append(ensureTests, "restic/backend/s3.TestBackendS3")
// make sure that cloud backends for which we have credentials are not
// silently skipped.
for pkg, env := range CloudBackends {
if _, ok := os.LookupEnv(env); ok {
ensureTests = append(ensureTests, pkg)
} else {
msg("S3 repository not available\n")
msg("credentials for %v are not available, skipping\n", pkg)
}
// if the test swift service is available, make sure that the test is not skipped
if os.Getenv("RESTIC_TEST_SWIFT") != "" {
ensureTests = append(ensureTests, "restic/backend/swift.TestBackendSwift")
} else {
msg("Swift service not available\n")
}
// if the test b2 repository is available, make sure that the test is not skipped
if os.Getenv("RESTIC_TEST_B2_REPOSITORY") != "" {
ensureTests = append(ensureTests, "restic/backend/b2.TestBackendB2")
} else {
msg("B2 repository not available\n")
}
// if the test gs repository is available, make sure that the test is not skipped
if os.Getenv("RESTIC_TEST_GS_REPOSITORY") != "" {
ensureTests = append(ensureTests, "restic/backend/gs.TestBackendGS")
} else {
msg("GS repository not available\n")
}
env.env["RESTIC_TEST_DISALLOW_SKIP"] = strings.Join(ensureTests, ",")