Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial functionality and tests #1

Merged
merged 15 commits into from
Jun 28, 2022
26 changes: 26 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# 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
/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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No 8.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge, Composer config validation depend on the PHP version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gah: Composer config validation doesn't depend on the PHP version

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
38 changes: 38 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Coding Standards

on:
pull_request:

jobs:
phpcs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [7.4]
montchr marked this conversation as resolved.
Show resolved Hide resolved
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 phpcs
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]
montchr marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: |
--health-cmd="mysqladmin ping" \
--health-interval=10s \
--health-timeout=5s \
--health-retries=3

continue-on-error: ${{ matrix.multisite == '1' }}

name: WordPress ${{ matrix.wp_version }} @ PHP ${{ matrix.php }} (WP_MULTISITE=${{ matrix.multisite }})
montchr marked this conversation as resolved.
Show resolved Hide resolved
env:
CACHEDIR: /tmp
WP_CORE_DIR: /tmp/wordpress
WP_VERSION: ${{ matrix.wp_version }}
montchr marked this conversation as resolved.
Show resolved Hide resolved
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 phpunit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor
composer.lock
.php_cs.cache
.phpunit.result.cache
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