Skip to content

Commit

Permalink
Add CS checks
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Dec 17, 2020
1 parent 9975011 commit 39bdea1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
php-74:
name: PHPUnit (PHP 7.4)
name: "PHPUnit (PHP 7.4)"
runs-on: ubuntu-latest

services:
Expand All @@ -31,24 +31,48 @@ jobs:
php-version: "7.4"
extensions: pdo_mysql

- name: Determine composer cache directory
id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"
- name: "List modified files"
id: diff
run: |
git fetch origin
git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} > git_diff_files.txt
echo "::set-output name=diff::$(cat git_diff_files.txt)"
- name: Cache composer dependencies
- name: "Cache composer dependencies"
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.directory }}
path: "~/.composer/cache"
key: composer-${{ hashFiles('**/composer.lock') }}
restore-keys: composer-

- name: "Install PHP dependencies with composer"
- name: "Set project parameters"
run: php bin/configure --default

- name: "Install PHP dependencies with Composer"
run: composer update --no-interaction

- name: "Set project parameters"
run: "php bin/configure --default"
- name: "Install JS dependencies with NPM"
run: npm install

- name: "Build JS files with Webpack"
run: npm run webpack

- name: "Run PHPMD checks"
run: if [ "$DIFF" != '' ]; then vendor/bin/phpmd `echo "$DIFF" | xargs | sed -e :a -e '$!N; s/ /,/; ta'` text phpmd.xml; fi
env:
DIFF: ${{ steps.diff.outputs.diff }}

- name: "Run PHPCSFixer checks"
run: if [ "$DIFF" != '' ]; then vendor/bin/php-cs-fixer fix --dry-run --diff --config=src/main/dev/Resources/travis/php-cs.php; fi
env:
DIFF: ${{ steps.diff.outputs.diff }}

- name: "Run ESLint checks"
run: if [ "$DIFF" != '' ]; then node_modules/.bin/eslint --ext js --ext jsx `echo "$DIFF" | grep 'Resources/modules/.\+\.js' | tr '\n' ' '`; fi
env:
DIFF: ${{ steps.diff.outputs.diff }}

- name: "Install Claroline platform"
- name: "Setup Claroline platform"
run: php bin/console claroline:install --env=test -vvv

- name: "Run PHPUnit Tests"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "claroline/Claroline",
"name": "claroline/claroline",
"description": "Claroline Learning Management System",
"keywords": ["Claroline", "LMS"],
"homepage": "http://www.claroline.net",
Expand Down
4 changes: 2 additions & 2 deletions src/main/dev/Resources/travis/php-cs.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

/*******************************************************************************
* This script is a config file for PHP-CS-Fixer designed for travis builds.
* This script is a config file for PHP-CS-Fixer designed for CI builds.
* It reads a list of targets (supposably files changed by the push/PR) from
* a file located in the root directory and passed them to the CS config (with
* default fixer level: Symfony).
******************************************************************************/

$pkgDir = realpath(__DIR__.'/../../../..');
$pkgDir = realpath(__DIR__.'/../../../../..');
$targetFile = "{$pkgDir}/git_diff_files.txt";

if (!file_exists($targetFile)) {
Expand Down

0 comments on commit 39bdea1

Please # to comment.