diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 080fa373..20466f55 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -83,6 +83,36 @@ jobs: run: | composer coding-standards-check/phpcs + php-code-analysis: + name: PHP code analysis + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: [ '8.1' ] + dependency-version: [ prefer-lowest, prefer-stable ] + steps: + - uses: actions/checkout@master + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: json + coverage: none + tools: composer:v2 + # https://github.com/shivammathur/setup-php#cache-composer-dependencies + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - name: Code analysis + run: | + ./scripts/code-analysis + markdownlint: runs-on: ubuntu-latest name: markdownlint diff --git a/scripts/code-analysis b/scripts/code-analysis index 9fac7c88..97cbef5f 100755 --- a/scripts/code-analysis +++ b/scripts/code-analysis @@ -27,7 +27,7 @@ echo "Module path: $module_path" # Work around # PHP Fatal error: Cannot redeclare drupal_get_filename() (previously declared in /Users/rimi/ITK/github/itk-dev/os2forms_selvbetjening/web/sites/default/modules/os2forms/vendor/drupal/core/includes/bootstrap.inc:190) in /Users/rimi/ITK/github/itk-dev/os2forms_selvbetjening/web/core/includes/bootstrap.inc on line 223 # Remove our non-develop requirements and a develop dependency requiring drupal/core. -docker run --rm --interactive efrecon/jq:1.7 'del(.require, ."require-dev"["drupal/maillog"])' < composer.json >| drupal-module-code-analysis-composer.json +docker run --volume ${PWD}:/app --workdir /app --rm efrecon/jq:1.7 'del(.require, ."require-dev"["drupal/maillog"])' composer.json >| drupal-module-code-analysis-composer.json # It seems that the file system needs a little time to sync. sleep 1