From 1f70b1f0e49b32dceadfdbb88c508f2deedf1af6 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Mon, 5 Aug 2024 20:42:02 -0700 Subject: [PATCH] Update PhpStan workflow --- .github/phpstan.svg | 22 +---------------- .github/workflows/phpstan.yml | 45 +++++++++++++++++------------------ 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/.github/phpstan.svg b/.github/phpstan.svg index 74a2e6d9..99531587 100644 --- a/.github/phpstan.svg +++ b/.github/phpstan.svg @@ -1,21 +1 @@ - - - - - - - - - - - - - - - - PHPStan - PHPStan - 8 - 8 - - \ No newline at end of file +PHPStan: Level 8❌PHPStanLevel 8❌ \ No newline at end of file diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 8f35765f..08db3c78 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -36,37 +36,36 @@ jobs: tools: composer, cs2pr extensions: zip - - name: Update environment config for GitHub Actions - env: - PLUGIN_SLUG: ${{ github.event.repository.name }} - run: | - find . -depth \( -name '.env.testing' \) -exec sed -i "s/TEST_SITE_DB_HOST=\"127.0.0.1\"/TEST_SITE_DB_HOST=\"127.0.0.1:${{ job.services.mysql.ports['3306'] }}\"/g" {} + - find . -depth \( -name '.env.testing' -o -name '*.cest' \) -exec sed -i "s/localhost:8080\/${{ env.PLUGIN_SLUG }}/localhost:8080/g" {} + - find . -depth \( -name 'dump.sql' \) -exec sed -i "s/localhost:8080\/${{ env.PLUGIN_SLUG }}/localhost:8080/g" {} + - - name: Read .env.testing uses: c-py/action-dotenv-to-setenv@v2 with: env-file: .env.testing - - name: Configure MySQL - run: | - mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE USER '"$TEST_DB_USER"'@'%' IDENTIFIED WITH mysql_native_password BY '"$TEST_DB_PASSWORD"';"; - mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE DATABASE "$TEST_SITE_DB_NAME"; USE "$TEST_SITE_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_SITE_DB_NAME".* TO '"$TEST_DB_USER"'@'%';"; - mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -ppassword -e "CREATE DATABASE "$TEST_DB_NAME"; USE "$TEST_DB_NAME"; GRANT ALL PRIVILEGES ON "$TEST_DB_NAME".* TO '"$TEST_DB_USER"'@'%';"; - - # - name: Create Composer auth.json - # run: php -r "file_put_contents( 'auth.json', json_encode( [ 'http-basic' => [ 'blog.brianhenry.ie' => [ 'username' => '"${{ secrets.COMPOSER_AUTH_SECRET }}"', 'password' => 'satispress' ] ] ] ) );" - - name: Run composer install continue-on-error: true run: composer install - - name: Create wpconfig ... the composer.json creation didn't work - run: | - export $(grep -v '^#' .env.testing | xargs); - sudo vendor/bin/wp config create --dbname=$TEST_SITE_DB_NAME --dbuser=$TEST_SITE_DB_USER --dbpass=$TEST_SITE_DB_PASSWORD --dbhost=127.0.0.1:${{ job.services.mysql.ports['3306'] }} --allow-root --extra-php="define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true );" - - name: Run PHPStan to add annotations to the code + id: run-phpstan continue-on-error: true - run: vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G --no-progress --error-format=checkstyle | cs2pr \ No newline at end of file + run: vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G --no-progress --error-format=checkstyle | cs2pr + + - name: Get PhpStan level + id: phpstan-level + run: | + LEVEL=$(cat phpstan.neon | grep level | sed "s/[^0-9]*//") + echo "level=$LEVEL" >> "$GITHUB_OUTPUT" + + - name: Check success + if: steps.run-phpstan.outcome == 'success' + run: curl -o .github/phpstan.svg https://img.shields.io/badge/PHPStan-Level%20${{ steps.phpstan-level.outputs.level}}-2a5ea7.svg + + - name: Check failures + if: steps.run-phpstan.outcome != 'success' + run: curl -o .github/phpstan.svg https://img.shields.io/badge/PHPStan-Level%20${{ steps.phpstan-level.outputs.level}}❌-lightgrey.svg + + - name: Commit README badge changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + file_pattern: ".github/phpstan.svg" + commit_message: "🤖 PhpStan" \ No newline at end of file