Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ root = true

[*]
charset = utf-8
indent_style = tab
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_style = space
indent_size = 2

[*.{json,xml,dist}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Reformat to the PHPUnit plugin's coding style (PER-CS 3.0)
07a4667a5309a7cd63acf2f8a56a327d3c0fcff7
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/phpcs.xml export-ignore
/phpcs.xml.dist export-ignore
/.git-blame-ignore-revs export-ignore
/.php-cs-fixer.php export-ignore
/phpunit.xml export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/README.md export-ignore
/test.php export-ignore
/tests export-ignore

*.phpstub linguist-language=PHP
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: CI

on:
push:
branches:
- master
pull_request:
schedule:
- cron: '0 4 * * 6' # Every Saturday at 4am
workflow_dispatch:

permissions:
contents: read

# A new push to a pull request cancels its running jobs; other runs get a unique group.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
php-cs-fixer:
name: Code style
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer:v2, cs2pr
coverage: none

- name: Get Composer cache directories
id: composer-cache
run: |
echo "files_cache=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
echo "vcs_cache=$(composer config cache-vcs-dir)" >> "$GITHUB_OUTPUT"

- name: Retrieve cached packages
uses: actions/cache@v6
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
${{ steps.composer-cache.outputs.vcs_cache }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer check --format=checkstyle | cs2pr

tests:
name: Tests on PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- '8.1'
- '8.2'
- '8.3'
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: none

- name: Get Composer cache directories
id: composer-cache
run: |
echo "files_cache=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
echo "vcs_cache=$(composer config cache-vcs-dir)" >> "$GITHUB_OUTPUT"

- name: Retrieve cached packages
uses: actions/cache@v6
with:
path: |
${{ steps.composer-cache.outputs.files_cache }}
${{ steps.composer-cache.outputs.vcs_cache }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-composer-

# Psalm's test classes come from its source checkout (see "preferred-install" in composer.json).
- name: Install dependencies
run: composer install --ansi --no-interaction --no-progress

- name: Show Psalm version
run: vendor/bin/psalm --version

- name: Run tests
run: vendor/bin/phpunit
36 changes: 0 additions & 36 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.phpunit.result.cache
.php-cs-fixer.cache
composer.lock
/stubs/wordpress/
/stubs/vendor/
/vendor/
/tools/phpcs/vendor/
38 changes: 38 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

return (new Config())
->setUnsupportedPhpVersionAllowed(true)
->setRiskyAllowed(false)
->setRules([
'@PER-CS3x0' => true,
'binary_operator_spaces' => ['default' => 'single_space'],
// import
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
'no_unused_imports' => true,
'ordered_imports' => true,
])
->setFinder(
(new Finder())
->in([
__DIR__ . '/stubs',
__DIR__ . '/tests',
])
->name('*.php')
->exclude(['vendor', 'wordpress'])
->append([
__DIR__ . '/Plugin.php',
__DIR__ . '/test.php',
__FILE__,
]),
)
->setParallelConfig(ParallelConfigFactory::detect());
Loading
Loading