Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Check for CI env var to catch unknown CI envs #130

Merged
merged 1 commit into from Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/environment.js
Expand Up @@ -49,6 +49,9 @@ class Environment {
return 'probo';
} else if (this._env.BITBUCKET_BUILD_NUMBER) {
return 'bitbucket';
} else if (this._env.CI) {
// this should always be the last branch
return 'CI/unknown';
}

return null;
Expand Down
26 changes: 26 additions & 0 deletions test/environment-test.js
Expand Up @@ -186,6 +186,32 @@ COMMIT_MESSAGE:A shiny new feature`);
});
});

context('in an unknown CI', function() {
beforeEach(function() {
environment = new Environment({
CI: 'true',
});
});

it('returns the right CI value', function() {
assert.strictEqual(environment.ci, 'CI/unknown');
});
});

context('in a known CI env with CI = true', function() {
beforeEach(function() {
environment = new Environment({
TRAVIS_BUILD_ID: '1234`',
CI: 'true',
});
});

it('returns the right CI value', function() {
assert.notEqual(environment.ci, 'CI/unknown');
assert.strictEqual(environment.ci, 'travis');
});
});

context('in Travis CI', function() {
beforeEach(function() {
environment = new Environment({
Expand Down