From 151f8fcde08d5efc1afd411a7660c5f02016d086 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 5 Apr 2024 11:43:01 +0200 Subject: [PATCH] wip --- .github/workflows/phpstan-reusable.yml | 55 ++++++++++++++++++++++++++ .github/workflows/phpstan.yml | 42 +++++--------------- 2 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/phpstan-reusable.yml diff --git a/.github/workflows/phpstan-reusable.yml b/.github/workflows/phpstan-reusable.yml new file mode 100644 index 0000000000..ca371a9656 --- /dev/null +++ b/.github/workflows/phpstan-reusable.yml @@ -0,0 +1,55 @@ +name: PHPStan + +on: + workflow_call: + inputs: + phpVersions: + required: false + type: string + default: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]' + description: 'PHP versions to test against, JSON encoded array of strings.' + phpExtensions: + required: false + type: string + description: 'PHP extensions to install, comma separated list of strings.' + dependencies: + required: true + type: string + description: 'Dependencies to install, JSON encoded map of path => repository url.' + +jobs: + phpstan: + name: Static analysis with phpstan and php ${{ matrix.php }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + php: ${{ fromJson(inputs.phpVersions) }} + os: ['ubuntu-latest'] + + steps: + - name: Checkout code base + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ inputs.phpExtensions }} + + - name: Setup dependencies + run: | + composer require -n --no-progress phpstan/phpstan + sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git /usr/share/icinga-php/ipl + sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git /usr/share/icinga-php/vendor + paths=`echo '${{ inputs.dependencies }}' | jq -c -r keys[]` + for path in $paths; do + url=`echo '${{ inputs.dependencies }}' | jq -r --arg path $path '.[$path]'` + sudo git clone --depth 1 $url $path + done + + - name: PHPStan + continue-on-error: true + if: ${{ ! cancelled() }} + run: ./vendor/bin/phpstan analyse diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index f94217395d..b83e29e511 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -6,35 +6,13 @@ on: - main jobs: - lint: - name: Static analysis with phpstan and php ${{ matrix.php }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] - os: ['ubuntu-latest'] - - steps: - - name: Checkout code base - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: ldap - - - name: Setup dependencies - run: | - composer require -n --no-progress phpstan/phpstan - sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git /usr/share/icinga-php/ipl - sudo git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git /usr/share/icinga-php/vendor - sudo git clone --depth 1 https://github.com/Icinga/icingaweb2-module-x509.git /usr/share/icingaweb2-modules/x509 - sudo git clone --depth 1 https://github.com/Icinga/icingadb-web.git /usr/share/icingaweb2-modules/icingadb - sudo git clone --depth 1 https://github.com/Icinga/icingaweb2-module-pdfexport.git /usr/share/icingaweb2-modules/pdfexport - - - name: PHPStan - if: ${{ ! cancelled() }} - run: ./vendor/bin/phpstan analyse + phpstan: + uses: ./.github/workflows/phpstan-reusable.yml + with: + phpExtensions: ldap + dependencies: | + { + "/usr/share/icingaweb2-modules/x509": "https://github.com/Icinga/icingaweb2-module-x509.git", + "/usr/share/icingaweb2-modules/icingadb": "https://github.com/Icinga/icingadb-web.git", + "/usr/share/icingaweb2-modules/pdfexport": "https://github.com/Icinga/icingaweb2-module-pdfexport.git" + }