@toptal/davinci-ci 2.0.8-alpha-fx-2925-use-davinci-by-parts-in-davinci-skeleton.13 → 2.0.9
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,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1541](https://github.com/toptal/davinci/pull/1541) [`397a53c9`](https://github.com/toptal/davinci/commit/397a53c9add9f7e8d485648b51cd22676d97c78f) Thanks [@TomasSlama](https://github.com/TomasSlama)! - ---
|
|
8
|
+
- Update documentation about prefering individual davinci packages usage
|
|
9
|
+
|
|
10
|
+
## 2.0.8
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#1525](https://github.com/toptal/davinci/pull/1525) [`f69a35e`](https://github.com/toptal/davinci/commit/f69a35e2a590b61524d9ab1ce37a03e50012a3c9) Thanks [@denieler](https://github.com/denieler)! - - fix davinci-ci bin executable name
|
|
15
|
+
|
|
3
16
|
## 2.0.7
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,26 +8,26 @@ Watch [this video](https://drive.google.com/file/d/1C5ApkATYCXZ8kTn2LeG5FkM4AveL
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
Use it by installing `yarn add @toptal/davinci` in your project.
|
|
11
|
+
Use it by installing `yarn add @toptal/davinci-ci` in your project.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
### Commands
|
|
16
16
|
|
|
17
|
-
- `davinci
|
|
17
|
+
- `davinci-ci danger` - checks if the PR title and and commit messages comply with [Toptal's standards](https://toptal-core.atlassian.net/wiki/spaces/ENG/pages/210665897/Commit+Message+Quality)
|
|
18
18
|
|
|
19
|
-
- `davinci
|
|
19
|
+
- `davinci-ci danger --conventionalCommits` - checks if the PR title and and commit messages comply with [ConventionalCommits](https://www.conventionalcommits.org/en/v1.0.0/)
|
|
20
20
|
|
|
21
21
|
To check commit message quality locally just add `--local` argument
|
|
22
22
|
|
|
23
|
-
`davinci
|
|
23
|
+
`davinci-ci danger --local`
|
|
24
24
|
|
|
25
25
|
Using husky, you can check the commit message before pushing files changes.
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
28
|
"husky": {
|
|
29
29
|
"hooks": {
|
|
30
|
-
"pre-push": "yarn davinci
|
|
30
|
+
"pre-push": "yarn davinci-ci danger --local"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
```
|
|
@@ -55,7 +55,10 @@ is_progressive_web_app: true
|
|
|
55
55
|
|
|
56
56
|
### Alias
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
You can use davinci ci both as a standalone command `davinci-ci [...args]`
|
|
59
|
+
or as a sub-command of the davinci command: `davinci ci [args...]`, in this case @toptal/davinci package is required.
|
|
60
|
+
Recommended way is to use individual davinci packages, i.e. `davinci-ci danger`.
|
|
61
|
+
|
|
59
62
|
|
|
60
63
|
### Commands you can use in GitHub PRs
|
|
61
64
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toptal/davinci-ci",
|
|
3
|
+
"version": "2.0.9",
|
|
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.0.3",
|
|
35
|
+
"@toptal/davinci-cli-shared": "1.6.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": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
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.0.3",
|
|
35
|
-
"@toptal/davinci-cli-shared": "1.6.
|
|
35
|
+
"@toptal/davinci-cli-shared": "1.6.0",
|
|
36
36
|
"danger": "^11.0.7",
|
|
37
37
|
"markdown-table": "^2.0.0"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "b2d240b7628e9d089e3f022a2dfcf894409a516f"
|
|
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
|
+
})
|