cancel
Showing results for 
Search instead for 
Did you mean: 

Running Magento Cloud automated tests on Bitbucket Pipelines

Running Magento Cloud automated tests on Bitbucket Pipelines

Not sure if this is the right subforum, but it didn't fit quite well anywhere else.

I'm currently configuring Bitbucket Pipelines to run the automated tests on our Magento Cloud code and it's running unit, static and integration tests fine so far.

Here's my bitbucket-pipelines.yaml file if anybody is interested:

image: magento/magento-cloud-docker-php:7.2-cli
pipelines:
  default:
    - step:
        name: Unit tests
        caches:
          - composer
        script:
          - echo "$MAGENTO_REPO_AUTH" > auth.json
          - composer install --prefer-dist
          - ./bin/magento module:enable --all
          - ./bin/magento setup:di:compile
          - ./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml
    - step:
        name: PHP Static code tests
        caches:
          - composer
        artifacts:
          - dev/tests/static/report/*
        script:
          - echo "$MAGENTO_REPO_AUTH" > auth.json
          - composer install --prefer-dist
          - ./bin/magento module:enable --all
          - ./bin/magento setup:di:compile
          - ./vendor/bin/phpunit -c dev/tests/static/phpunit.xml.dist --testsuite="PHP Coding Standard Verification" --verbose
    - step:
        name: Magento integration tests
        caches:
          - composer
        services:
          - mysql
          - rabbitmq
          - elasticsearch
        script:
          - echo "$MAGENTO_REPO_AUTH" > auth.json
          - composer install --prefer-dist
          - ./bin/magento module:enable --all
          - ./bin/magento setup:di:compile
          - cp dev/tests/integration/etc/install-config-mysql.php.dist dev/tests/integration/etc/install-config-mysql.php
          - sed -i s/localhost/127.0.0.1/g dev/tests/integration/etc/install-config-mysql.php
          - cd dev/tests/integration && ../../../vendor/bin/phpunit -c phpunit.xml --testsuite="Magento Integration Tests" --verbose

definitions:
  services:
    elasticsearch:
      image: magento/magento-cloud-docker-elasticsearch:6.5
      environment:
        ES_JAVA_OPTS: '-Xms512m -Xmx512m'
    rabbitmq:
      image: rabbitmq:3.5
    mysql:
      image: mariadb:10.0
      variables:
        MYSQL_DATABASE: 'magento_integration_tests'
        MYSQL_ROOT_PASSWORD: '123123q'

I'd like to hear if anybody else did it already and maybe some suggestions to improve this!

 

For example the whole "composer install && setup:di:compile" should be in a seperate step in the beginning ideally, but unfortunately only sharing .vendor and generated as artifacts is not quite enough, since there are so many more files generated all over the place (like app/autoload and stuff in app/etc), so I run it on every step from now.

If somebody has figured out the whole list that would be appreciated.

I also haven't started into looking at running functional tests yet.