Skip to content

Commit

Permalink
Merge pull request #1 from alleyinteractive/1.0
Browse files Browse the repository at this point in the history
Add initial functionality and tests
  • Loading branch information
dlh01 authored Jun 28, 2022
2 parents b5038df + c911c4a commit c75710d
Show file tree
Hide file tree
Showing 19 changed files with 1,161 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Exclude these files from release archives.
#
# This will also make the files unavailable when using Composer with `--prefer-dist`.
# If you develop using Composer, use `--prefer-source`.
#
# Via WPCS.
#
/phpcs.xml export-ignore
/phpunit.xml export-ignore
/.github export-ignore
/.php-cs-fixer.dist.php export-ignore
/tests export-ignore

#
# Auto detect text files and perform LF normalization.
#
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
#
* text=auto

#
# The above will handle all files not found below.
#
*.md text
*.php text
*.inc text
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Summary

As titled.

## Notes for reviewers

None.

## Changelog entries

### Added

### Changed

### Deprecated

### Removed

### Fixed

### Security
31 changes: 31 additions & 0 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Composer Validation

on:
pull_request:

jobs:
validate:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.1]
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Check out code
uses: actions/checkout@v3

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

- name: Run Composer config validation
run: composer validate --strict
41 changes: 41 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Coding Standards

on:
pull_request:

jobs:
cs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.4]
steps:
- name: Cancel previous runs of this workflow (pull requests only)
if: ${{ github.event_name == 'pull_request' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Check out code
uses: actions/checkout@v3

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

- name: Install composer dependencies
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer install

- name: Run PHPCS
run: composer run-script phpcs

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix -v --dry-run --stop-on-violation --using-cache=no --allow-risky=yes
56 changes: 56 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Tests

on:
pull_request:

jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.1, 8.0, 7.4]
wp_version: ["latest"]
can_fail: [false]
multisite: [0,1]
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
continue-on-error: ${{ matrix.can_fail }}

name: WordPress ${{ matrix.wp_version }} @ PHP ${{ matrix.php }} (WP_MULTISITE=${{ matrix.multisite }})
env:
CACHEDIR: /tmp
WP_CORE_DIR: /tmp/wordpress
WP_VERSION: ${{ matrix.wp_version }}
WP_MULTISITE: ${{ matrix.multisite }}
WP_DB_HOST: 127.0.0.1
WP_DB_USER: root
WP_DB_PASSWORD: '""'

steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, mysqli, curl, dom, exif, fileinfo, hash, imagick, mbstring, openssl, pcre, xml, zip
tools: composer:v2
coverage: none

- name: Install Composer dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer install

- name: Run PHPUnit
run: composer run-script phpunit
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vendor
composer.lock
.php_cs.cache
.phpunit.result.cache
.php-cs-fixer.cache
36 changes: 36 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* PHP-CS-Fixer configuration
*
* (c) Alley <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package wp-find-one
*/

$finder = PhpCsFixer\Finder::create()->in(
[
__DIR__ . '/src/',
__DIR__ . '/tests/',
]
);

$config = new PhpCsFixer\Config();
$config->setRules(
[
'@PHP81Migration' => true,
// Enabled by '@PHP81Migration' but generates invalid spacing for WordPress.
'method_argument_space' => false,

'final_class' => true,
'native_constant_invocation' => true,
'native_function_casing' => true,
'native_function_invocation' => true,
'native_function_type_declaration_casing' => true,
]
);
$config->setFinder( $finder );

return $config;
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

This library adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/en/1.0.0/).

## 1.0.0

Initial release.
Loading

0 comments on commit c75710d

Please sign in to comment.