Skip to content

Commit

Permalink
Updated github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
therakib7 committed Apr 4, 2024
1 parent d35e02d commit 87e7d4e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 45 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: PHPCS check

on:
pull_request:
push:
Expand All @@ -12,26 +13,26 @@ concurrency:

jobs:
phpcs:
name: PHPCS check
name: Run PHPCS checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: 'shivammathur/setup-php@v2'
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
ini-values: 'memory_limit=1G'
coverage: none
tools: cs2pr

- name: Install Composer dependencies
uses: 'ramsey/composer-install@v2'
run: composer update

- name: Run PHPCS checks
continue-on-error: true
run: composer run phpcs --report-checkstyle=./phpcs-report.xml
run: composer run phpcs -- --report=checkstyle > phpcs-report.xml

- name: Show PHPCS results in PR
run: cs2pr ./phpcs-report.xml
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
run: cs2pr phpcs-report.xml
14 changes: 6 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
- name: Checkout code
uses: actions/checkout@v2

- name: Use desired version of php (7.4 with xdebug)
- name: Use desired version of PHP (7.4 with xdebug)
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug

- name: Composer install and build
run: |
composer install
composer update
composer dump-autoload -o
- name: Composer install
run: composer install

- name: Running the phpunit tests
- name: Running the PHPUnit tests
continue-on-error: true
run: composer run test
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
},
"require-dev": {
"wp-coding-standards/wpcs": "^3.0",
"phpcompatibility/phpcompatibility-wp": "dev-master",
"wp-phpunit/wp-phpunit": "dev-master",
"yoast/phpunit-polyfills": "^1.0"
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"phpcompatibility/phpcompatibility-wp": "dev-master",
"wp-phpunit/wp-phpunit": "^6.0",
"yoast/phpunit-polyfills": "^1.0",
"doctrine/instantiator": "^1.3.1",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
49 changes: 23 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion tests/phpunit/Api/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ protected function setUp() : void {
/**
* Settings request api exist
*
* Add prefix test_ before function name like test_settings_endpoint_exists
*
* @since 0.1.0
*/
public function test_users_endpoint_exists() {
public function settings_endpoint_exists() {
$endpoint = '/' . $this->namespace . '/' . $this->base;

$request = new WP_REST_Request( 'GET', $endpoint );
Expand All @@ -62,4 +64,14 @@ public function test_users_endpoint_exists() {
$this->assertEquals( 200, $response->get_status() );
}

/**
* Test addition
*
* @since 0.1.0
*/
public function test_addition() {
$result = 2 + 2;
$this->assertEquals(4, $result);
}

}
2 changes: 1 addition & 1 deletion wp-plugin-kit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package WpPluginKit - WpPluginKit
* @author WpPluginKit <therakib7@gmail.com>
* @link https://therakib7.com
* @copyright 2023 WpPluginKit
* @copyright 2024 WpPluginKit
*
* @wordpress-plugin
* Plugin Name: WP Plugin Kit
Expand Down

0 comments on commit 87e7d4e

Please sign in to comment.