Skip to content

Commit 5733594

Browse files
authored
feat(vela): Adds Vela CI provider (#170)
1 parent 8814f92 commit 5733594

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ if (isCI) {
8888
| [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: | :white_check_mark: |
8989
| [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: | :x: | :white_check_mark: | :white_check_mark: |
9090
| [Travis CI](https://docs.travis-ci.com/user/environment-variables#default-environment-variables) | `travis` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
91+
| [Vela](https://go-vela.github.io/docs/reference/environment/variables/) | `vela` | :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: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
9192
| [Vercel](https://vercel.com/docs/environment-variables) | `vercel` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :x: |
9293
| [Visual Studio Team Services](https://docs.microsoft.com/en-us/vsts/pipelines/build/variables) | `vsts` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
9394
| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name) | `wercker` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const services = {
2626
shippable: require('./services/shippable.js'),
2727
teamcity: require('./services/teamcity.js'),
2828
travis: require('./services/travis.js'),
29+
vela: require('./services/vela.js'),
2930
vercel: require('./services/vercel.js'),
3031
vsts: require('./services/vsts.js'),
3132
wercker: require('./services/wercker.js'),

services/vela.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// https://go-vela.github.io/docs/reference/environment/variables/
2+
3+
module.exports = {
4+
detect({env}) {
5+
return Boolean(env.VELA);
6+
},
7+
configuration({env}) {
8+
const isPr = env.VELA_BUILD_EVENT === 'pull_request';
9+
10+
return {
11+
name: 'Vela',
12+
service: 'vela',
13+
branch: isPr ? env.VELA_PULL_REQUEST_TARGET : env.VELA_BUILD_BRANCH,
14+
commit: env.VELA_BUILD_COMMIT,
15+
tag: env.VELA_BUILD_TAG,
16+
build: env.VELA_BUILD_NUMBER,
17+
buildUrl: env.VELA_BUILD_LINK,
18+
job: undefined,
19+
jobUrl: undefined,
20+
isPr,
21+
pr: env.VELA_BUILD_PULL_REQUEST,
22+
prBranch: env.VELA_PULL_REQUEST_SOURCE,
23+
slug: env.VELA_REPO_FULL_NAME,
24+
root: env.VELA_BUILD_WORKSPACE,
25+
};
26+
},
27+
};

test/index.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ test('Travis', (t) => {
165165
t.is(service, 'travis');
166166
});
167167

168+
test('Vela', (t) => {
169+
const {isCi, service} = m({env: {VELA: 'true'}});
170+
171+
t.is(isCi, true);
172+
t.is(service, 'vela');
173+
});
174+
168175
test('Visual Studio Team Services', (t) => {
169176
const {isCi, service} = m({env: {BUILD_BUILDURI: 'https://fabrikamfiber.visualstudio.com/_git/Scripts'}});
170177

test/services/vela.test.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
const test = require('ava');
2+
const vela = require('../../services/vela.js');
3+
4+
const env = {
5+
VELA: 'true',
6+
VELA_BUILD_EVENT: 'push',
7+
VELA_BUILD_BRANCH: 'my-branch',
8+
VELA_BUILD_COMMIT: 'a1b2c3',
9+
VELA_BUILD_NUMBER: '25',
10+
VELA_BUILD_LINK: 'https://some-vela-instance.com/Org/Project/25',
11+
VELA_REPO_FULL_NAME: 'Org/Project',
12+
VELA_BUILD_WORKSPACE: '/home/Org/Project',
13+
};
14+
15+
test('Push', (t) => {
16+
t.deepEqual(vela.configuration({env}), {
17+
name: 'Vela',
18+
service: 'vela',
19+
commit: 'a1b2c3',
20+
tag: undefined,
21+
build: '25',
22+
buildUrl: 'https://some-vela-instance.com/Org/Project/25',
23+
branch: 'my-branch',
24+
job: undefined,
25+
jobUrl: undefined,
26+
isPr: false,
27+
pr: undefined,
28+
prBranch: undefined,
29+
slug: 'Org/Project',
30+
root: '/home/Org/Project',
31+
});
32+
});
33+
34+
test('PR', (t) => {
35+
t.deepEqual(
36+
vela.configuration({
37+
env: {
38+
...env,
39+
VELA_BUILD_EVENT: 'pull_request',
40+
VELA_BUILD_PULL_REQUEST: '1',
41+
VELA_PULL_REQUEST_TARGET: 'main',
42+
VELA_PULL_REQUEST_SOURCE: 'my-branch',
43+
VELA_BUILD_BRANCH: 'my-branch',
44+
},
45+
}),
46+
{
47+
name: 'Vela',
48+
service: 'vela',
49+
commit: 'a1b2c3',
50+
tag: undefined,
51+
build: '25',
52+
buildUrl: 'https://some-vela-instance.com/Org/Project/25',
53+
branch: 'main',
54+
job: undefined,
55+
jobUrl: undefined,
56+
isPr: true,
57+
pr: '1',
58+
prBranch: 'my-branch',
59+
slug: 'Org/Project',
60+
root: '/home/Org/Project',
61+
}
62+
);
63+
});
64+
65+
test('Tag', (t) => {
66+
t.deepEqual(
67+
vela.configuration({
68+
env: {
69+
...env,
70+
VELA_BUILD_EVENT: 'tag',
71+
VELA_BUILD_TAG: 'v1.0.2',
72+
},
73+
}),
74+
{
75+
name: 'Vela',
76+
service: 'vela',
77+
commit: 'a1b2c3',
78+
tag: 'v1.0.2',
79+
build: '25',
80+
buildUrl: 'https://some-vela-instance.com/Org/Project/25',
81+
branch: 'my-branch',
82+
job: undefined,
83+
jobUrl: undefined,
84+
isPr: false,
85+
pr: undefined,
86+
prBranch: undefined,
87+
slug: 'Org/Project',
88+
root: '/home/Org/Project',
89+
}
90+
);
91+
});

0 commit comments

Comments
 (0)