@toptal/davinci-ci 1.15.1-alpha-fx-2724-prepare-a-davinci-codemod-package.28 → 2.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 +6 -0
- package/dist-package/package.json +39 -0
- package/package.json +3 -4
- package/src/configs/danger/toptal/plugins/toptal-commits/toptal-commits.test.js +128 -0
- package/src/configs/danger/toptal/plugins/toptal-pr-title/toptal-pr-title.test.js +66 -0
- package/src/configs/jobs/build-image/Jenkinsfile +2 -0
- package/src/configs/jobs/build-release-image/Jenkinsfile +2 -0
- package/src/configs/jobs/deploy-helm-run-trigger/Jenkinsfile +2 -0
- package/src/configs/jobs/master-main/Jenkinsfile +5 -1
- package/src/configs/jobs/pr-tests/Jenkinsfile +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#1326](https://github.com/toptal/davinci/pull/1326) [`77adee1f`](https://github.com/toptal/davinci/commit/77adee1f003f6336279ca4ac24476bdece8d9828) Thanks [@augustobmoura](https://github.com/augustobmoura)! - - rename the command `davinci qa e2e` to `davinci qa integration`
|
|
8
|
+
|
|
3
9
|
## 1.15.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toptal/davinci-ci",
|
|
3
|
+
"version": "2.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-code": "./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": "^16.2.4",
|
|
34
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
35
|
+
"@toptal/davinci-cli-shared": "1.5.1",
|
|
36
|
+
"danger": "^11.0.5",
|
|
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": "2.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": "^16.2.4",
|
|
34
34
|
"@commitlint/config-conventional": "^16.0.0",
|
|
35
|
-
"@toptal/davinci-cli-shared": "1.5.
|
|
35
|
+
"@toptal/davinci-cli-shared": "1.5.1",
|
|
36
36
|
"danger": "^11.0.5",
|
|
37
37
|
"markdown-table": "^2.0.0"
|
|
38
|
-
}
|
|
39
|
-
"gitHead": "50775c42637e6c0a896030c2cfe34aa80900f515"
|
|
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
|
+
test('commit with title only', () => {
|
|
30
|
+
global.danger.git = prepareCommitsWithMessages(['Hello world'])
|
|
31
|
+
toptalCommits()
|
|
32
|
+
|
|
33
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('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
|
+
test('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
|
+
test('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
|
+
test('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
|
+
test('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
|
+
test('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
|
+
test('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
|
+
test('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
|
+
test('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,66 @@
|
|
|
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: [
|
|
18
|
+
{ name: 'My Team' }
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
pr: {
|
|
22
|
+
title: '',
|
|
23
|
+
user: {
|
|
24
|
+
login: 'user'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
global.fail = undefined
|
|
33
|
+
global.danger = undefined
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test('should pass valid PR title', () => {
|
|
37
|
+
global.danger.github.pr.title = VALID_PR_TITLE
|
|
38
|
+
|
|
39
|
+
toptalPRTitle()
|
|
40
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('should fail PR title with missing ticket code', () => {
|
|
44
|
+
global.danger.github.pr.title = NO_TICKET_CODE_PR_TITLE
|
|
45
|
+
|
|
46
|
+
toptalPRTitle()
|
|
47
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
48
|
+
expect(global.fail).toHaveBeenCalledWith(MISSING_TICKET_CODE_ERROR_MESSAGE)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('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
|
+
expect(global.fail).toHaveBeenCalledTimes(0)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('should fail invalid PR title', () => {
|
|
60
|
+
global.danger.github.pr.title = INVALID_PR_TITLE
|
|
61
|
+
|
|
62
|
+
toptalPRTitle()
|
|
63
|
+
expect(global.fail).toHaveBeenCalledTimes(1)
|
|
64
|
+
expect(global.fail).toHaveBeenCalledWith(DEFAULT_PR_TITLE_ERROR_MESSAGE)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
@@ -4,6 +4,7 @@ image = null
|
|
|
4
4
|
|
|
5
5
|
repositoryName = REPOSITORY_NAME
|
|
6
6
|
repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
|
|
7
|
+
env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
|
|
7
8
|
|
|
8
9
|
pipeline {
|
|
9
10
|
agent { label 'slave_aws' }
|
|
@@ -47,6 +48,7 @@ pipeline {
|
|
|
47
48
|
additionalBehaviours: [
|
|
48
49
|
cleanBeforeCheckout: true
|
|
49
50
|
])
|
|
51
|
+
script { env.COMMIT_FOR_ANVIL = gitCommit() }
|
|
50
52
|
success "== Checked out ${BRANCH} at ${gitCommit()}"
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -8,6 +8,7 @@ release_docker_image = null
|
|
|
8
8
|
repositoryName = REPOSITORY_NAME
|
|
9
9
|
repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
|
|
10
10
|
releaseImageName = "${repositoryName}-release"
|
|
11
|
+
env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
|
|
11
12
|
|
|
12
13
|
pipeline {
|
|
13
14
|
agent { label 'slave_aws' }
|
|
@@ -47,6 +48,7 @@ pipeline {
|
|
|
47
48
|
additionalBehaviours: [
|
|
48
49
|
cleanBeforeCheckout: true
|
|
49
50
|
])
|
|
51
|
+
script { env.COMMIT_FOR_ANVIL = gitCommit() }
|
|
50
52
|
success "== Checked out ${BRANCH} at ${gitCommit()}"
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -13,6 +13,7 @@ repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
|
|
|
13
13
|
targetBranch = "master"
|
|
14
14
|
configDavinciYaml = "davinci.yaml"
|
|
15
15
|
def repoBullhornSlackChannel
|
|
16
|
+
env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
|
|
16
17
|
|
|
17
18
|
buildImageJobName = "${repositoryName}-build-image"
|
|
18
19
|
buildReleaseImageJobName = "${repositoryName}-build-release-image"
|
|
@@ -96,6 +97,7 @@ pipeline {
|
|
|
96
97
|
|
|
97
98
|
info "Git commit: ${gitCommit()}"
|
|
98
99
|
info "Git branch: ${gitBranch()}"
|
|
100
|
+
script { env.COMMIT_FOR_ANVIL = gitCommit() }
|
|
99
101
|
success 'Checkout finished'
|
|
100
102
|
|
|
101
103
|
script {
|
|
@@ -392,10 +392,14 @@ pipeline {
|
|
|
392
392
|
|
|
393
393
|
steps {
|
|
394
394
|
script {
|
|
395
|
+
def packageJson = readJSON(file: 'package.json', returnPojo: true)
|
|
396
|
+
def hasIntegrationCmd = 'test:integration:ci' in (packageJson.scripts ?: [:])
|
|
397
|
+
def testCommand = hasIntegrationCmd ? 'integration' : 'e2e'
|
|
398
|
+
|
|
395
399
|
sh """
|
|
396
400
|
docker run \
|
|
397
401
|
--user="root" \
|
|
398
|
-
--rm gcr.io/toptal-hub/${repositoryName}:${commitId} /bin/bash -c "apt update && apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb && yarn cypress install > /dev/null && yarn test:
|
|
402
|
+
--rm gcr.io/toptal-hub/${repositoryName}:${commitId} /bin/bash -c "apt update && apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb && yarn cypress install > /dev/null && yarn test:$testCommand:ci"
|
|
399
403
|
"""
|
|
400
404
|
}
|
|
401
405
|
} //steps
|
|
@@ -15,6 +15,9 @@ commitId = params.GITHUB_PR_HEAD_SHA
|
|
|
15
15
|
repositoryName = repositoryUrl.tokenize('/').last().split("\\.")[0]
|
|
16
16
|
repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
|
|
17
17
|
|
|
18
|
+
env.COMMIT_FOR_ANVIL = commitId
|
|
19
|
+
env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
|
|
20
|
+
|
|
18
21
|
buildImageJobName = "${repositoryName}-build-image"
|
|
19
22
|
buildReleaseImageJobName = "${repositoryName}-build-release-image"
|
|
20
23
|
deployTemployJobName = "${repositoryName}-temploy-helm-run"
|
|
@@ -255,10 +258,14 @@ pipeline {
|
|
|
255
258
|
script {
|
|
256
259
|
ghHelper.notifyPR('Cypress Tests', 'PENDING', 'running', "${commitId}", "${BUILD_URL}", repositoryName)
|
|
257
260
|
|
|
261
|
+
def packageJson = readJSON(file: 'package.json', returnPojo: true)
|
|
262
|
+
def hasIntegrationCmd = 'test:integration:ci' in (packageJson.scripts ?: [:])
|
|
263
|
+
def testCommand = hasIntegrationCmd ? 'integration' : 'e2e'
|
|
264
|
+
|
|
258
265
|
sh """
|
|
259
266
|
docker run \
|
|
260
267
|
--user="root" \
|
|
261
|
-
--rm gcr.io/toptal-hub/${repositoryName}:${commitId} /bin/bash -c "apt update && apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb && yarn cypress install > /dev/null && yarn test:
|
|
268
|
+
--rm gcr.io/toptal-hub/${repositoryName}:${commitId} /bin/bash -c "apt update && apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb && yarn cypress install > /dev/null && yarn test:$testCommand:ci"
|
|
262
269
|
"""
|
|
263
270
|
}
|
|
264
271
|
} //steps
|