Skip to content

Commit

Permalink
CI Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre-T committed Apr 5, 2024
1 parent d7c741b commit f7f55ae
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI

on:
push:
pull_request:
branches:
- main
- develop

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3']

name: PHP ${{ matrix.php-version }}
env:
HAS_CC_SECRET: ${{secrets.CC_TEST_REPORTER_ID != '' }}
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
tools: composer:v2

- name: Install dependencies
run: composer --prefer-source update

- name: Run test with coverage
uses: paambaati/[email protected]
if: env.HAS_CC_SECRET == 'true'
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: vendor/bin/phpunit --coverage-clover=.phpunit.cache/clover-${{ matrix.php-version }}.xml
coverageLocations: ${{github.workspace}}/.phpunit.cache/clover*.xml:clover

- name: Run tests for forks
if: env.HAS_CC_SECRET != 'true'
run: vendor/bin/phpunit

## Quality checks
## PHP-CS-Fixer
- name: Cache Composer PHP-CS-FIXER packages
if: ${{ matrix.php-version == '8.3' }}
id: composer-phpcsfixer-cache
uses: actions/cache@v4
with:
path: quality/php-cs-fixer/vendor/
key: ${{ runner.os }}-phpcsfixer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-phpcsfixer-
- name: Install PHP-CS-Fixer
if: ${{ matrix.php-version == '8.3' }}
run: composer update --working-dir=quality/php-cs-fixer

- name: Run PHP-CS-Fixer
if: ${{ matrix.php-version == '8.3' }}
run: ./quality/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=quality/php-cs-fixer/.php-cs-fixer.php --dry-run --allow-risky=yes

## PHP-MESS-DETECTOR
- name: Cache Composer PHP-MESS-DETECTOR packages
if: ${{ matrix.php-version == '8.3' }}
id: composer-phpmd-cache
uses: actions/cache@v4
with:
path: quality/php-cs-fixer/vendor/
key: ${{ runner.os }}-phpmd-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-phpmd-
- name: Install PHP-MESS-DETECTOR
if: ${{ matrix.php-version == '8.3' }}
run: composer update --working-dir=quality/php-mess-detector
- name: Run PHP-MESS-DETECTOR on lib directory
if: ${{ matrix.php-version == '8.3' }}
run: ./quality/php-mess-detector/vendor/bin/phpmd lib text quality/php-mess-detector/ruleset.xml
- name: Run PHP-MESS-DETECTOR on tests directory
if: ${{ matrix.php-version == '8.3' }}
run: ./quality/php-mess-detector/vendor/bin/phpmd tests text quality/php-mess-detector/test-ruleset.xml

## PHP-STAN
- name: Cache Composer PHP-STAN packages
if: ${{ matrix.php-version == '8.3' }}
id: composer-php-stan-cache
uses: actions/cache@v4
with:
path: quality/php-cs-fixer/vendor/
key: ${{ runner.os }}-php-stan-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-stan-
- name: Install PHP-STAN
if: ${{ matrix.php-version == '8.3' }}
run: composer update --working-dir=quality/php-stan
- name: Run PHP-STAN
if: ${{ matrix.php-version == '8.3' }}
run: ./quality/php-stan/vendor/bin/phpstan analyse --configuration=quality/php-stan/php-stan.neon lib tests --error-format=table --no-progress --no-interaction --no-ansi --level=9 --memory-limit=256M -v

0 comments on commit f7f55ae

Please sign in to comment.