From 3313673af8bc37950e7248699b07d5014555ee28 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 2 Oct 2023 12:36:20 +0200 Subject: [PATCH] Added code analysis action --- .github/workflows/pr.yml | 30 ++++++++++++++++++++++++++++++ scripts/code-analysis | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) 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