Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
73b3c304
Commit
73b3c304
authored
Jan 14, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci-pkgs: added travis and jenkins ci pkgs
parent
01283b92
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
196 additions
and
0 deletions
+196
-0
util/testutil/ci/ci.go
util/testutil/ci/ci.go
+52
-0
util/testutil/ci/jenkins/jenkins.go
util/testutil/ci/jenkins/jenkins.go
+58
-0
util/testutil/ci/jenkins/jenkins_test.go
util/testutil/ci/jenkins/jenkins_test.go
+16
-0
util/testutil/ci/travis/travis.go
util/testutil/ci/travis/travis.go
+57
-0
util/testutil/ci/travis/travis_test.go
util/testutil/ci/travis/travis_test.go
+13
-0
No files found.
util/testutil/ci/ci.go
0 → 100644
View file @
73b3c304
// Package ci implements some helper functions to use during
// tests. Many times certain facilities are not available, or tests
// must run differently.
package
ci
import
(
"os"
jenkins
"github.com/jbenet/go-ipfs/util/testutil/ci/jenkins"
travis
"github.com/jbenet/go-ipfs/util/testutil/ci/travis"
)
// EnvVar is a type to use travis-only env var names with
// the type system.
type
EnvVar
string
// Environment variables that TravisCI uses.
const
(
VarCI
EnvVar
=
"TEST_NO_FUSE"
VarNoFuse
EnvVar
=
"TEST_NO_FUSE"
VarVerbose
EnvVar
=
"TEST_VERBOSE"
)
// IsRunning attempts to determine whether this process is
// running on CI. This is done by checking any of:
//
// CI=true
// travis.IsRunning()
// jenkins.IsRunning()
//
func
IsRunning
()
bool
{
if
os
.
Getenv
(
string
(
VarCI
))
==
"true"
{
return
true
}
return
travis
.
IsRunning
()
||
jenkins
.
IsRunning
()
}
// Env returns the value of a CI env variable.
func
Env
(
v
EnvVar
)
string
{
return
os
.
Getenv
(
string
(
v
))
}
// Returns whether FUSE is explicitly disabled wiht TEST_NO_FUSE.
func
NoFuse
(
v
EnvVar
)
bool
{
return
os
.
Getenv
(
string
(
VarNoFuse
))
==
"1"
}
// Returns whether TEST_VERBOSE is enabled.
func
Verbose
(
v
EnvVar
)
bool
{
return
os
.
Getenv
(
string
(
VarVerbose
))
==
"1"
}
util/testutil/ci/jenkins/jenkins.go
0 → 100644
View file @
73b3c304
// Package jenkins implements some helper functions to use during
// tests. Many times certain facilities are not available, or tests
// must run differently.
package
jenkins
import
(
"os"
"strings"
)
// EnvVar is a type to use travis-only env var names with
// the type system.
type
EnvVar
string
// Environment variables that TravisCI uses.
const
(
VarBuildNumber
EnvVar
=
"BUILD_NUMBER"
VarBuildId
EnvVar
=
"BUILD_ID"
VarBuildUrl
EnvVar
=
"BUILD_URL"
VarNodeName
EnvVar
=
"NODE_NAME"
VarJobName
EnvVar
=
"JOB_NAME"
VarBuildTag
EnvVar
=
"BUILD_TAG"
VarJenkinsUrl
EnvVar
=
"JENKINS_URL"
VarExecutorNumber
EnvVar
=
"EXECUTOR_NUMBER"
VarJavaHome
EnvVar
=
"JAVA_HOME"
VarWorkspace
EnvVar
=
"WORKSPACE"
VarSvnRevision
EnvVar
=
"SVN_REVISION"
VarCvsBranch
EnvVar
=
"CVS_BRANCH"
VarGitCommit
EnvVar
=
"GIT_COMMIT"
VarGitUrl
EnvVar
=
"GIT_URL"
VarGitBranch
EnvVar
=
"GIT_BRANCH"
)
// IsRunning attempts to determine whether this process is
// running on Jenkins CI. This is done by checking any of the
// following:
//
// JENKINS_URL is set
// BuildTag has prefix "jenkins-"
//
func
IsRunning
()
bool
{
return
len
(
Env
(
VarJenkinsUrl
))
>
0
||
strings
.
HasPrefix
(
Env
(
VarBuildTag
),
"jenkins-"
)
}
// Env returns the value of a travis env variable.
func
Env
(
v
EnvVar
)
string
{
return
os
.
Getenv
(
string
(
v
))
}
// JobName returns the jenkins JOB_NAME of this build.
func
JobName
()
string
{
return
Env
(
VarJobName
)
}
// BuildTag returns the jenkins BUILD_TAG.
func
BuildTag
()
string
{
return
Env
(
VarBuildTag
)
}
util/testutil/ci/jenkins/jenkins_test.go
0 → 100644
View file @
73b3c304
package
jenkins
import
(
"os"
"strings"
"testing"
)
func
TestIsRunning
(
t
*
testing
.
T
)
{
hasPrefix
:=
strings
.
HasPrefix
(
os
.
Getenv
(
"BUILD_TAG"
),
"jenkins-"
)
tr
:=
len
(
os
.
Getenv
(
"JENKINS_URL"
))
>
0
||
hasPrefix
if
tr
!=
IsRunning
()
{
t
.
Error
(
"IsRunning() does not match TRAVIS && CI env var check"
)
}
}
util/testutil/ci/travis/travis.go
0 → 100644
View file @
73b3c304
// Package travis implements some helper functions to use during
// tests. Many times certain facilities are not available, or tests
// must run differently.
package
travis
import
"os"
// EnvVar is a type to use travis-only env var names with
// the type system.
type
EnvVar
string
// Environment variables that TravisCI uses.
const
(
VarCI
EnvVar
=
"CI"
VarTravis
EnvVar
=
"TRAVIS"
VarBranch
EnvVar
=
"TRAVIS_BRANCH"
VarBuildDir
EnvVar
=
"TRAVIS_BUILD_DIR"
VarBuildId
EnvVar
=
"TRAVIS_BUILD_ID"
VarBuildNumber
EnvVar
=
"TRAVIS_BUILD_NUMBER"
VarCommit
EnvVar
=
"TRAVIS_COMMIT"
VarCommitRange
EnvVar
=
"TRAVIS_COMMIT_RANGE"
VarJobId
EnvVar
=
"TRAVIS_JOB_ID"
VarJobNumber
EnvVar
=
"TRAVIS_JOB_NUMBER"
VarPullRequest
EnvVar
=
"TRAVIS_PULL_REQUEST"
VarSecureEnvVars
EnvVar
=
"TRAVIS_SECURE_ENV_VARS"
VarRepoSlug
EnvVar
=
"TRAVIS_REPO_SLUG"
VarOsName
EnvVar
=
"TRAVIS_OS_NAME"
VarTag
EnvVar
=
"TRAVIS_TAG"
VarGoVersion
EnvVar
=
"TRAVIS_GO_VERSION"
)
// IsRunning attempts to determine whether this process is
// running on Travis-CI. This is done by checking ALL of the
// following env vars are set:
//
// CI=true
// TRAVIS=true
//
// Note: cannot just check CI.
func
IsRunning
()
bool
{
return
Env
(
VarCI
)
==
"true"
&&
Env
(
VarTravis
)
==
"true"
}
// Env returns the value of a travis env variable.
func
Env
(
v
EnvVar
)
string
{
return
os
.
Getenv
(
string
(
v
))
}
// JobId returns the travis JOB_ID of this build.
func
JobId
()
string
{
return
Env
(
VarJobId
)
}
// JobNumber returns the travis JOB_NUMBER of this build.
func
JobNumber
()
string
{
return
Env
(
VarJobNumber
)
}
util/testutil/ci/travis/travis_test.go
0 → 100644
View file @
73b3c304
package
travis
import
(
"os"
"testing"
)
func
TestIsRunning
(
t
*
testing
.
T
)
{
tr
:=
os
.
Getenv
(
"TRAVIS"
)
==
"true"
&&
os
.
Getenv
(
"CI"
)
==
"true"
if
tr
!=
IsRunning
()
{
t
.
Error
(
"IsRunning() does not match TRAVIS && CI env var check"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment