Skip to content

Commit

Permalink
Jenkinsfile for automated CI (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux authored Mar 13, 2017
1 parent 72da6ec commit 4828c58
Show file tree
Hide file tree
Showing 30 changed files with 229 additions and 59 deletions.
106 changes: 79 additions & 27 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ if (launchUnitTests.equals("yes")) {
def tasks = [:]

tasks["phpspec-5.6"] = {runPhpSpecTest("5.6")}
tasks["phpspec-7.0"] = {runPhpSpecTest("7.0")}
tasks["phpspec-7.1"] = {runPhpSpecTest("7.1")}

tasks["php-cs-fixer-7.1"] = {runPhpCsFixerTest("7.0")}
tasks["php-cs-fixer-5.6"] = {runPhpCsFixerTest("5.6")}

parallel tasks
}
Expand All @@ -62,7 +60,8 @@ if (launchIntegrationTests.equals("yes")) {
stage("Integration tests") {
def tasks = [:]

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

parallel tasks
}
Expand Down Expand Up @@ -114,35 +113,88 @@ def runPhpCsFixerTest(version) {
}
}

def runIntegrationTest(version) {
def runIntegrationTestCe(version) {
node('docker') {
deleteDir()
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"

if (version != "5.6") {
sh "composer require --no-update alcaeus/mongo-php-adapter"
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"

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

sh "composer require --no-update phpunit/phpunit:5.4 akeneo/extended-attribute-type:${Globals.extensionBranch}"
sh "composer update --ignore-platform-reqs --optimize-autoloader --no-interaction --no-progress --prefer-dist"
dir("vendor/akeneo/extended-attribute-type") {
deleteDir()
unstash "extended_attributes"
}
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/"
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()
}
}
}

sh "composer require --no-update phpunit/phpunit akeneo/extended-attribute-type ${Globals.extensionBranch}"
sh "composer update --ignore-platform-reqs --optimize-autoloader --no-interaction --no-progress --prefer-dist"

dir("vendor/akeneo/extended_attributes") {
unstash "extended_attributes"
def runIntegrationTestEe(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_enterprise"

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

sh "composer require --no-update phpunit/phpunit:5.4 akeneo/extended-attribute-type:${Globals.extensionBranch}"
sh "composer update --ignore-platform-reqs --optimize-autoloader --no-interaction --no-progress --prefer-dist"
dir("vendor/akeneo/extended-attribute-type") {
deleteDir()
unstash "extended_attributes"
}
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/ExtendedEeBundle/Resources/config/config_test.yml app/config/config_test.yml"
sh "cp vendor/akeneo/extended-attribute-type/doc/example/Pim/Bundle/ExtendedEeBundle/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\\\\ExtendedEeBundle\\\\ExtendedEeBundle(),#' 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/"
sh "./bin/phpunit -c app/ --log-junit app/build/logs/phpunit.xml vendor/akeneo/extended-attribute-type/Tests"
}
sh "composer dump-autoload -o"

sh "cp app/config/parameters.yml.dist app/config/parameters_test.yml"
sh "sed -i 's/database_host: localhost/database_host: mysql/' app/config/parameters_test.yml"
sh "echo '' >> app/config/parameters_test.yml"
sh "sed -i 's#// your app bundles should be registered here#\\0\\nnew Pim\\\\Bundle\\\\ExtendedAttributeTypeBundle\\\\PimExtendedAttributeTypeBundle(),#' app/AppKernel.php"
sh "sed -i 's#// your app bundles should be registered here#\\0\\nnew Acme\\\\Bundle\\\\AppBundle\\\\AcmeAppBundle(),#' app/AppKernel.php"

sh "cp vendor/akeneo/extended_attributes/doc/example/app/config/config_test.yml app/config/config_test.yml"

sh "./app/console --env=test pim:install --force"
}
} finally {
sh "sed -i \"s/testcase name=\\\"/testcase name=\\\"[php-${version}] /\" app/build/logs/*.xml"
junit "app/build/logs/*.xml"
deleteDir()
}
}
}
59 changes: 59 additions & 0 deletions Tests/TextCollection/TextCollectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Tests\TextCollection;

use Pim\Behat\Context\DBALPurger;
use Pim\Bundle\ExtendedAttributeTypeBundle\AttributeType\ExtendedAttributeTypes;
use Pim\Component\Catalog\Model\AttributeInterface;
use Pim\Component\Catalog\Repository\AttributeGroupRepositoryInterface;
use Pim\Component\Catalog\Repository\AttributeRepositoryInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;

class TextCollectionTest extends KernelTestCase
{
/** @var ContainerInterface */
private $container;

/** @var AttributeRepositoryInterface */
private $attributeRepo;

/** @var AttributeGroupRepositoryInterface */
private $attributeGroupRepo;

public function setUp()
{
self::bootKernel();
$this->container = self::$kernel->getContainer();
$connection = $this->container->get('doctrine.dbal.default_connection');
$purger = new DBALPurger($connection, ['pim_catalog_group_attribute', 'pim_catalog_attribute']);
$purger->purge();

$this->attributeRepo = $this->container->get('pim_catalog.repository.attribute');
$this->attributeGroupRepo = $this->container->get('pim_catalog.repository.attribute_group');
}

public function testCreateAttribute()
{
$factory = $this->container->get('pim_catalog.factory.attribute');
$attribute = $factory->createAttribute('pim_catalog_text_collection');
$attribute->setCode('my_collection');
$this->assertEquals(ExtendedAttributeTypes::TEXT_COLLECTION, $attribute->getAttributeType());
$this->assertEquals(ExtendedAttributeTypes::BACKEND_TYPE_TEXT_COLLECTION, $attribute->getBackendType());

$defaultGroup = $this->attributeGroupRepo->findDefaultAttributeGroup();
$attribute->setGroup($defaultGroup);

$saver = $this->container->get('pim_catalog.saver.attribute');
$saver->save($attribute);
unset($attributeGroupRepo);
unset($attribute);

/** @var AttributeInterface $savedAttribute */
$savedAttribute = $this->attributeRepo->findOneByIdentifier('my_collection');
$this->assertInstanceOf(AttributeInterface::class, $savedAttribute);
$this->assertEquals(ExtendedAttributeTypes::TEXT_COLLECTION, $savedAttribute->getAttributeType());
$this->assertEquals(ExtendedAttributeTypes::BACKEND_TYPE_TEXT_COLLECTION, $savedAttribute->getBackendType());
$this->assertEquals($defaultGroup->getCode(), $savedAttribute->getGroup()->getCode());
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
},
"autoload": {
"psr-4": {
"Pim\\Bundle\\ExtendedAttributeTypeBundle\\": "src/"
"Pim\\Bundle\\ExtendedAttributeTypeBundle\\": "src/",
"Pim\\Bundle\\ExtendedCeBundle\\": "doc/example/PimBundle/ExtendedCeBundle",
"Pim\\Bundle\\ExtendedEeBundle\\": "doc/example/PimBundle/ExtendedEeBundle"
}
},
"config": {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppEEBundle\DependencyInjection;
namespace Pim\Bundle\ExtendedCeBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -10,7 +10,7 @@
/**
* @author Romain Monceau <[email protected]>
*/
class AcmeAppEEExtension extends Extension
class ExtendedCeExtension extends Extension
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppBundle;
namespace Pim\Bundle\ExtendedCeBundle;

use Akeneo\Bundle\StorageUtilsBundle\AkeneoStorageUtilsBundle;
use Akeneo\Bundle\StorageUtilsBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
Expand All @@ -10,15 +10,15 @@
/**
* @author Romain Monceau <[email protected]>
*/
class AcmeAppBundle extends Bundle
class ExtendedCeBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
$productMappings = [
realpath(__DIR__ . '/Resources/config/model/doctrine') => 'Acme\Bundle\AppBundle\Model'
realpath(__DIR__ . '/Resources/config/model/doctrine') => 'Pim\Bundle\ExtendedCeBundle\Model'
];

$container->addCompilerPass(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppBundle\Model;
namespace Pim\Bundle\ExtendedCeBundle\Model;

use Pim\Bundle\ExtendedAttributeTypeBundle\Model\TextCollectionValueTrait;
use Pim\Component\Catalog\Model\ProductValue as PimProductValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ akeneo_storage_utils:
mapping_overrides:
-
original: Pim\Component\Catalog\Model\ProductValue
override: Acme\Bundle\AppBundle\Model\ProductValue
override: Pim\Bundle\ExtendedCeBundle\Model\ProductValue
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
pim_catalog.entity.product_value.class: Pim\Bundle\ExtendedCeBundle\Model\ProductValue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Acme\Bundle\AppBundle\Model\ProductValue:
Pim\Bundle\ExtendedCeBundle\Model\ProductValue:
type: embeddedDocument
fields:
textCollection:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Acme\Bundle\AppBundle\Model\ProductValue:
Pim\Bundle\ExtendedCeBundle\Model\ProductValue:
type: entity
table: pim_catalog_product_value
changeTrackingPolicy: DEFERRED_EXPLICIT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
database_driver: pdo_mysql
database_host: mysql
database_port: null
database_name: akeneo_pim
database_user: akeneo_pim
database_password: akeneo_pim
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
installer_data: PimInstallerBundle:minimal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppBundle\DependencyInjection;
namespace Pim\Bundle\ExtendedEeBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -10,7 +10,7 @@
/**
* @author Romain Monceau <[email protected]>
*/
class AcmeAppExtension extends Extension
class ExtendedEeExtension extends Extension
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppEEBundle\Doctrine\ORM;
namespace Pim\Bundle\ExtendedEeBundle\Doctrine\ORM;

use PimEnterprise\Bundle\CatalogBundle\Doctrine\ORM\CompletenessGenerator as BaseCompletenessGenerator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppEEBundle;
namespace Pim\Bundle\ExtendedEeBundle;

use Akeneo\Bundle\StorageUtilsBundle\AkeneoStorageUtilsBundle;
use Akeneo\Bundle\StorageUtilsBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
Expand All @@ -10,15 +10,15 @@
/**
* @author Romain Monceau <[email protected]>
*/
class AcmeAppEEBundle extends Bundle
class ExtendedEeBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
$productMappings = [
realpath(__DIR__ . '/Resources/config/model/doctrine') => 'Acme\Bundle\AppEEBundle\Model'
realpath(__DIR__ . '/Resources/config/model/doctrine') => 'Pim\Bundle\ExtendedEeBundle\Model'
];

$container->addCompilerPass(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppEEBundle\Model;
namespace Pim\Bundle\ExtendedEeBundle\Model;

use Pim\Bundle\ExtendedAttributeTypeBundle\Model\TextCollectionValueTrait;
use PimEnterprise\Component\Catalog\Model\ProductValue as PimProductValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Acme\Bundle\AppEEBundle\Model;
namespace Pim\Bundle\ExtendedEeBundle\Model;

use Pim\Bundle\ExtendedAttributeTypeBundle\Model\TextCollectionValueTrait;
use PimEnterprise\Component\Workflow\Model\PublishedProductValue as PimPublishedProductValue;
Expand Down
Loading

0 comments on commit 4828c58

Please sign in to comment.