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

Gh actions test #27

Closed
wants to merge 17 commits into from
Closed
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
31 changes: 31 additions & 0 deletions .github/workflows/wp-coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: WP Coding standards

on:
workflow_dispatch:
pull_request:
types: [ opened, synchronize ]

jobs:
phpcs:
name: phpcs
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

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

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-progress --no-ansi --no-interaction"
working-directory: "src/plugin"

- name: Run PHPCS
run: src/plugin/vendor/bin/phpcs --standard=phpcs.xml -q --report=checkstyle | cs2pr --notices-as-warnings
63 changes: 63 additions & 0 deletions .github/workflows/wp-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: PHPUnit Tests

on:
workflow_dispatch:
pull_request:
types: [ opened, synchronize ]

jobs:
phpunit:
name: PHPUnit ${{ matrix.php }}
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
ports:
- 3306/tcp
env:
MYSQL_ROOT_PASSWORD: password
# Set health checks to wait until mysql has started
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3

strategy:
fail-fast: false
matrix:
php: [ '8.3' ]

steps:
- name: Check out Git repository
uses: actions/checkout@v4

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

# Workaround since ramsey/composer-install doesn't support vendor-dir option for composer
- name: Move composer.json and composer.lock to src/plugin/
run: cp composer.json src/plugin/ && cp composer.lock src/plugin/

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
working-directory: "src/plugin"
composer-options: "--no-progress --no-ansi --no-interaction"

- name: Install WordPress test setup
run: bash tests/bin/install-wp-tests.sh wordpress_test root password 127.0.0.1:${{ job.services.mysql.ports[3306] }} latest

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run tests
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib/
working-directory: "./"
run: src/plugin/vendor/bin/phpunit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ firefox/
node_modules/
test-results/
build/
vendor/

.phpunit.result.cache
14 changes: 14 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"core": "WordPress/WordPress",
"phpVersion": "8.3",
"env": {
"tests": {
"phpVersion": "8.3"
}
},
"plugins": [ "./src/plugin" ],
"mappings": {
"wp-content/phpunit.xml.dist": "./phpunit.xml.dist",
"wp-content/tests": "./tests"
}
}
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "wordpress/try-wordpress",
"description": "",
"license": "",
"require-dev": {
"phpunit/phpunit": "^9.6.16",
"yoast/phpunit-polyfills": "^2.0.0",
"wp-coding-standards/wpcs": "^3.0"
},
"scripts": {
"lint": "phpcs --standard=phpcs.xml -s",
"lint:fix": "phpcbf --standard=phpcs.xml",
"dev:start": "wp-env start && wp-env run cli wp rewrite structure '/%postname%/'",
"dev:debug": "wp-env start --xdebug",
"dev:stop": "wp-env stop",
"dev:destroy": "yes | wp-env destroy",
"dev:test": "wp-env run tests-cli --env-cwd=wp-content/ plugins/plugin/vendor/bin/phpunit"
},
"config": {
"vendor-dir": "src/plugin/vendor",
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Loading
Loading