Skip to content

Merge pull request #129 from nplhse/dependabot/composer/vincentlangle… #285

Merge pull request #129 from nplhse/dependabot/composer/vincentlangle…

Merge pull request #129 from nplhse/dependabot/composer/vincentlangle… #285

name: Continuous Integration
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
static-analysis:
name: Static Analysis (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: symfony
MYSQL_DATABASE: symfony
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:
php-versions: ["8.2", "8.3"]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Validate main `composer.json` and `composer.lock` files
run: composer validate --no-check-version
- name: Check if any dependencies are compromised
run: composer audit
- name: Composer Dependencies
uses: "ramsey/composer-install@v3"
- name: Lint YAML files
run: ./bin/console lint:yaml config --parse-tags
- name: Lint Twig templates
run: ./bin/console lint:twig templates
- name: Lint XLIFF translations
run: ./bin/console lint:xliff translations
- name: Lint Parameters and Services
run: ./bin/console lint:container --no-debug
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Lint Doctrine entities
run: ./bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Lint PHP Code (PHP-CS-Fixer)
run: vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run --config=php-cs-fixer.php
- name: Run Migration
run: php bin/console doctrine:schema:create || echo "No schema found or schema failed"
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Analyse PHP Code (PHPStan)
run: vendor/bin/phpstan analyse
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Analyse PHP Code (Psalm)
run: vendor/bin/psalm
- name: Cache node_modules
uses: actions/cache@v4
id: yarn-cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-yarn-cache-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-cache-node-modules-
- name: Yarn install
if: steps.yarn-cache-node-modules.outputs.cache-hit != 'true'
run: yarn install
- name: Analyse JS (ESLint)
run: yarn run eslint assets
tests:
name: Tests (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
services:
mysql:
image: mysql:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: symfony
MYSQL_DATABASE: symfony
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:
php-versions: ["8.2", "8.3"]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Composer Dependencies
uses: "ramsey/composer-install@v3"
- name: Run Migration
run: php bin/console doctrine:schema:create || echo "No schema found or schema failed"
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: "Build Assets"
run: php bin/console importmap:install
- name: Execute tests via PHPUnit
run: vendor/bin/phpunit
env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Upload coverage to Codeclimate
if: ${{ github.actor != 'dependabot[bot]' }}
uses: paambaati/codeclimate-action@v5.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_REPORTER_ID }}
with:
coverageLocations: ${{github.workspace}}/var/coverage/logs/clover.xml:clover
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
directory: ${{github.workspace}}/var/coverage/logs/
verbose: true