Skip to content

Commit

Permalink
feat: support Sail CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsharratt authored and pvdlg committed Sep 17, 2018
1 parent 6f9321d commit 06fb5b0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ if (isCI) {
| [Drone](https://readme.drone.io/reference/environ/) | `drone` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| [Gitlab CI/CD](https://docs.gitlab.com/ce/ci/variables/README.html) | `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: |
| [Jenkins](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) | `jenkins` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
| [Sail CI](https://sail.ci/docs/environment-variables) | `sail` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [Semaphore](https://semaphoreci.com/docs/available-environment-variables.html) | `semaphore` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [Shippable](http://docs.shippable.com/ci/env-vars/#stdEnv) | `shippable` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [TeamCity](https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters) | `teamcity` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const services = {
drone: require('./lib/drone'),
gitlab: require('./lib/gitlab'),
jenkins: require('./lib/jenkins'),
sail: require('./lib/sail'),
semaphore: require('./lib/semaphore'),
shippable: require('./lib/shippable'),
teamcity: require('./lib/teamcity'),
Expand Down
19 changes: 19 additions & 0 deletions lib/sail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// https://sail.ci/docs/environment-variables

module.exports = {
detect({env}) {
return Boolean(env.SAILCI);
},
configuration({env}) {
return {
name: 'Sail CI',
service: 'sail',
commit: env.SAIL_COMMIT_SHA,
branch: env.SAIL_COMMIT_BRANCH,
slug: `${env.SAIL_REPO_OWNER}/${env.SAIL_REPO_NAME}`,
root: env.SAIL_CLONE_DIR,
pr: env.SAIL_PULL_REQUEST_NUMBER,
isPr: Boolean(env.SAIL_PULL_REQUEST_NUMBER),
};
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"git",
"gitlab",
"jenkins",
"sail",
"semaphore",
"shippable",
"teamcity",
Expand Down
7 changes: 7 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ test('Jenkins', async t => {
t.is(service, 'jenkins');
});

test('Sail CI', t => {
const {isCi, service} = m({env: {SAILCI: 'true'}});

t.is(isCi, true);
t.is(service, 'sail');
});

test('Semaphore', async t => {
const {cwd} = await gitRepo();
await gitCommit('Test commit message', {cwd});
Expand Down
36 changes: 36 additions & 0 deletions test/sail.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import test from 'ava';
import sail from '../lib/sail';

const env = {
SAIL_COMMIT_SHA: 'full-commit-sha',
SAIL_COMMIT_BRANCH: 'master',
SAIL_REPO_OWNER: 'owner',
SAIL_REPO_NAME: 'repo',
SAIL_CLONE_DIR: '/workspace/repo',
};

test('Push', t => {
t.deepEqual(sail.configuration({env}), {
name: 'Sail CI',
service: 'sail',
commit: 'full-commit-sha',
branch: 'master',
slug: 'owner/repo',
pr: undefined,
isPr: false,
root: '/workspace/repo',
});
});

test('PR', t => {
t.deepEqual(sail.configuration({env: Object.assign({}, env, {SAIL_PULL_REQUEST_NUMBER: '10'})}), {
name: 'Sail CI',
service: 'sail',
commit: 'full-commit-sha',
branch: 'master',
slug: 'owner/repo',
root: '/workspace/repo',
pr: '10',
isPr: true,
});
});

0 comments on commit 06fb5b0

Please sign in to comment.