@toptal/davinci-ci 3.0.1-alpha-chore-improve-packages-building-14e3a950.51 → 3.0.2-alpha-chore-improve-packages-building-4fb91e1f.10

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.
Files changed (40) hide show
  1. package/package.json +6 -5
  2. package/src/commands/danger.js +67 -0
  3. package/src/configs/danger/conventional-commits/dangerfile.js +17 -0
  4. package/src/configs/danger/conventional-commits/plugins/conventional-commits/index.js +52 -0
  5. package/src/configs/danger/conventional-commits/plugins/conventional-pr-title/index.js +53 -0
  6. package/src/configs/danger/conventional-commits/plugins/index.js +7 -0
  7. package/src/configs/danger/plugins/empty-assignee.js +24 -0
  8. package/src/configs/danger/toptal/config.js +30 -0
  9. package/src/configs/danger/toptal/dangerfile.js +17 -0
  10. package/src/configs/danger/toptal/plugins/index.js +7 -0
  11. package/src/configs/danger/toptal/plugins/toptal-commits/index.js +73 -0
  12. package/src/configs/danger/toptal/plugins/toptal-commits/toptal-commits.test.js +128 -0
  13. package/src/configs/danger/toptal/plugins/toptal-pr-title/index.js +62 -0
  14. package/src/configs/danger/toptal/plugins/toptal-pr-title/toptal-pr-title.test.js +68 -0
  15. package/src/configs/docker/Dockerfile +30 -0
  16. package/src/configs/docker/Dockerfile.gha-deploy +33 -0
  17. package/src/configs/docker/Dockerfile.release +28 -0
  18. package/src/configs/docker/Dockerfile.storybook +20 -0
  19. package/src/configs/docker/env-runtime.entrypoint.sh +47 -0
  20. package/src/configs/docker/nginx-vhost-storybook.conf +20 -0
  21. package/src/configs/docker/nginx-vhost.conf +18 -0
  22. package/src/configs/jobs/build-image/Jenkinsfile +142 -0
  23. package/src/configs/jobs/build-image/config.xml +119 -0
  24. package/src/configs/jobs/build-release-image/Jenkinsfile +154 -0
  25. package/src/configs/jobs/build-release-image/config.xml +102 -0
  26. package/src/configs/jobs/consumer-contracts-verify/Jenkinsfile +117 -0
  27. package/src/configs/jobs/consumer-contracts-verify/config.xml +114 -0
  28. package/src/configs/jobs/deploy/config.xml +107 -0
  29. package/src/configs/jobs/deploy-helm-run/Jenkinsfile +159 -0
  30. package/src/configs/jobs/deploy-helm-run/config.xml +107 -0
  31. package/src/configs/jobs/deploy-helm-run-trigger/Jenkinsfile +200 -0
  32. package/src/configs/jobs/master-main/Jenkinsfile +460 -0
  33. package/src/configs/jobs/master-main/config.xml +119 -0
  34. package/src/configs/jobs/pr-tests/Jenkinsfile +407 -0
  35. package/src/configs/jobs/pr-tests/config.xml +134 -0
  36. package/src/configs/jobs/publish-alpha-package/Jenkinsfile +189 -0
  37. package/src/configs/jobs/publish-alpha-package/config.xml +136 -0
  38. package/src/configs/jobs/temploy-helm-run/Jenkinsfile +141 -0
  39. package/src/configs/jobs/temploy-helm-run/config.xml +97 -0
  40. package/src/index.js +17 -0
@@ -0,0 +1,107 @@
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
+ <string>jenkins.model.BuildDiscarderProperty</string>
7
+ </jobProperties>
8
+ <triggers />
9
+ <parameters>
10
+ <string>HELM_BRANCH</string>
11
+ <string>REPOSITORY_NAME</string>
12
+ <string>TAG</string>
13
+ <string>RELEASE</string>
14
+ <string>ENV</string>
15
+ </parameters>
16
+ <options>
17
+ <string>skipDefaultCheckout</string>
18
+ </options>
19
+ </org.jenkinsci.plugins.pipeline.modeldefinition.actions.DeclarativeJobPropertyTrackerAction>
20
+ </actions>
21
+ <description />
22
+ <keepDependencies>false</keepDependencies>
23
+ <properties>
24
+ <hudson.model.ParametersDefinitionProperty>
25
+ <parameterDefinitions>
26
+ <hudson.model.StringParameterDefinition>
27
+ <name>HELM_BRANCH</name>
28
+ <description>Helm branch</description>
29
+ <defaultValue>master</defaultValue>
30
+ <trim>false</trim>
31
+ </hudson.model.StringParameterDefinition>
32
+ <hudson.model.StringParameterDefinition>
33
+ <name>REPOSITORY_NAME</name>
34
+ <description>Name of repository</description>
35
+ <defaultValue />
36
+ <trim>false</trim>
37
+ </hudson.model.StringParameterDefinition>
38
+ <hudson.model.StringParameterDefinition>
39
+ <name>TAG</name>
40
+ <description>Image tag to deploy</description>
41
+ <defaultValue />
42
+ <trim>false</trim>
43
+ </hudson.model.StringParameterDefinition>
44
+ <hudson.model.StringParameterDefinition>
45
+ <name>RELEASE</name>
46
+ <description>Release name</description>
47
+ <defaultValue />
48
+ <trim>false</trim>
49
+ </hudson.model.StringParameterDefinition>
50
+ <hudson.model.StringParameterDefinition>
51
+ <name>ENV</name>
52
+ <description>Environment values in format ENV.key1=value1,ENV.key2=value2</description>
53
+ <defaultValue>ENV=null</defaultValue>
54
+ <trim>false</trim>
55
+ </hudson.model.StringParameterDefinition>
56
+ </parameterDefinitions>
57
+ </hudson.model.ParametersDefinitionProperty>
58
+ <hudson.plugins.jira.JiraProjectProperty plugin="jira@3.0.7" />
59
+ <jenkins.model.BuildDiscarderProperty>
60
+ <strategy class="hudson.tasks.LogRotator">
61
+ <daysToKeep>-1</daysToKeep>
62
+ <numToKeep>20</numToKeep>
63
+ <artifactDaysToKeep>-1</artifactDaysToKeep>
64
+ <artifactNumToKeep>-1</artifactNumToKeep>
65
+ </strategy>
66
+ </jenkins.model.BuildDiscarderProperty>
67
+ <com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty plugin="build-failure-analyzer@1.20.0">
68
+ <doNotScan>false</doNotScan>
69
+ </com.sonyericsson.jenkins.plugins.bfa.model.ScannerJobProperty>
70
+ <com.coravy.hudson.plugins.github.GithubProjectProperty plugin="github@1.29.4">
71
+ <projectUrl>$PROJECT_URL</projectUrl>
72
+ <displayName />
73
+ </com.coravy.hudson.plugins.github.GithubProjectProperty>
74
+ <hudson.plugins.throttleconcurrents.ThrottleJobProperty plugin="throttle-concurrents@2.0.1">
75
+ <maxConcurrentPerNode>0</maxConcurrentPerNode>
76
+ <maxConcurrentTotal>0</maxConcurrentTotal>
77
+ <categories class="java.util.concurrent.CopyOnWriteArrayList" />
78
+ <throttleEnabled>false</throttleEnabled>
79
+ <throttleOption>project</throttleOption>
80
+ <limitOneJobWithMatchingParams>false</limitOneJobWithMatchingParams>
81
+ <paramsToUseForLimit />
82
+ </hudson.plugins.throttleconcurrents.ThrottleJobProperty>
83
+ </properties>
84
+ <definition class="org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition" plugin="workflow-cps@2.74">
85
+ <scm class="hudson.plugins.git.GitSCM" plugin="git@3.10.1">
86
+ <configVersion>2</configVersion>
87
+ <userRemoteConfigs>
88
+ <hudson.plugins.git.UserRemoteConfig>
89
+ <url>git@github.com:toptal/davinci.git</url>
90
+ <credentialsId>$CREDENTIALS_ID</credentialsId>
91
+ </hudson.plugins.git.UserRemoteConfig>
92
+ </userRemoteConfigs>
93
+ <branches>
94
+ <hudson.plugins.git.BranchSpec>
95
+ <name>master</name>
96
+ </hudson.plugins.git.BranchSpec>
97
+ </branches>
98
+ <doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
99
+ <submoduleCfg class="list" />
100
+ <extensions />
101
+ </scm>
102
+ <scriptPath>packages/ci/src/configs/jobs/deploy-helm-run/Jenkinsfile</scriptPath>
103
+ <lightweight>true</lightweight>
104
+ </definition>
105
+ <triggers />
106
+ <disabled>false</disabled>
107
+ </flow-definition>
@@ -0,0 +1,200 @@
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
+ environment = "production"
10
+
11
+ repositoryName = params.REPOSITORY_NAME
12
+ repositorySSHUrl = "git@github.com:toptal/${repositoryName}.git"
13
+ targetBranch = "master"
14
+ configDavinciYaml = "davinci.yaml"
15
+ def repoBullhornSlackChannel
16
+ env.REPO_NAME_FOR_COMMIT = "toptal/${repositoryName}"
17
+
18
+ buildImageJobName = "${repositoryName}-build-image"
19
+ buildReleaseImageJobName = "${repositoryName}-build-release-image"
20
+ deployHelmRunJobName = "${repositoryName}-deploy-helm-run"
21
+
22
+ String readDavinciYaml(String section, String defaultValue = '') {
23
+ if (fileExists(configDavinciYaml)) {
24
+ configuration = jobHelper.readYaml(configDavinciYaml)
25
+
26
+ if (configuration[section]) {
27
+ return "${configuration[section]}"
28
+ }
29
+ }
30
+
31
+ return defaultValue
32
+ }
33
+
34
+ def getEnvironmentVariables(environmentName) {
35
+ def environmentFilename = ".env.${environmentName}"
36
+
37
+ if(!fileExists(environmentFilename)) {
38
+ return 'ENV=null'
39
+ }
40
+
41
+ return sh(
42
+ script: "egrep -v '^(#|\$)' ${environmentFilename} | sed 's/^/ENV./'| awk '{print}' ORS=',' | sed 's/,*\$//g'",
43
+ returnStdout: true
44
+ ).trim() as String
45
+ }
46
+
47
+ String getCommitDetails() {
48
+ def commitId = gitCommit()
49
+ def shortSha = commitId.substring(0, 12)
50
+ def gitCommitLink = "https://github.com/toptal/${repositoryName}/commit/${commitId}"
51
+ def author = gitAuthor(commitId)
52
+ def pullRequestId = gitHubPullRequestId(commitId)
53
+ def pullRequestLink = gitHubPullRequestLink(repositoryName, commitId)
54
+
55
+ if (pullRequestId.trim() == "") {
56
+ return "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> with <${gitCommitLink}|${shortSha}> (by ${author})."
57
+ }
58
+
59
+ info "pullRequestId: ${pullRequestId}"
60
+ info "pullRequestLink: ${pullRequestLink}"
61
+ return "Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}> with <${gitCommitLink}|${shortSha}> (PR <${pullRequestLink}|#${pullRequestId}> by ${author})."
62
+ }
63
+
64
+ pipeline {
65
+ agent { label 'docker' }
66
+
67
+ options {
68
+ ansiColor('xterm')
69
+ timestamps()
70
+ timeout(time: 1, unit: 'HOURS')
71
+ buildDiscarder(logRotator(numToKeepStr: '20'))
72
+ skipDefaultCheckout()
73
+ }
74
+
75
+ parameters {
76
+ string(name: 'REPOSITORY_NAME', defaultValue: '', description: 'Name of repository')
77
+ }
78
+
79
+ stages {
80
+ stage('Git checkout PR') {
81
+ steps {
82
+ info "== Checking out Git revision ${targetBranch}"
83
+
84
+ gitCheckout(
85
+ branches: "${targetBranch}",
86
+ credentials: [username: 'toptal-build', description: 'toptal-build-ssh-key'],
87
+ url: repositorySSHUrl,
88
+ refspec: "+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}",
89
+ additionalBehaviours: [
90
+ advancedCheckoutBehaviour: [timeout: 120],
91
+ advancedCloneBehaviour : [depth: 0, noTags: true, reference: '', shallow: false, timeout: 340],
92
+ cleanBeforeCheckout : false,
93
+ calculateChangelog : [compareRemote: 'origin', compareTarget: "${targetBranch}"],
94
+ mergeBeforeBuild : [mergeRemote: 'origin', mergeTarget: "${targetBranch}", mergeStrategy: 'DEFAULT', fastForwardMode: 'FF']
95
+ ]
96
+ )
97
+
98
+ info "Git commit: ${gitCommit()}"
99
+ info "Git branch: ${gitBranch()}"
100
+ script { env.COMMIT_FOR_ANVIL = gitCommit() }
101
+ success 'Checkout finished'
102
+
103
+ script {
104
+ if (fileExists(configDavinciYaml)) {
105
+ info "davinci.yaml file was found in the project root folder"
106
+ info "Extracting values from the davinci.yaml file"
107
+ repoBullhornSlackChannel = readDavinciYaml('slack_channel', "${repositoryName}-bullhorn")
108
+ } else {
109
+ info "davinci.yaml file was not found, using standard CI configuration"
110
+ }
111
+ }
112
+ }
113
+ } //stage
114
+
115
+ stage('Build image') {
116
+ steps {
117
+ script {
118
+ buildImageResult[0] = buildWithParameters(
119
+ jobName: buildImageJobName,
120
+ propagate: true,
121
+ wait: true,
122
+ parameters: [
123
+ VERSION: gitCommit(),
124
+ IMAGE_NAME: repositoryName,
125
+ REPOSITORY_NAME: repositoryName
126
+ ]
127
+ )
128
+ }
129
+ } //steps
130
+ } //stage
131
+
132
+ stage('Build release image') {
133
+ steps {
134
+ script {
135
+ buildImageResult[1] = buildWithParameters(
136
+ jobName: buildReleaseImageJobName,
137
+ propagate: true,
138
+ wait: true,
139
+ parameters: [
140
+ IMAGE_TAG: gitCommit(),
141
+ REPOSITORY_NAME: repositoryName
142
+ ]
143
+ )
144
+ }
145
+ } //steps
146
+ } //stage
147
+
148
+ stage('Trigger deploy') {
149
+ steps {
150
+ script {
151
+ def productionEnvironmentVariables = getEnvironmentVariables(environment)
152
+
153
+ buildImageResult[2] = buildWithParameters(
154
+ jobName: deployHelmRunJobName,
155
+ propagate: false,
156
+ wait: true,
157
+ parameters: [
158
+ REPOSITORY_NAME: repositoryName,
159
+ TAG: gitCommit(),
160
+ ENV: productionEnvironmentVariables
161
+ ]
162
+ )
163
+ }
164
+ } //steps
165
+ } //stage
166
+
167
+ stage('Check images build status') {
168
+ steps {
169
+ script {
170
+ helper.setBuildStatus(buildImageResult)
171
+ }
172
+ } //steps
173
+ } //stage
174
+
175
+ } //stages
176
+
177
+ post {
178
+ always{
179
+ sendBuildData(currentBuild)
180
+ }
181
+
182
+ failure {
183
+ script {
184
+ slackSend color: 'danger',
185
+ channel: repoBullhornSlackChannel,
186
+ message: "<!here> The latest master version of ${repositoryName} was not deployed to '${environment}' environment.\n${getCommitDetails()}"
187
+ }
188
+ }
189
+
190
+ success {
191
+ script {
192
+ slackSend color: 'good',
193
+ channel: repoBullhornSlackChannel,
194
+ message: "The latest master version of ${repositoryName} was deployed to '${environment}' environment :green_heart:.\n${getCommitDetails()}"
195
+ }
196
+ }
197
+ }
198
+
199
+ }
200
+ // vim:ft=groovy