Skip to content

Commit

Permalink
Upgrade PHPStan and use Composer v2 (#62)
Browse files Browse the repository at this point in the history
* Upgrade PHPStan and use Composer v2

* Revert to Composer v2.2

* Fix Composer version

* Fix CI

* Upgrade actions/cache action

* Upgrade OS version in CI
  • Loading branch information
szepeviktor authored Mar 15, 2023
1 parent f5659d8 commit a1fe637
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 107 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
coding-standards:
name: "Coding Standards"

runs-on: "ubuntu-18.04"
runs-on: "ubuntu-20.04"

strategy:
matrix:
Expand All @@ -29,15 +29,15 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.2"
uses: "actions/checkout@v3"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@2.8.0"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
coverage: "none"
tools: "composer:v1"
tools: "composer:2.2"

- name: "Validate composer.json and composer.lock"
run: "composer validate --strict"
Expand All @@ -47,7 +47,7 @@ jobs:
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache PHAR files installed with phive"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: "${{ runner.temp }}/.phive"
key: "php-${{ matrix.php-version }}-phive-${{ matrix.dependencies }}-${{ hashFiles('.phive/phars.xml') }}"
Expand All @@ -65,7 +65,7 @@ jobs:
trustGpgKeys: "C00543248C87FB13,31C7E470E2138192"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
static-code-analysis:
name: "Static Code Analysis"

runs-on: "ubuntu-18.04"
runs-on: "ubuntu-20.04"

strategy:
matrix:
Expand All @@ -107,22 +107,22 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.2"
uses: "actions/checkout@v3"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@2.8.0"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
coverage: "none"
tools: "composer:v1"
tools: "composer:2.2"

- name: "Determine composer cache directory"
shell: "bash"
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache PHAR files installed with phive"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: "${{ runner.temp }}/.phive"
key: "php-${{ matrix.php-version }}-phive-${{ matrix.dependencies }}-${{ hashFiles('.phive/phars.xml') }}"
Expand All @@ -140,7 +140,7 @@ jobs:
trustGpgKeys: "C00543248C87FB13,31C7E470E2138192"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
Expand All @@ -162,21 +162,21 @@ jobs:
run: "mkdir -p .build/phpstan"

- name: "Cache cache directory for phpstan/phpstan"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: ".build/phpstan"
key: "php-${{ matrix.php-version }}-phpstan-${{ github.sha }}"
restore-keys: "php-${{ matrix.php-version }}-phpstan-"

- name: "Run phpstan/phpstan"
run: |
composer require --working-dir=tools "szepeviktor/phpstan-wordpress:^0.6.2"
composer require --working-dir=tools "szepeviktor/phpstan-wordpress:^1.1"
tools/vendor/bin/phpstan analyze src/
tests:
name: "Tests"

runs-on: "ubuntu-18.04"
runs-on: "ubuntu-20.04"

strategy:
matrix:
Expand All @@ -198,22 +198,22 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.2"
uses: "actions/checkout@v3"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@2.8.0"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
coverage: "none"
tools: "composer:v1"
tools: "composer:2.2"

- name: "Determine composer cache directory"
shell: "bash"
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
Expand All @@ -239,7 +239,7 @@ jobs:
tests-old:
name: "Tests on unsupported PHP"

runs-on: "ubuntu-18.04"
runs-on: "ubuntu-20.04"

strategy:
matrix:
Expand All @@ -254,22 +254,22 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.2"
uses: "actions/checkout@v3"

- name: "Install PHP with extensions"
uses: "shivammathur/setup-php@2.8.0"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
coverage: "none"
tools: "composer:v1"
tools: "composer:2.2"

- name: "Determine composer cache directory"
shell: "bash"
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.0"
uses: "actions/cache@v3"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
Expand Down
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="composer-normalize" version="^2.6.1" installed="2.6.1" location="./tools/composer-normalize" copy="false"/>
<phar name="phpcs" version="^3.5.6" installed="3.5.6" location="./tools/phpcs" copy="false"/>
<phar name="composer-normalize" version="~2.28" installed="2.28.3" location="./tools/composer-normalize" copy="false"/>
<phar name="phpcs" version="^3.5.6" installed="3.7.1" location="./tools/phpcs" copy="false"/>
</phive>
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "automattic/wordbless",
"type": "wordpress-dropin",
"description": "WorDBless allows you to use WordPress core functions in your PHPUnit tests without having to set up a database and the whole WordPress environment",
"license": "GPL-2.0-or-later",
"type": "wordpress-dropin",
"authors": [
{
"name": "Automattic Inc."
Expand All @@ -16,28 +16,28 @@
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^9.5"
},
"config": {
"allow-plugins": {
"roots/wordpress-core-installer": true
}
},
"autoload": {
"psr-4": {
"WorDBless\\": "src/",
"WorDBless\\Composer\\": "src/Composer/"
}
},
"config": {
"allow-plugins": {
"roots/wordpress-core-installer": true
}
},
"scripts": {
"post-install-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"post-update-cmd": "WorDBless\\Composer\\InstallDropin::copy",
"ci": [
"phive install --trust-gpg-keys C00543248C87FB13,31C7E470E2138192",
"@composer validate --strict",
"tools/composer-normalize normalize --dry-run",
"@composer require --working-dir=tools 'wp-coding-standards/wpcs:^2.3.0'",
"@composer require --working-dir=tools --dev 'wp-coding-standards/wpcs:^2.3.0'",
"tools/phpcs --config-set installed_paths tools/vendor/wp-coding-standards/wpcs",
"tools/phpcs -s --standard=WordPress-Core --exclude=WordPress.Files.FileName src/",
"@composer require --working-dir=tools 'szepeviktor/phpstan-wordpress:^0.6.2'",
"@composer require --working-dir=tools --dev 'szepeviktor/phpstan-wordpress:^1.1'",
"tools/vendor/bin/phpstan analyze --memory-limit=2G src/",
"@phpunit"
],
Expand Down
Loading

0 comments on commit a1fe637

Please sign in to comment.