|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches-ignore: |
| 6 | + - 'dependabot/**' |
| 7 | + pull_request: ~ |
| 8 | + release: |
| 9 | + types: [created] |
| 10 | + schedule: |
| 11 | + - |
| 12 | + cron: "0 1 * * 6" # Run at 1am every Saturday |
| 13 | + workflow_dispatch: ~ |
| 14 | + |
| 15 | +jobs: |
| 16 | + tests: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" |
| 20 | + |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + php: ["8.3"] |
| 25 | + symfony: ["^7.3"] |
| 26 | + sylius: ["^2.1"] |
| 27 | + node: ["22.x"] |
| 28 | + mysql: ["8.4"] |
| 29 | + |
| 30 | + env: |
| 31 | + APP_ENV: test |
| 32 | + DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" |
| 33 | + |
| 34 | + steps: |
| 35 | + - |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - |
| 39 | + name: Setup PHP |
| 40 | + uses: shivammathur/setup-php@v2 |
| 41 | + with: |
| 42 | + php-version: "${{ matrix.php }}" |
| 43 | + extensions: intl |
| 44 | + tools: flex,symfony |
| 45 | + coverage: none |
| 46 | + |
| 47 | + - |
| 48 | + name: Setup Node |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: "${{ matrix.node }}" |
| 52 | + |
| 53 | + - |
| 54 | + name: Shutdown default MySQL |
| 55 | + run: sudo service mysql stop |
| 56 | + |
| 57 | + - |
| 58 | + name: Setup MySQL |
| 59 | + uses: mirromutth/mysql-action@v1.1 |
| 60 | + with: |
| 61 | + mysql version: "${{ matrix.mysql }}" |
| 62 | + mysql root password: "root" |
| 63 | + |
| 64 | + - |
| 65 | + name: Output PHP version for Symfony CLI |
| 66 | + run: php -v | head -n 1 | awk '{ print $2 }' > .php-version |
| 67 | + |
| 68 | + - |
| 69 | + name: Install certificates |
| 70 | + run: symfony server:ca:install |
| 71 | + |
| 72 | + - |
| 73 | + name: Get Composer cache directory |
| 74 | + id: composer-cache |
| 75 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 76 | + |
| 77 | + - |
| 78 | + name: Cache Composer |
| 79 | + uses: actions/cache@v4 |
| 80 | + with: |
| 81 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 82 | + key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} |
| 83 | + restore-keys: | |
| 84 | + ${{ runner.os }}-php-${{ matrix.php }}-composer- |
| 85 | +
|
| 86 | + - |
| 87 | + name: Configure global composer |
| 88 | + run: | |
| 89 | + composer global config --no-plugins allow-plugins.symfony/flex true |
| 90 | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2" |
| 91 | +
|
| 92 | + - |
| 93 | + name: Restrict Symfony version |
| 94 | + if: matrix.symfony != '' |
| 95 | + run: | |
| 96 | + composer config extra.symfony.require "${{ matrix.symfony }}" |
| 97 | +
|
| 98 | + - |
| 99 | + name: Restrict Sylius version |
| 100 | + if: matrix.sylius != '' |
| 101 | + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction |
| 102 | + |
| 103 | + - |
| 104 | + name: Install PHP dependencies |
| 105 | + run: composer install --no-interaction |
| 106 | + |
| 107 | + - |
| 108 | + name: Validate composer.json |
| 109 | + run: composer validate --ansi --strict |
| 110 | + |
| 111 | + - |
| 112 | + name: Run PHPStan |
| 113 | + run: vendor/bin/phpstan analyse |
| 114 | + |
| 115 | + - |
| 116 | + name: Run ECS |
| 117 | + run: vendor/bin/ecs check |
| 118 | + |
| 119 | + - |
| 120 | + name: Run unit tests |
| 121 | + run: vendor/bin/phpunit --colors=always |
| 122 | + |
| 123 | + - |
| 124 | + name: Validate container |
| 125 | + run: vendor/bin/console lint:container |
| 126 | + |
| 127 | + - |
| 128 | + name: Get Yarn cache directory |
| 129 | + id: yarn-cache |
| 130 | + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT |
| 131 | + |
| 132 | + - |
| 133 | + name: Cache Yarn |
| 134 | + uses: actions/cache@v4 |
| 135 | + with: |
| 136 | + path: ${{ steps.yarn-cache.outputs.dir }} |
| 137 | + key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} |
| 138 | + restore-keys: | |
| 139 | + ${{ runner.os }}-node-${{ matrix.node }}-yarn- |
| 140 | +
|
| 141 | + - |
| 142 | + name: Install JS dependencies |
| 143 | + run: (cd vendor/sylius/test-application && yarn install) |
| 144 | + |
| 145 | + - |
| 146 | + name: Prepare test application database |
| 147 | + run: | |
| 148 | + vendor/bin/console doctrine:database:create -vvv |
| 149 | + vendor/bin/console doctrine:migrations:migrate -n -vvv -q |
| 150 | +
|
| 151 | + - |
| 152 | + name: Validate database schema |
| 153 | + run: vendor/bin/console doctrine:schema:validate |
| 154 | + |
| 155 | + - |
| 156 | + name: Prepare test application assets |
| 157 | + run: | |
| 158 | + vendor/bin/console assets:install -vvv |
| 159 | + (cd vendor/sylius/test-application && yarn build) |
| 160 | +
|
| 161 | + - |
| 162 | + name: Prepare test application cache |
| 163 | + run: vendor/bin/console cache:warmup -vvv |
| 164 | + |
| 165 | + - |
| 166 | + name: Load fixtures in test application |
| 167 | + run: vendor/bin/console sylius:fixtures:load -n |
0 commit comments