forked from KonstantinCodes/mautic-recaptcha
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
171 lines (167 loc) · 5.62 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@Library('jenkins-scripts') _
pipeline {
environment {
SUBMODULE_NAME = "MauticRecaptchaBundle"
}
options {
skipDefaultCheckout()
disableConcurrentBuilds()
}
agent {
kubernetes {
inheritFrom 'with-mysql'
yaml libraryResource('mautic-tester-80-withcomposer2.yaml')
}
}
stages {
stage('Download and combine') {
steps {
container('mautic-tester') {
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'development']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '1a066462-6d24-4247-bef6-1da084c8f484', url: '[email protected]:mautic-inc/mautic-cloud.git']]]
sh('rm -r plugins/${SUBMODULE_NAME} || true; mkdir -p plugins/${SUBMODULE_NAME} && chmod 777 plugins/${SUBMODULE_NAME} && chown 1000:1000 plugins/${SUBMODULE_NAME}')
dir("plugins/${env.SUBMODULE_NAME}") {
checkout scm
}
}
}
}
stage('Build') {
steps {
container('mautic-tester') {
ansiColor('xterm') {
withCredentials([string(credentialsId: 'github-composer-token', variable: 'composertoken')]) {
sh("composer config --global github-oauth.github.com ${composertoken}")
}
sh '''
git config --global --add safe.directory '*'
## We need all private plugins enabled during tests so their tests can run successfully
echo "<?php
\\$hostedParameters = array_merge(
\\$hostedParameters,
[
'private_cloud_plugin_deny_list' => [],
'private_cloud_plugin_allow_list' => [],
]
);" > app/config/hosted_local.php
echo "<?php
\\$parameters = array(
'db_driver' => 'pdo_mysql',
'db_host' => '127.0.0.1',
'db_port' => 3306,
'db_name' => 'mautictest',
'db_user' => 'travis',
'db_password' => '',
'db_table_prefix' => '',
'hosted_plan' => 'pro',
'custom_objects_enabled' => true,
'create_custom_field_in_background' => false,
);" > app/config/local.php
composer validate --no-check-all --strict || (echo "Composer failed validation. If the lock file is out of sync you can try running 'composer update --lock'"; exit 1)
composer install --ansi
'''
}
}
}
}
stage('Tests') {
parallel {
stage('PHPUNIT') {
environment {
COVERALLS_REPO_TOKEN = credentials('COVERALLS_REPO_TOKEN')
CI_PULL_REQUEST = "${env.CHANGE_ID}"
CI_BRANCH = "${env.BRANCH_NAME}"
CI_BUILD_URL = "${env.BUILD_URL}"
}
steps {
container('mautic-tester') {
ansiColor('xterm') {
sh '''
echo "PHP Version Info"
php --version
mysql -h 127.0.0.1 -e 'CREATE DATABASE mautictest; CREATE USER travis@"%"; GRANT ALL on mautictest.* to travis@"%"; GRANT SUPER,PROCESS ON *.* TO travis@"%";'
export SYMFONY_ENV="test"
mkdir -p var/cache/coverage-report
# APP_DEBUG=0 disables debug mode for functional test clients decreasing memory usage to almost half
APP_DEBUG=0 php -dpcov.enabled=1 -dpcov.directory=. -dpcov.exclude="~tests|themes|vendor~" bin/phpunit -d memory_limit=1G --bootstrap vendor/autoload.php --configuration plugins/${SUBMODULE_NAME}/phpunit.xml --disallow-test-output --coverage-clover var/cache/coverage-report/clover.xml --testsuite=all
'''
}
}
}
}
// stage('Static Analysis') {
// steps {
// container('mautic-tester') {
// ansiColor('xterm') {
// dir("plugins/${env.SUBMODULE_NAME}") {
// sh '''
// composer run-script phpstan
// '''
// }
// }
// }
// }
// }
stage('CS Fixer') {
steps {
container('mautic-tester') {
ansiColor('xterm') {
dir("plugins/${env.SUBMODULE_NAME}") {
sh '''
export COMPOSER_ALLOW_SUPERUSER=1
composer csfixer
'''
}
}
}
}
}
}
}
stage('Automerge') {
when {
anyOf {
changeRequest target: 'staging'
changeRequest target: 'master'
changeRequest target: 'preproduction'
changeRequest target: 'hotfix'
changeRequest target: 'deployed'
changeRequest target: 'epic-.*', comparator: 'REGEXP'
}
}
steps {
script {
automergeScript()
}
}
}
stage('Set Revision') {
when {
not {
changeRequest()
}
anyOf {
branch 'development'
branch 'beta'
branch 'staging';
}
}
steps {
script {
setRevisionScript()
}
}
}
}
post {
failure {
script {
postFailureScript()
}
}
fixed {
script {
postFixedScript()
}
}
}
}