@toptal/davinci-ci 2.1.1-alpha-fix-execute-graphql-command-f9d910f2.16 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1799](https://github.com/toptal/davinci/pull/1799) [`103a3ec9`](https://github.com/toptal/davinci/commit/103a3ec94aa9ca9d9d83aab4cbcb510e26bf6071) Thanks [@separatio](https://github.com/separatio)! - ---
|
|
8
|
+
|
|
9
|
+
- upgrade required minimum Node version to 14 LTS
|
|
10
|
+
|
|
3
11
|
## 2.1.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toptal/davinci-ci",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Continuos integrations tools for frontend projects",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [
|
|
9
|
+
"jenkins",
|
|
10
|
+
"docker",
|
|
11
|
+
"ci"
|
|
12
|
+
],
|
|
13
|
+
"author": "Toptal",
|
|
14
|
+
"homepage": "https://github.com/toptal/davinci/tree/master/packages/ci#readme",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"bin": {
|
|
17
|
+
"davinci-ci": "./bin/davinci-ci.js"
|
|
18
|
+
},
|
|
19
|
+
"main": "./src/index.js",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/toptal/davinci.git"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build:package": "../../bin/build-package.js",
|
|
26
|
+
"prepublishOnly": "../../bin/prepublish.js",
|
|
27
|
+
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/toptal/davinci/issues"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@commitlint/cli": "^17.0.2",
|
|
34
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
35
|
+
"@toptal/davinci-cli-shared": "1.10.0",
|
|
36
|
+
"danger": "^11.0.7",
|
|
37
|
+
"markdown-table": "^2.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/davinci-ci",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Continuos integrations tools for frontend projects",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,9 +32,8 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@commitlint/cli": "^17.0.2",
|
|
34
34
|
"@commitlint/config-conventional": "^17.1.0",
|
|
35
|
-
"@toptal/davinci-cli-shared": "1.10.
|
|
35
|
+
"@toptal/davinci-cli-shared": "1.10.0",
|
|
36
36
|
"danger": "^11.0.7",
|
|
37
37
|
"markdown-table": "^2.0.0"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "f9d910f255c0f3a91e4181beb4b1883fd158551e"
|
|
38
|
+
}
|
|
40
39
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const { toptalCommits } = require('.')
|
|
2
|
+
|
|
3
|
+
const prepareCommitsWithMessages = (messages = []) => ({
|
|
4
|
+
commits: messages.map(message => ({
|
|
5
|
+
message,
|
|
6
|
+
sha: '123',
|
|
7
|
+
})),
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
describe('commit danger plugin', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
global.fail = jest.fn()
|
|
13
|
+
global.danger = {
|
|
14
|
+
github: {
|
|
15
|
+
pr: {
|
|
16
|
+
user: {
|
|
17
|
+
login: 'user',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
global.fail = undefined
|
|
26
|
+
global.danger = undefined
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('commit with title only', () => {
|
|
30
|
+
global.danger.git = prepareCommitsWithMessages(['Hello world'])
|
|
31
|
+
toptalCommits()
|
|
32
|
+
|
|
33
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('commit with title and body', () => {
|
|
37
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
38
|
+
'Hello world\n\nSome commit body here.',
|
|
39
|
+
])
|
|
40
|
+
toptalCommits()
|
|
41
|
+
|
|
42
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('commit with multi-line body', () => {
|
|
46
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
47
|
+
'Hello world\n\nFirst line of commit body\nSecond line of commit body',
|
|
48
|
+
])
|
|
49
|
+
toptalCommits()
|
|
50
|
+
|
|
51
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('commit with title longer than allowed', () => {
|
|
55
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
56
|
+
'This commit message is a teeny tiny bit longer than allowed length of 79 characters',
|
|
57
|
+
])
|
|
58
|
+
toptalCommits()
|
|
59
|
+
|
|
60
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('commit with body lines longer than allowed', () => {
|
|
64
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
65
|
+
'Short commit title\n\nBut this body line commit message is a bit longer than allowed length of 79 characters\nAnd this one is fine again.',
|
|
66
|
+
])
|
|
67
|
+
toptalCommits()
|
|
68
|
+
|
|
69
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('commit message not starting with an uppercase letter', () => {
|
|
73
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
74
|
+
'23432 starts with a number',
|
|
75
|
+
'starts with a lowercase letter',
|
|
76
|
+
'* starts with a symbol',
|
|
77
|
+
' starts with a space',
|
|
78
|
+
])
|
|
79
|
+
toptalCommits()
|
|
80
|
+
|
|
81
|
+
expect(global.fail).toHaveBeenCalledTimes(4)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('commit message ending with a period in title', () => {
|
|
85
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
86
|
+
'Commit title ending with period.',
|
|
87
|
+
])
|
|
88
|
+
toptalCommits()
|
|
89
|
+
|
|
90
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('commit without a blank line between title and body', () => {
|
|
94
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
95
|
+
'Commit title\nBody without a blank line after title',
|
|
96
|
+
])
|
|
97
|
+
toptalCommits()
|
|
98
|
+
|
|
99
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('valid commit titles', () => {
|
|
103
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
104
|
+
'Regular commit title',
|
|
105
|
+
'Commit with sentence. But does not end with a full-stop',
|
|
106
|
+
'[FOO-1234] Commit with prefix',
|
|
107
|
+
'[FOO] Prefix numbers can be omitted',
|
|
108
|
+
'[FOO][BAR] Prefixes can couple',
|
|
109
|
+
'[FOO-1234][BAR] Mixed prefixes',
|
|
110
|
+
'[FOO-1234][BAR-123][BAZ] Everything. Together',
|
|
111
|
+
])
|
|
112
|
+
toptalCommits()
|
|
113
|
+
|
|
114
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('invalid commit title prefixes', () => {
|
|
118
|
+
global.danger.git = prepareCommitsWithMessages([
|
|
119
|
+
'[FOO-1234] commit with lowercase',
|
|
120
|
+
'[FOO-BAR] Prefix with letter after dash',
|
|
121
|
+
'[FOO] [BAR] Prefixes with space between',
|
|
122
|
+
'[FOO]Prefix without space',
|
|
123
|
+
])
|
|
124
|
+
toptalCommits()
|
|
125
|
+
|
|
126
|
+
expect(global.fail).toHaveBeenCalledTimes(4)
|
|
127
|
+
})
|
|
128
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const { toptalPRTitle } = require('.')
|
|
2
|
+
const {
|
|
3
|
+
MISSING_TICKET_CODE_ERROR_MESSAGE,
|
|
4
|
+
DEFAULT_PR_TITLE_ERROR_MESSAGE,
|
|
5
|
+
} = require('../../config')
|
|
6
|
+
|
|
7
|
+
const VALID_PR_TITLE = '[ASD-123] Hello world'
|
|
8
|
+
const INVALID_PR_TITLE = '[ASD-123] hello world'
|
|
9
|
+
const NO_TICKET_CODE_PR_TITLE = 'Hello world'
|
|
10
|
+
|
|
11
|
+
describe('commit danger plugin', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
global.fail = jest.fn()
|
|
14
|
+
global.danger = {
|
|
15
|
+
github: {
|
|
16
|
+
issue: {
|
|
17
|
+
labels: [{ name: 'My Team' }],
|
|
18
|
+
},
|
|
19
|
+
pr: {
|
|
20
|
+
title: '',
|
|
21
|
+
user: {
|
|
22
|
+
login: 'user',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
global.fail = undefined
|
|
31
|
+
global.danger = undefined
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should pass valid PR title', () => {
|
|
35
|
+
global.danger.github.pr.title = VALID_PR_TITLE
|
|
36
|
+
|
|
37
|
+
toptalPRTitle()
|
|
38
|
+
|
|
39
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('should fail PR title with missing ticket code', () => {
|
|
43
|
+
global.danger.github.pr.title = NO_TICKET_CODE_PR_TITLE
|
|
44
|
+
|
|
45
|
+
toptalPRTitle()
|
|
46
|
+
|
|
47
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
48
|
+
expect(global.fail).toHaveBeenCalledWith(MISSING_TICKET_CODE_ERROR_MESSAGE)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('should pass valid PR title with missing ticket code and no-jira label', () => {
|
|
52
|
+
global.danger.github.pr.title = NO_TICKET_CODE_PR_TITLE
|
|
53
|
+
global.danger.github.issue.labels = [{ name: 'no-jira' }]
|
|
54
|
+
|
|
55
|
+
toptalPRTitle()
|
|
56
|
+
|
|
57
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('should fail invalid PR title', () => {
|
|
61
|
+
global.danger.github.pr.title = INVALID_PR_TITLE
|
|
62
|
+
|
|
63
|
+
toptalPRTitle()
|
|
64
|
+
|
|
65
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
66
|
+
expect(global.fail).toHaveBeenCalledWith(DEFAULT_PR_TITLE_ERROR_MESSAGE)
|
|
67
|
+
})
|
|
68
|
+
})
|