@toptal/davinci-ci 6.0.1-alpha-fx-4497-storybook-13e9f909.10 → 7.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.
@@ -1,407 +0,0 @@
1
- @Library('globalLibrary@master') _
2
-
3
- ghHelper = new helpers.GithubNotifyHelper()
4
- helper = new helpers.Helpers()
5
- jobHelper = new helpers.JobHelper()
6
-
7
- buildImageResult = []
8
-
9
- repositoryUrl = params.GITHUB_REPO_GIT_URL
10
- pullRequestId = params.GITHUB_PR_NUMBER
11
- sourceBranch = params.GITHUB_PR_SOURCE_BRANCH
12
- targetBranch = params.GITHUB_PR_TARGET_BRANCH
13
- commitId = params.GITHUB_PR_HEAD_SHA
14
-
15
- repositoryName = repositoryUrl.tokenize('/').last().split("\\.")[0]
16
- repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
17
-
18
- env.COMMIT_FOR_ANVIL = commitId
19
- env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
20
-
21
- buildImageJobName = "${repositoryName}-build-image"
22
- buildReleaseImageJobName = "${repositoryName}-build-release-image"
23
- deployTemployJobName = "${repositoryName}-temploy-helm-run"
24
-
25
- configDavinciYaml = "davinci.yaml"
26
-
27
- def getEnvironmentVariables(environmentName) {
28
- def environmentFilename = ".env.${environmentName}"
29
-
30
- if(!fileExists(environmentFilename)) {
31
- return 'ENV=null'
32
- }
33
-
34
- return sh(
35
- script: "egrep -v '^(#|\$)' ${environmentFilename} | sed 's/^/ENV./'| awk '{print}' ORS=',' | sed 's/,*\$//g'",
36
- returnStdout: true
37
- ).trim() as String
38
- }
39
-
40
- Boolean isEnabledInDavinciYaml(String section, String key) {
41
- if (fileExists(configDavinciYaml)) {
42
- configuration = jobHelper.readYaml(configDavinciYaml)
43
-
44
- if (configuration[section] && configuration[section][key]) {
45
- return true
46
- }
47
- }
48
-
49
- return false
50
- }
51
-
52
- pipeline {
53
- agent { label 'slave_aws' }
54
-
55
- options {
56
- ansiColor('xterm')
57
- timestamps()
58
- timeout(time: 25, unit: 'MINUTES')
59
- skipDefaultCheckout()
60
- }
61
-
62
- environment {
63
- DANGER_GITHUB_API_TOKEN = credentials('toptal-devbot-personal-token')
64
- GCE_ACCOUNT_KEY = credentials('jenkins-storage-administrator')
65
- GITHUB_TOKEN = credentials('toptal-devbot-token-github-notify')
66
- }
67
-
68
- parameters {
69
- string(name: 'GITHUB_REPO_GIT_URL', defaultValue: '', description: 'Repository url')
70
- string(name: 'GITHUB_PR_NUMBER', defaultValue: '', description: 'Pull request Id')
71
- string(name: 'GITHUB_PR_SOURCE_BRANCH', defaultValue: '', description: 'Source branch')
72
- string(name: 'GITHUB_PR_TARGET_BRANCH', defaultValue: 'master', description: 'Target branch')
73
- string(name: 'GITHUB_PR_HEAD_SHA', defaultValue: '', description: 'Commit Id')
74
- }
75
-
76
- stages {
77
- // Perform this only for PRs
78
- stage('Git checkout PR') {
79
- steps {
80
- info "== Checking out Git revision ${commitId}"
81
-
82
- gitCheckout(
83
- branches: "${commitId}",
84
- credentials: [username: 'toptal-build', description: "toptal-build-ssh-key"],
85
- url: repositorySSHUrl,
86
- refspec: "+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch} +refs/pull/${pullRequestId}/*:refs/remotes/origin/pr/${pullRequestId}/*",
87
- additionalBehaviours: [
88
- advancedCheckoutBehaviour: [timeout: 120],
89
- advancedCloneBehaviour : [depth: 0, noTags: true, reference: '', shallow: false, timeout: 340],
90
- cleanBeforeCheckout : false,
91
- calculateChangelog : [compareRemote: 'origin', compareTarget: "${targetBranch}"],
92
- mergeBeforeBuild : [mergeRemote: 'origin', mergeTarget: "${targetBranch}", mergeStrategy: 'DEFAULT', fastForwardMode: 'FF']
93
- ]
94
- )
95
-
96
- info "Git commit: ${gitCommit()}"
97
- info "Git branch: ${gitBranch()}"
98
- success 'Checkout finished'
99
-
100
- script {
101
- if (fileExists(configDavinciYaml)) {
102
- info "davinci.yaml file was found in the project root folder"
103
- } else {
104
- info "davinci.yaml file was not found, using standard CI configuration"
105
- }
106
- }
107
- }
108
- } //stage
109
-
110
- stage('Build image') {
111
- steps {
112
- script {
113
- ghHelper.notifyPR('Docker Build', 'PENDING', 'running', "${commitId}", "${BUILD_URL}", repositoryName)
114
-
115
- buildImageResult[0] = buildWithParameters(
116
- jobName: buildImageJobName,
117
- propagate: false,
118
- wait: true,
119
- parameters: [
120
- BRANCH: sourceBranch,
121
- VERSION: commitId,
122
- IMAGE_NAME: repositoryName,
123
- REPOSITORY_NAME: repositoryName
124
- ]
125
- )
126
-
127
- Boolean isBuildSuccessful = buildImageResult[0].currentResult == 'SUCCESS'
128
- if (!isBuildSuccessful) {
129
- String errorMsg = "The build failed. Go to ${buildImageResult[0].absoluteUrl} for more information."
130
- gitHubPostComment("${repositoryName}", "${pullRequestId}", errorMsg, GITHUB_TOKEN)
131
- error(errorMsg)
132
- }
133
- }
134
- } //steps
135
-
136
- post {
137
- success {
138
- success "Docker Build successful"
139
- script {
140
- ghHelper.notifyPR('Docker Build', 'SUCCESS', 'Success', "${commitId}", "${BUILD_URL}", repositoryName)
141
- }
142
- }
143
- failure {
144
- err "Docker Build failed"
145
- script {
146
- ghHelper.notifyPR('Docker Build', 'ERROR', 'Job failed', "${commitId}", "${BUILD_URL}", repositoryName)
147
- }
148
- }
149
- aborted {
150
- err "Docker Build aborted"
151
- script {
152
- ghHelper.notifyPR('Docker Build', 'FAILURE', 'Job aborted', "${commitId}", "${BUILD_URL}", repositoryName)
153
- }
154
- }
155
- }
156
- } //stage
157
-
158
- // Danger needs GitHub Pull Request Builder variables to
159
- // succesfully do checks on Jenkins
160
- stage('Danger checks') {
161
- steps {
162
- script {
163
- sh """
164
- docker run \
165
- --rm \
166
- -e JENKINS_URL=${JENKINS_URL} \
167
- -e ghprbPullId=${pullRequestId} \
168
- -e ghprbGhRepository=toptal/${repositoryName} \
169
- -e BUILD_URL=${BUILD_URL} \
170
- -e DANGER_GITHUB_API_TOKEN=${DANGER_GITHUB_API_TOKEN} \
171
- gcr.io/toptal-hub/${repositoryName}:${commitId} \
172
- yarn davinci ci danger
173
- """
174
- }
175
- } //steps
176
- } //stage
177
-
178
- stage('Run unit tests') {
179
- parallel {
180
-
181
- stage('Run linter') {
182
- steps {
183
- script {
184
- ghHelper.notifyPR(
185
- 'Lint',
186
- 'PENDING',
187
- 'running',
188
- "${commitId}",
189
- "${BUILD_URL}",
190
- repositoryName
191
- )
192
-
193
- sh "docker run --rm gcr.io/toptal-hub/${repositoryName}:${commitId} yarn lint"
194
- }
195
- } //steps
196
-
197
- post {
198
- success {
199
- success "Lint successful"
200
- script {
201
- ghHelper.notifyPR('Lint', 'SUCCESS', 'Success', "${commitId}", "${BUILD_URL}", repositoryName)
202
- }
203
- }
204
- failure {
205
- err "Lint failed"
206
- script {
207
- ghHelper.notifyPR('Lint', 'ERROR', 'Job failed', "${commitId}", "${BUILD_URL}", repositoryName)
208
- }
209
- }
210
- } //post
211
- } //stage
212
-
213
- stage('Run jest') {
214
- steps {
215
- script {
216
- ghHelper.notifyPR('Jest Tests', 'PENDING', 'running', "${commitId}", "${BUILD_URL}", repositoryName)
217
-
218
- sh "docker run --rm gcr.io/toptal-hub/${repositoryName}:${commitId} yarn test --ci"
219
- }
220
- } //steps
221
-
222
- post {
223
- success {
224
- success "Test successful"
225
- script {
226
- ghHelper.notifyPR(
227
- 'Jest Tests',
228
- 'SUCCESS',
229
- 'Success',
230
- "${commitId}",
231
- "${BUILD_URL}",
232
- repositoryName
233
- )
234
- }
235
- }
236
- failure {
237
- err "Test failed"
238
- script {
239
- ghHelper.notifyPR(
240
- 'Jest Tests',
241
- 'ERROR',
242
- 'Job failed',
243
- "${commitId}",
244
- "${BUILD_URL}",
245
- repositoryName
246
- )
247
- }
248
- }
249
- } //post
250
- } //stage
251
-
252
- stage('Cypress tests') {
253
- when {
254
- expression { return isEnabledInDavinciYaml("pr", "cypress") }
255
- }
256
-
257
- steps {
258
- script {
259
- ghHelper.notifyPR('Cypress Tests', 'PENDING', 'running', "${commitId}", "${BUILD_URL}", repositoryName)
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
-
265
- sh """
266
- docker run \
267
- --user="root" \
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"
269
- """
270
- }
271
- } //steps
272
-
273
- post {
274
- success {
275
- success "Test successful"
276
- script {
277
- ghHelper.notifyPR('Cypress Tests', 'SUCCESS', 'Success', "${commitId}", "${BUILD_URL}", repositoryName)
278
- }
279
- }
280
- failure {
281
- err "Cypress tests failed"
282
- script {
283
- ghHelper.notifyPR('Cypress Tests', 'ERROR', 'Job failed', "${commitId}", "${BUILD_URL}", repositoryName)
284
- }
285
- }
286
- } //post
287
- } //stage
288
-
289
- } //parallel
290
- } //stage
291
-
292
- stage('Trigger consumer contracts verification') {
293
- when {
294
- expression { return isEnabledInDavinciYaml("pr", "contract_testing") }
295
- }
296
-
297
- steps {
298
- info "== Trigger consumer contracts verification"
299
-
300
- // script {
301
- // TODO: add PACT publishing
302
- // TODO: run consumer-contracts-verify job
303
- // }
304
- }
305
- } //stage
306
-
307
- stage('Build release image') {
308
- steps {
309
- script {
310
- buildImageResult[1] = buildWithParameters(
311
- jobName: buildReleaseImageJobName,
312
- propagate: false,
313
- wait: true,
314
- parameters: [
315
- IMAGE_TAG: commitId,
316
- REPOSITORY_NAME: repositoryName
317
- ]
318
- )
319
- }
320
- } //steps
321
- } //stage
322
-
323
- stage('Check images build status') {
324
- steps {
325
- script {
326
- helper.printBuildsResults(buildImageResult)
327
- helper.setBuildStatus(buildImageResult)
328
- }
329
- } //steps
330
- } //stage
331
-
332
- stage('Deploy temploy as preview') {
333
- steps {
334
- script {
335
- releaseName = "${repositoryName}-pr-${pullRequestId}"
336
- info "== Triggering temploy for ${commitId} as release ${releaseName} =="
337
-
338
- ghHelper.notifyPR(
339
- 'Temploy',
340
- 'PENDING',
341
- 'running',
342
- "${commitId}",
343
- "${BUILD_URL}",
344
- repositoryName
345
- )
346
-
347
- def temployEnvironmentVariables = getEnvironmentVariables('temploy')
348
-
349
- temployJob = build(
350
- job: "${deployTemployJobName}",
351
- parameters: [
352
- string(name: 'REPOSITORY_NAME', value: "${repositoryName}"),
353
- string(name: 'TAG', value: "${commitId}"),
354
- string(name: 'RELEASE', value: "${releaseName}"),
355
- string(name: 'ENV', value: temployEnvironmentVariables)
356
- ],
357
- propagate: false,
358
- wait: true)
359
-
360
- }
361
- } //steps
362
-
363
- post {
364
- always {
365
- script {
366
- sendBuildData(currentBuild)
367
- }
368
- }
369
-
370
- success {
371
- success "Temploy deployed"
372
- script {
373
- copyArtifacts(projectName: "${deployTemployJobName}", selector: specific("${temployJob.number}"))
374
-
375
- notes = readFile('tmp/NOTES.txt').trim().replaceAll("\n", "<br/>")
376
- comment = "Your temploy is ready :tada:<br/>" + notes
377
- gitHubPostComment("${repositoryName}", "${pullRequestId}", comment, env.GITHUB_TOKEN)
378
-
379
- ghHelper.notifyPR(
380
- 'Temploy',
381
- 'SUCCESS',
382
- 'Success',
383
- "${commitId}",
384
- "${temployJob.absoluteUrl}",
385
- repositoryName
386
- )
387
- }
388
- }
389
- failure {
390
- err "Temploy failed"
391
- script {
392
- ghHelper.notifyPR(
393
- 'Temploy',
394
- 'ERROR',
395
- 'Job failed',
396
- "${commitId}",
397
- "${temployJob.absoluteUrl}",
398
- repositoryName
399
- )
400
- }
401
- }
402
- } //post
403
- } //stage
404
-
405
- }//stages
406
-
407
- }//pipeline
@@ -1,134 +0,0 @@
1
- <flow-definition plugin="workflow-job@2.35">
2
- <actions>
3
- <org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobAction plugin="pipeline-model-definition@1.3.9"/>
4
- <org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction plugin="pipeline-model-definition@1.3.9">
5
- <jobProperties/>
6
- <triggers/>
7
- <parameters>
8
- <string>GITHUB_PR_HEAD_SHA</string>
9
- <string>GITHUB_PR_TARGET_BRANCH</string>
10
- <string>GITHUB_REPO_GIT_URL</string>
11
- <string>GITHUB_PR_NUMBER</string>
12
- <string>GITHUB_PR_SOURCE_BRANCH</string>
13
- </parameters>
14
- <options>
15
- <string>skipDefaultCheckout</string>
16
- </options>
17
- </org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction>
18
- </actions>
19
- <description></description>
20
- <keepDependencies>false</keepDependencies>
21
- <properties>
22
- <hudson.plugins.jira.JiraProjectProperty plugin="jira@3.0.7"/>
23
- <com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer@1.20.0">
24
- <doNotScan>false</doNotScan>
25
- </com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
26
- <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.29.4">
27
- <projectUrl>$PROJECT_URL</projectUrl>
28
- <displayName></displayName>
29
- </com.coravy.hudson.plugins.github.GithubProjectProperty>
30
- <hudson.model.ParametersDefinitionProperty>
31
- <parameterDefinitions>
32
- <hudson.model.StringParameterDefinition>
33
- <name>GITHUB_REPO_GIT_URL</name>
34
- <description>Repository url</description>
35
- <defaultValue></defaultValue>
36
- <trim>false</trim>
37
- </hudson.model.StringParameterDefinition>
38
- <hudson.model.StringParameterDefinition>
39
- <name>GITHUB_PR_NUMBER</name>
40
- <description>Pull request Id</description>
41
- <defaultValue></defaultValue>
42
- <trim>false</trim>
43
- </hudson.model.StringParameterDefinition>
44
- <hudson.model.StringParameterDefinition>
45
- <name>GITHUB_PR_SOURCE_BRANCH</name>
46
- <description>Source branch</description>
47
- <defaultValue></defaultValue>
48
- <trim>false</trim>
49
- </hudson.model.StringParameterDefinition>
50
- <hudson.model.StringParameterDefinition>
51
- <name>GITHUB_PR_TARGET_BRANCH</name>
52
- <description>Target branch</description>
53
- <defaultValue>master</defaultValue>
54
- <trim>false</trim>
55
- </hudson.model.StringParameterDefinition>
56
- <hudson.model.StringParameterDefinition>
57
- <name>GITHUB_PR_HEAD_SHA</name>
58
- <description>Commit Id</description>
59
- <defaultValue></defaultValue>
60
- <trim>false</trim>
61
- </hudson.model.StringParameterDefinition>
62
- </parameterDefinitions>
63
- </hudson.model.ParametersDefinitionProperty>
64
- <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.0.1">
65
- <maxConcurrentPerNode>0</maxConcurrentPerNode>
66
- <maxConcurrentTotal>0</maxConcurrentTotal>
67
- <categories class="java.util.concurrent.CopyOnWriteArrayList"/>
68
- <throttleEnabled>false</throttleEnabled>
69
- <throttleOption>project</throttleOption>
70
- <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
71
- <paramsToUseForLimit></paramsToUseForLimit>
72
- </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
73
- <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
74
- <triggers>
75
- <org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger plugin="github-pullrequest@0.2.6">
76
- <spec></spec>
77
- <triggerMode>HEAVY_HOOKS</triggerMode>
78
- <cancelQueued>true</cancelQueued>
79
- <abortRunning>true</abortRunning>
80
- <skipFirstRun>false</skipFirstRun>
81
- <repoProviders>
82
- <com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider>
83
- <cacheConnection>true</cacheConnection>
84
- <manageHooks>true</manageHooks>
85
- <repoPermission>ADMIN</repoPermission>
86
- </com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider>
87
- </repoProviders>
88
- <errorsAction>
89
- <description>GitHub Pull Requests Trigger Errors</description>
90
- <errors class="java.util.Collections$SynchronizedSet" serialization="custom">
91
- <java.util.Collections_-SynchronizedCollection>
92
- <default>
93
- <c class="set"/>
94
- <mutex class="java.util.Collections$SynchronizedSet" reference="../../.."/>
95
- </default>
96
- </java.util.Collections_-SynchronizedCollection>
97
- </errors>
98
- </errorsAction>
99
- <events>
100
- <org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRCommitEvent/>
101
- <org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPROpenEvent/>
102
- <org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRCommentEvent>
103
- <comment>@toptal-bot run tests</comment>
104
- </org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRCommentEvent>
105
- </events>
106
- <preStatus>false</preStatus>
107
- </org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger>
108
- </triggers>
109
- </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
110
- </properties>
111
- <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.74">
112
- <scm class="hudson.plugins.git.GitSCM" plugin="git@3.10.1">
113
- <configVersion>2</configVersion>
114
- <userRemoteConfigs>
115
- <hudson.plugins.git.UserRemoteConfig>
116
- <url>git@github.com:toptal/davinci.git</url>
117
- <credentialsId>$CREDENTIALS_ID</credentialsId>
118
- </hudson.plugins.git.UserRemoteConfig>
119
- </userRemoteConfigs>
120
- <branches>
121
- <hudson.plugins.git.BranchSpec>
122
- <name>master</name>
123
- </hudson.plugins.git.BranchSpec>
124
- </branches>
125
- <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
126
- <submoduleCfg class="list"/>
127
- <extensions/>
128
- </scm>
129
- <scriptPath>packages/ci/src/configs/jobs/pr-tests/Jenkinsfile</scriptPath>
130
- <lightweight>false</lightweight>
131
- </definition>
132
- <triggers/>
133
- <disabled>false</disabled>
134
- </flow-definition>