Skip to content

Commit

Permalink
Integrate fixes from master (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux authored May 22, 2017
1 parent d792981 commit db5194a
Showing 1 changed file with 57 additions and 36 deletions.
93 changes: 57 additions & 36 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
#!groovy

def phpVersion = "5.6"
def mysqlVersion = "5.5"
def launchUnitTests = "yes"
def launchIntegrationTests = "no"

class Globals {
static pimVersion = "1.6"
static extensionBranch = "dev-master"
static phpVersion = "5.6"
static mysqlVersion = "5.5"
static extensionBranch = "1.0"
}

stage("Checkout") {
milestone 1
if (env.BRANCH_NAME =~ /^PR-/) {
userInput = input(message: 'Launch tests?', parameters: [
choice(choices: '1.6\n1.7', description: 'PIM version to use', name: 'pimVersion'),
choice(choices: 'yes\nno', description: 'Run unit tests', name: 'launchUnitTests'),
choice(choices: 'yes\nno', description: 'Run integration tests', name: 'launchIntegrationTests'),
])

Globals.pimVersion = userInput['pimVersion']
launchUnitTests = userInput['launchUnitTests']
launchIntegrationTests = userInput['launchIntegrationTests']
}
Expand Down Expand Up @@ -60,7 +57,6 @@ if (launchIntegrationTests.equals("yes")) {
def tasks = [:]

tasks["phpunit-5.6-ce"] = {runIntegrationTestCe("5.6")}
tasks["phpunit-5.6-ee"] = {runIntegrationTestEe("5.6")}

parallel tasks
}
Expand Down Expand Up @@ -115,42 +111,59 @@ def runPhpCsFixerTest(version) {
def runIntegrationTestCe(version) {
node('docker') {
deleteDir()
try {
docker.image("mysql:5.5").withRun("--name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim") {
docker.image("carcel/php:${version}").inside("--link mysql:mysql -v /home/akeneo/.composer:/home/akeneo/.composer -e COMPOSER_HOME=/home/akeneo/.composer") {
unstash "pim_community"
cleanUpEnvironment()
def workspace = "/home/docker/pim"

if (version != "5.6") {
sh "composer require --no-update alcaeus/mongo-php-adapter"
}
sh "docker network create akeneo"
sh """
docker pull mysql:${Globals.mysqlVersion}
docker pull carcel/akeneo-behat:php-${version}
"""

sh "composer require --no-update phpunit/phpunit:5.4 akeneo/icecat-connector:${Globals.extensionBranch}"
sh "composer update --ignore-platform-reqs --optimize-autoloader --no-interaction --no-progress --prefer-dist"
dir("vendor/akeneo/extended-attribute-type") {
deleteDir()
unstash "icecat_extension"
}
sh 'ln -s $(pwd)/vendor/akeneo/extended-attribute-type/doc/example/Pim src/Pim'
sh 'composer dump-autoload -o'
sh "docker run -d --network akeneo --name mysql \
-e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=akeneo_pim -e MYSQL_PASSWORD=akeneo_pim -e MYSQL_DATABASE=akeneo_pim \
mysql:${Globals.mysqlVersion} \
--sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

sh "cp vendor/akeneo/extended-attribute-type/doc/example/Pim/Bundle/ExtendedCeBundle/Resources/config/config_test.yml app/config/config_test.yml"
sh "cp vendor/akeneo/extended-attribute-type/doc/example/Pim/Bundle/ExtendedCeBundle/Resources/config/parameters_test.yml app/config/parameters_test.yml"
docker.image("carcel/akeneo-behat:php-${version}").inside(
"--network akeneo --name akeneo-behat -e WORKSPACE=${workspace} -e COMPOSER_HOME=/home/docker/.composer \
-v /home/akeneo/.composer:/home/docker/.composer -w ${workspace}"
) {

sh "sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedCeBundle\\\\ExtendedCeBundle(),#' app/AppKernel.php"
sh "sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedAttributeTypeBundle\\\\PimExtendedAttributeTypeBundle(),#' app/AppKernel.php"
sh "cat app/AppKernel.php"
unstash "pim_community"

if (version != "5.6") {
sh "composer require --no-update alcaeus/mongo-php-adapter"
}

sh "rm ./app/cache/* -rf"
sh "./app/console --env=test pim:install --force"
sh "mkdir -p app/build/logs/"
sh "./bin/phpunit -c app/ --log-junit app/build/logs/phpunit.xml vendor/akeneo/extended-attribute-type/Tests"
}
sh 'composer config repositories.icecat \'{"type": "vcs", "url": "[email protected]:akeneo/icecat-connector.git"}\''
sh "composer require --no-update phpunit/phpunit:5.4 akeneo/icecat-connector:${Globals.extensionBranch}"
sh "composer update --ignore-platform-reqs --optimize-autoloader --no-interaction --no-progress --prefer-dist"
dir("vendor/akeneo/extended-attribute-type") {
deleteDir()
unstash "icecat_extension"
}
sh 'ln -s $(pwd)/vendor/akeneo/extended-attribute-type/doc/example/Pim src/Pim'
sh 'composer dump-autoload -o'

sh "cp vendor/akeneo/extended-attribute-type/doc/example/Pim/Bundle/ExtendedCeBundle/Resources/config/config_test.yml app/config/config_test.yml"
sh "cp vendor/akeneo/extended-attribute-type/doc/example/Pim/Bundle/ExtendedCeBundle/Resources/config/parameters_test.yml app/config/parameters_test.yml"

sh "sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedCeBundle\\\\ExtendedCeBundle(),#' app/AppKernel.php"
sh "sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedAttributeTypeBundle\\\\PimExtendedAttributeTypeBundle(),#' app/AppKernel.php"
sh "cat app/AppKernel.php"


sh "rm ./app/cache/* -rf"
sh "./app/console --env=test pim:install --force"
sh "mkdir -p app/build/logs/"
try {
sh "./bin/phpunit -c app/ --log-junit app/build/logs/phpunit.xml vendor/akeneo/extended-attribute-type/Tests"
} finally {
sh "sed -i \"s/testcase name=\\\"/testcase name=\\\"[php-${version}] /\" app/build/logs/*.xml"
junit "app/build/logs/*.xml"
deleteDir()
}
} finally {
sh "sed -i \"s/testcase name=\\\"/testcase name=\\\"[php-${version}] /\" app/build/logs/*.xml"
junit "app/build/logs/*.xml"
deleteDir()
}
}
}
Expand Down Expand Up @@ -198,3 +211,11 @@ def runIntegrationTestEe(version) {
}
}

def cleanUpEnvironment() {
deleteDir()
sh '''
docker ps -a -q | xargs -n 1 -P 8 -I {} docker rm -f {} > /dev/null
docker volume ls -q | xargs -n 1 -P 8 -I {} docker volume rm {} > /dev/null
docker network ls --filter name=akeneo -q | xargs -n 1 -P 8 -I {} docker network rm {} > /dev/null
'''
}

0 comments on commit db5194a

Please sign in to comment.