Skip to content

Commit

Permalink
feat: require Node.js 8.3
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove support for Node.js < 8.3
  • Loading branch information
pvdlg committed Jun 6, 2019
1 parent f49ac93 commit 542be77
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: node_js

node_js:
- 12
- 10
- 8
- 6

branches:
only:
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const services = {
module.exports = ({env = process.env, cwd = process.cwd()} = {}) => {
for (const name of Object.keys(services)) {
if (services[name].detect({env, cwd})) {
return Object.assign({isCi: true}, services[name].configuration({env, cwd}));
return {isCi: true, ...services[name].configuration({env, cwd})};
}
}

return Object.assign({isCi: Boolean(env.CI)}, git.configuration({env, cwd}));
return {isCi: Boolean(env.CI), ...git.configuration({env, cwd})};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"xo": "^0.24.0"
},
"engines": {
"node": ">=6"
"node": ">=8.3"
},
"files": [
"index.js",
Expand Down
24 changes: 11 additions & 13 deletions services/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@ module.exports = {
const isPr = env.GITHUB_EVENT_NAME === 'pull_request';
const branch = parseBranch(env.GITHUB_REF);

return Object.assign(
{
name: 'GitHub Actions',
service: 'github',
commit: env.GITHUB_SHA,
isPr,
branch,
prBranch: isPr ? branch : undefined,
slug: env.GITHUB_REPOSITORY,
root: env.GITHUB_WORKSPACE,
},
isPr ? getPrEvent({env, cwd}) : undefined
);
return {
name: 'GitHub Actions',
service: 'github',
commit: env.GITHUB_SHA,
isPr,
branch,
prBranch: isPr ? branch : undefined,
slug: env.GITHUB_REPOSITORY,
root: env.GITHUB_WORKSPACE,
...(isPr ? getPrEvent({env, cwd}) : undefined),
};
},
};
18 changes: 8 additions & 10 deletions services/teamcity.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ module.exports = {
return Boolean(env.TEAMCITY_VERSION);
},
configuration({env, cwd}) {
return Object.assign(
{
name: 'TeamCity',
service: 'teamcity',
commit: env.BUILD_VCS_NUMBER,
build: env.BUILD_NUMBER,
slug: env.TEAMCITY_BUILDCONF_NAME,
},
getProperties({env, cwd})
);
return {
name: 'TeamCity',
service: 'teamcity',
commit: env.BUILD_VCS_NUMBER,
build: env.BUILD_NUMBER,
slug: env.TEAMCITY_BUILDCONF_NAME,
...getProperties({env, cwd}),
};
},
};
5 changes: 1 addition & 4 deletions test/services/appveyor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
appveyor.configuration({
env: Object.assign({}, env, {
APPVEYOR_PULL_REQUEST_NUMBER: '10',
APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH: 'pr-branch',
}),
env: {...env, APPVEYOR_PULL_REQUEST_NUMBER: '10', APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH: 'pr-branch'},
}),
{
name: 'Appveyor',
Expand Down
6 changes: 1 addition & 5 deletions test/services/bitrise.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
bitrise.configuration({
env: Object.assign({}, env, {
BITRISE_PULL_REQUEST: '10',
BITRISEIO_GIT_BRANCH_DEST: 'master',
BITRISE_GIT_BRANCH: 'pr-branch',
}),
env: {...env, BITRISE_PULL_REQUEST: '10', BITRISEIO_GIT_BRANCH_DEST: 'master', BITRISE_GIT_BRANCH: 'pr-branch'},
}),
{
name: 'Bitrise',
Expand Down
2 changes: 1 addition & 1 deletion test/services/buddy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
buddy.configuration({
env: Object.assign({}, env, {BUDDY_EXECUTION_PULL_REQUEST_ID: 'pull/10', BUDDY_EXECUTION_BRANCH: undefined}),
env: {...env, BUDDY_EXECUTION_PULL_REQUEST_ID: 'pull/10', BUDDY_EXECUTION_BRANCH: undefined},
}),
{
name: 'Buddy',
Expand Down
5 changes: 3 additions & 2 deletions test/services/buildkite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
buildkite.configuration({
env: Object.assign({}, env, {
env: {
...env,
BUILDKITE_PULL_REQUEST: '10',
BUILDKITE_PULL_REQUEST_BASE_BRANCH: 'master',
BUILDKITE_BRANCH: 'pr-branch',
}),
},
}),
{
name: 'Buildkite',
Expand Down
93 changes: 42 additions & 51 deletions test/services/circleci.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,52 @@ test('Push', t => {
});

test('PR 1.0', t => {
t.deepEqual(
circle.configuration({env: Object.assign({}, env, {CIRCLE_BRANCH: 'pr-branch', CIRCLE_PR_NUMBER: '10'})}),
{
name: 'CircleCI',
service: 'circleci',
commit: '5678',
tag: 'tag_name',
build: '1234',
buildUrl: 'https://server.com/buildresult',
job: '1234.1',
branch: undefined,
pr: '10',
isPr: true,
prBranch: 'pr-branch',
slug: 'owner/repo',
}
);
t.deepEqual(circle.configuration({env: {...env, CIRCLE_BRANCH: 'pr-branch', CIRCLE_PR_NUMBER: '10'}}), {
name: 'CircleCI',
service: 'circleci',
commit: '5678',
tag: 'tag_name',
build: '1234',
buildUrl: 'https://server.com/buildresult',
job: '1234.1',
branch: undefined,
pr: '10',
isPr: true,
prBranch: 'pr-branch',
slug: 'owner/repo',
});
});

test('PR 2.0', t => {
t.deepEqual(
circle.configuration({env: Object.assign({}, env, {CIRCLE_BRANCH: 'pr-branch', CIRCLE_PR_NUMBER: '10'})}),
{
name: 'CircleCI',
service: 'circleci',
commit: '5678',
tag: 'tag_name',
build: '1234',
buildUrl: 'https://server.com/buildresult',
job: '1234.1',
branch: undefined,
pr: '10',
isPr: true,
prBranch: 'pr-branch',
slug: 'owner/repo',
}
);
t.deepEqual(circle.configuration({env: {...env, CIRCLE_BRANCH: 'pr-branch', CIRCLE_PR_NUMBER: '10'}}), {
name: 'CircleCI',
service: 'circleci',
commit: '5678',
tag: 'tag_name',
build: '1234',
buildUrl: 'https://server.com/buildresult',
job: '1234.1',
branch: undefined,
pr: '10',
isPr: true,
prBranch: 'pr-branch',
slug: 'owner/repo',
});
});

test('PR 2.0 without pull uri', t => {
t.deepEqual(
circle.configuration({env: Object.assign({}, env, {CIRCLE_BRANCH: 'pr-branch', CIRCLE_PR_NUMBER: '10'})}),
{
name: 'CircleCI',
service: 'circleci',
commit: '5678',
tag: 'tag_name',
build: '1234',
buildUrl: 'https://server.com/buildresult',
job: '1234.1',
branch: undefined,
pr: '10',
isPr: true,
prBranch: 'pr-branch',
slug: 'owner/repo',
}
);
t.deepEqual(circle.configuration({env: {...env, CIRCLE_BRANCH: 'pr-branch', CIRCLE_PR_NUMBER: '10'}}), {
name: 'CircleCI',
service: 'circleci',
commit: '5678',
tag: 'tag_name',
build: '1234',
buildUrl: 'https://server.com/buildresult',
job: '1234.1',
branch: undefined,
pr: '10',
isPr: true,
prBranch: 'pr-branch',
slug: 'owner/repo',
});
});
2 changes: 1 addition & 1 deletion test/services/cirrus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
cirrus.configuration({
env: Object.assign({}, env, {CIRRUS_PR: '239', CIRRUS_BASE_BRANCH: 'master', CIRRUS_BRANCH: 'pr-branch'}),
env: {...env, CIRRUS_PR: '239', CIRRUS_BASE_BRANCH: 'master', CIRRUS_BRANCH: 'pr-branch'},
}),
{
name: 'Cirrus CI',
Expand Down
6 changes: 1 addition & 5 deletions test/services/codefresh.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
codefresh.configuration({
env: Object.assign({}, env, {
CF_PULL_REQUEST_NUMBER: '10',
CF_PULL_REQUEST_TARGET: 'master',
CF_BRANCH: 'pr-branch',
}),
env: {...env, CF_PULL_REQUEST_NUMBER: '10', CF_PULL_REQUEST_TARGET: 'master', CF_BRANCH: 'pr-branch'},
}),
{
name: 'Codefresh',
Expand Down
5 changes: 3 additions & 2 deletions test/services/drone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ test('Push', t => {
test('PR', t => {
t.deepEqual(
drone.configuration({
env: Object.assign({}, env, {
env: {
...env,
DRONE_PULL_REQUEST: '10',
DRONE_BUILD_EVENT: 'pull_request',
DRONE_TARGET_BRANCH: 'master',
DRONE_SOURCE_BRANCH: 'pr-branch',
}),
},
}),
{
name: 'Drone',
Expand Down
30 changes: 16 additions & 14 deletions test/services/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ test('PR - with event.json file', t => {

t.deepEqual(
github.configuration({
env: Object.assign({}, env, {
env: {
...env,
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: '/refs/heads/pr-branch',
GITHUB_EVENT_PATH: eventFile,
}),
},
}),
{
name: 'GitHub Actions',
Expand All @@ -56,11 +57,12 @@ test('PR - with event.json file', t => {
test('PR - with missing event.json file', t => {
t.deepEqual(
github.configuration({
env: Object.assign({}, env, {
env: {
...env,
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: '/refs/heads/pr-branch',
GITHUB_EVENT_PATH: '/tmp/null',
}),
},
}),
{
name: 'GitHub Actions',
Expand All @@ -79,10 +81,7 @@ test('PR - with missing event.json file', t => {
test('PR - with missing event.json file path', t => {
t.deepEqual(
github.configuration({
env: Object.assign({}, env, {
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: '/refs/heads/pr-branch',
}),
env: {...env, GITHUB_EVENT_NAME: 'pull_request', GITHUB_REF: '/refs/heads/pr-branch'},
}),
{
name: 'GitHub Actions',
Expand All @@ -105,11 +104,12 @@ test('PR - with missing "pull_request" in event.json file', t => {

t.deepEqual(
github.configuration({
env: Object.assign({}, env, {
env: {
...env,
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: '/refs/heads/pr-branch',
GITHUB_EVENT_PATH: eventFile,
}),
},
}),
{
name: 'GitHub Actions',
Expand All @@ -132,11 +132,12 @@ test('PR - with missing "pull_request.base" in event.json file', t => {

t.deepEqual(
github.configuration({
env: Object.assign({}, env, {
env: {
...env,
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: '/refs/heads/pr-branch',
GITHUB_EVENT_PATH: eventFile,
}),
},
}),
{
name: 'GitHub Actions',
Expand All @@ -159,11 +160,12 @@ test('PR - with erronous branch names', t => {

t.deepEqual(
github.configuration({
env: Object.assign({}, env, {
env: {
...env,
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: '/refs/tags/pr-branch',
GITHUB_EVENT_PATH: eventFile,
}),
},
}),
{
name: 'GitHub Actions',
Expand Down
Loading

0 comments on commit 542be77

Please sign in to comment.