make sure integration test does not crash #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
env: | |
COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }} | |
PHP_VERSION: ${{ secrets.PHP_VERSION }} | |
MYSQL_HOST: ${{ secrets.MYSQL_HOST }} | |
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | |
MYSQL_USER: ${{ secrets.MYSQL_USER }} | |
MYSQL_PORT: ${{ secrets.MYSQL_PORT }} | |
ELASTIC_HOST: ${{ secrets.ELASTIC_HOST }} | |
ELASTIC_PORT: 9200 | |
PACKAGIST_URL: ${{ secrets.PACKAGIST_URL }} | |
MAGENTO_VERSION: '2.4.2' | |
MODULE_NAME: 'vendic/magento2-postcode-nl' | |
on: | |
push: | |
branches: | |
- '**' | |
tags-ignore: | |
- '*.*.*' | |
jobs: | |
phpcs: | |
name: Code styling | |
runs-on: self-hosted | |
steps: | |
- name: Clean | |
run: | | |
if [ -f "/home/runner/.ssh/id_rsa" ]; then rm /home/runner/.ssh/id_rsa; fi | |
echo "Cleaning up previous run" | |
rm -rf "${{ github.workspace }}" | |
rm -rf $HOME/.ssh | |
mkdir -p "${{ github.workspace }}" | |
- uses: actions/checkout@v2 | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
coverage: none | |
php-version: ${{ env.PHP_VERSION }} | |
tools: composer:v1, | |
extensions: gd, bcmath, soap, pdo_mysql, ctype, curl, dom, hash, iconv, intl, mbstring, openssl, simplexml, xsl, sockets, zip | |
env: | |
runner: self-hosted | |
- name: Create empty folders | |
run: | | |
mkdir -p app/etc | |
touch app/etc/vendor_path.php | |
- name: Setup composer repositories | |
run: | | |
composer config repositories.private-packagist composer ${{ env.PACKAGIST_URL }} | |
composer config repositories.packagist.org false | |
- name: Install composer dependencies | |
run: | | |
composer config --global --auth http-basic.repo.packagist.com token ${{ env.COMPOSER_TOKEN }} | |
composer install --prefer-dist | |
- name: Run phpcs | |
run: | | |
vendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard/ | |
vendor/bin/phpcs --standard=Magento2 ./ --ignore="*vendor/*" | |
integration: | |
name: Integration tests | |
runs-on: self-hosted | |
steps: | |
- name: Clean | |
run: | | |
if [ -f "/home/runner/.ssh/id_rsa" ]; then rm /home/runner/.ssh/id_rsa; fi | |
echo "Cleaning up previous run" | |
rm -rf "${{ github.workspace }}" | |
rm -rf $HOME/.ssh | |
mkdir -p "${{ github.workspace }}" | |
- uses: actions/checkout@v2 | |
- uses: FranzDiebold/github-env-vars-action@v2 | |
- name: Set DB name | |
run: | | |
# DB name | |
DB_NAME=$(< /dev/urandom tr -dc a-z | head -c9) | |
echo "DB_NAME=$DB_NAME" >> $GITHUB_ENV | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
with: | |
coverage: none | |
php-version: ${{ env.PHP_VERSION }} | |
tools: composer:v1 | |
extensions: gd, bcmath, soap, pdo_mysql, ctype, curl, dom, hash, iconv, intl, mbstring, openssl, simplexml, xsl, sockets, zip | |
env: | |
runner: self-hosted | |
- name: Create folder for Magento 2 | |
run: | | |
mkdir magento2 | |
chmod 775 magento2 | |
- name: Setup composer authentication | |
run: | | |
composer config --global --auth http-basic.repo.packagist.com token ${{ env.COMPOSER_TOKEN }} | |
- name: Copy Magento 2 composer.json | |
run: | | |
cp .github/workflows/_files/composer.json magento2/composer.json | |
- name: Prepare test database | |
run: | | |
echo 'CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};' | mysql -h ${{ env.MYSQL_HOST }} -u${{ env.MYSQL_USER}} -p${{ env.MYSQL_PASSWORD }} --port=${{ env.MYSQL_PORT }} | |
- name: Prepare integration test config | |
run: | | |
sed -i -e "s/{{mysql-db-name}}/${{ env.DB_NAME }}/g" .github/workflows/_files/install-config-mysql.php | |
sed -i -e "s/{{mysql-host}}/${{ env.MYSQL_HOST }}:${{ env.MYSQL_PORT }}/g" .github/workflows/_files/install-config-mysql.php | |
sed -i -e "s/{{mysql-password}}/${{ env.MYSQL_PASSWORD }}/g" .github/workflows/_files/install-config-mysql.php | |
sed -i -e "s/{{mysql-user}}/${{ env.MYSQL_USER }}/g" .github/workflows/_files/install-config-mysql.php | |
sed -i -e "s/{{elasticsearch-host}}/${{ env.ELASTIC_HOST }}/g" .github/workflows/_files/install-config-mysql.php | |
sed -i -e "s/{{elasticsearch-port}}/${{ env.ELASTIC_PORT }}/g" .github/workflows/_files/install-config-mysql.php | |
mkdir -p magento2/dev/tests/integration/etc | |
cp .github/workflows/_files/install-config-mysql.php magento2/dev/tests/integration/etc/install-config-mysql.php | |
cat magento2/dev/tests/integration/etc/install-config-mysql.php | |
- name: Setup Magento 2 | |
run: | | |
cd magento2 | |
COMPOSER_MEMORY_LIMIT=-3 composer require magento/product-community-edition ${{ env.MAGENTO_VERSION }} --no-update | |
COMPOSER_MEMORY_LIMIT=-3 composer update | |
COMPOSER_MEMORY_LIMIT=-3 composer config minimum-stability dev | |
- name: Install module | |
run: | | |
cd magento2 | |
COMPOSER_MEMORY_LIMIT=-3 composer require ${{ env.MODULE_NAME }}:dev-${{ env.CI_REF_NAME }} | |
- name: Run integration tests | |
run: | | |
cd magento2/dev/tests/integration | |
../../../vendor/bin/phpunit -c phpunit.xml.dist ../../../vendor/${{ env.MODULE_NAME }} | |
- name: Clean DB | |
if: ${{ always() }} | |
run: | | |
echo 'DROP DATABASE IF EXISTS ${{ env.DB_NAME }};' | mysql -h ${{ env.MYSQL_HOST }} -u${{ env.MYSQL_USER}} -p${{ env.MYSQL_PASSWORD }} --port=${{ env.MYSQL_PORT }} |