Skip to content

Commit

Permalink
refactor #164 Initialize GitHub actions (clem21, GSadee)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.1-dev branch.

Discussion
----------



Commits
-------

bd0d7a3 intialize Github Actions
e1b0814 Fixes to GitHub Actions build configuration
4053c7f Add missing migrations for Sylius 1.7
  • Loading branch information
GSadee authored Apr 13, 2021
2 parents 62485d9 + 4053c7f commit 799ee68
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 79 deletions.
186 changes: 186 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Build

on:
push: ~
pull_request: ~
release:
types: [created]
schedule:
-
cron: "0 1 * * 6" # Run at 1am every Saturday

jobs:
tests:
runs-on: ubuntu-latest

name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"

strategy:
fail-fast: false
matrix:
php: [7.3, 7.4]
symfony: [^4.4]
sylius: [~1.7.0]
node: [10.x]
mysql: [5.7, 8.0]

exclude:
- # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0
php: 7.3
mysql: 8.0

env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"

steps:
-
uses: actions/checkout@v2

-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: intl, gd
tools: symfony
coverage: none

-
name: Setup Node
uses: actions/setup-node@v1
with:
node-version: "${{ matrix.node }}"

-
name: Shutdown default MySQL
run: sudo service mysql stop

-
name: Setup MySQL
uses: mirromutth/[email protected]
with:
mysql version: "${{ matrix.mysql }}"
mysql root password: "root"

-
name: Output PHP version for Symfony CLI
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version

-
name: Install certificates
run: symfony server:ca:install

-
name: Run Chrome Headless
run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &

-
name: Run webserver
run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon)

-
name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

-
name: Cache Composer
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-
-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"
-
name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

-
name: Install PHP dependencies
run: composer update --no-interaction

-
name: Get Yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

-
name: Cache Yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-yarn-
-
name: Install JS dependencies
run: (cd tests/Application && yarn install)

-
name: Prepare test application database
run: |
(cp migrations/* tests/Application/src/Migrations/)
(cd tests/Application && bin/console doctrine:database:create -vvv)
(cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv -q)
-
name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build)
-
name: Prepare test application cache
run: (cd tests/Application && bin/console cache:warmup -vvv)

-
name: Load fixtures in test application
run: (cd tests/Application && bin/console sylius:fixtures:load -n)

-
name: Validate composer.json
run: composer validate --ansi --strict

-
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run security check
run: symfony security:check

-
name: Run PHPStan
run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

-
name: Run PHPUnit
run: vendor/bin/phpunit --colors=always

-
name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun

-
name: Upload Behat logs
uses: actions/upload-artifact@v2
if: failure()
with:
name: Behat logs
path: etc/build/
if-no-files-found: ignore
77 changes: 0 additions & 77 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@
},
"scripts": {
"analyse": [
"@composer validate --strict",
"vendor/bin/phpstan analyse -c phpstan.neon -l max src/",
"vendor/bin/ecs check src/ spec/"
],
"fix": [
"vendor/bin/ecs check src/ spec/ --fix"
]
},
"extra": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Feature: Previewing order before creation
And I select "Free" shipping method
And I select "Cash on Delivery" payment method
And I place this order
Then I should see preview of the order with total "PLN100.00"
Then I should see preview of the order with total "PLN 100.00"
And this order should contain "Stark Coat" product
And its shipping total should be "PLN0.00"
And its shipping total should be "PLN 0.00"
And it should have one "Cash on Delivery" payment
And it should have "English (United States)" locale
And it should have "PLN" currency
Expand Down
25 changes: 25 additions & 0 deletions tests/Application/src/Migrations/Version20191119131635.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20191119131635 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_channel ADD type VARCHAR(255) DEFAULT NULL');
}

public function down(Schema $schema): void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_channel DROP type');
}
}
45 changes: 45 additions & 0 deletions tests/Application/src/Migrations/Version20200301170604.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200301170604 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE sylius_channel_countries (channel_id INT NOT NULL, country_id INT NOT NULL, INDEX IDX_D96E51AE72F5A1AA (channel_id), INDEX IDX_D96E51AEF92F3E70 (country_id), PRIMARY KEY(channel_id, country_id)) DEFAULT CHARACTER SET UTF8 COLLATE `UTF8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE sylius_channel_countries ADD CONSTRAINT FK_D96E51AE72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE sylius_channel_countries ADD CONSTRAINT FK_D96E51AEF92F3E70 FOREIGN KEY (country_id) REFERENCES sylius_country (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE sylius_shipment ADD shipped_at DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE sylius_channel ADD menu_taxon_id INT DEFAULT NULL, DROP type');
$this->addSql('ALTER TABLE sylius_channel ADD CONSTRAINT FK_16C8119EF242B1E6 FOREIGN KEY (menu_taxon_id) REFERENCES sylius_taxon (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_16C8119EF242B1E6 ON sylius_channel (menu_taxon_id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('DROP TABLE sylius_channel_countries');
$this->addSql('ALTER TABLE sylius_channel DROP FOREIGN KEY FK_16C8119EF242B1E6');
$this->addSql('DROP INDEX IDX_16C8119EF242B1E6 ON sylius_channel');
$this->addSql('ALTER TABLE sylius_channel ADD type VARCHAR(255) CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_unicode_ci`, DROP menu_taxon_id');
$this->addSql('ALTER TABLE sylius_shipment DROP shipped_at');
}
}
32 changes: 32 additions & 0 deletions tests/Application/src/Migrations/Version20200916093101.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20200916093101 extends AbstractMigration
{
public function getDescription(): string
{
return 'Make a price on channel pricing nullable';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_channel_pricing CHANGE price price INT DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_channel_pricing CHANGE price price INT NOT NULL');
}
}

0 comments on commit 799ee68

Please sign in to comment.