Merge pull request #322 from utmsigep/dependabot/npm_and_yarn/multi-9… #331
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
# GitHub Action for Symfony with MySQL | |
name: CI Build and Test | |
on: | |
push: | |
branches: [main] | |
paths-ignore: | |
- 'README.md' | |
- 'docs/**' | |
pull_request: | |
branches: [main] | |
paths-ignore: | |
- 'README.md' | |
- 'docs/**' | |
jobs: | |
build: | |
name: Build and Test (PHP ${{ matrix.php-versions }}) | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: false | |
MYSQL_ROOT_PASSWORD: symfony | |
MYSQL_DATABASE: symfony_test | |
ports: | |
- 3306/tcp | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-versions: ['8.1', '8.2'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup PHP, with composer and extensions | |
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: phpunit-bridge | |
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql | |
coverage: xdebug #optional | |
- name: Start mysql service | |
run: sudo systemctl start mysql.service | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache composer dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
# Use composer.json for key, if composer.lock is not committed. | |
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install Composer dependencies | |
run: composer install --no-progress --prefer-dist --optimize-autoloader | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Install Node dependencies | |
run: npm ci | |
- name: Build Webpack | |
run: npm run build | |
- name: Run Migration | |
run: | | |
php bin/console doctrine:database:create --if-not-exists -n | |
php bin/console doctrine:migrations:migrate -n | |
php bin/console doctrine:fixtures:load -n | |
env: | |
DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/symfony_test | |
- name: Run Validators | |
run: | | |
php bin/console lint:yaml config | |
php bin/console lint:twig templates | |
php bin/console lint:xliff translations | |
php bin/console doctrine:schema:validate -vvv --no-interaction | |
env: | |
DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/symfony_test | |
- name: Run PHPUnit | |
run: bin/phpunit --coverage-clover build/coverage-${{ matrix.php-versions }}.xml --log-junit build/phpunit-${{ matrix.php-versions }}.xml | |
env: | |
DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/symfony | |
USPS_USERNAME: ${{ secrets.USPS_USERNAME }} | |
USPS_PASSWORD: ${{ secrets.USPS_PASSWORD }} | |
TWILIO_DSN: ${{ secrets.TWILIO_DSN }} | |
- name: Run PHPStan | |
run: | | |
sed -i 's/var\/cache\/dev/var\/cache\/test/gI' phpstan.neon | |
sed -i 's/App_KernelDevDebugContainer/App_KernelTestDebugContainer/gI' phpstan.neon | |
./vendor/bin/phpstan analyse --memory-limit 2G | |
- name: Upload test result artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results-${{ matrix.php-versions }} | |
path: build/ | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} |