From 00f0ade2c69429bc1b5bd1f7c9b6dd23143052c2 Mon Sep 17 00:00:00 2001 From: Mohan <36844205+m0hanraj@users.noreply.github.com> Date: Sat, 25 Mar 2023 16:13:26 +0000 Subject: [PATCH 1/7] Adds phpunit github actions --- .github/workflows/php.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..32cbe27 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,20 @@ +name: PHP + +on: [push] + +jobs: + build-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: php-actions/composer@v6 + + - name: PHPUnit Tests + uses: php-actions/phpunit@master + + with: + bootstrap: vendor/autoload.php + configuration: phpunit.xml + args: --testdox From 84d51ea212316ff793321371cbd7e5d63862c4d6 Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Sat, 25 Mar 2023 16:16:14 +0000 Subject: [PATCH 2/7] updated phpunit config --- phpunit.xml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 5226b6a..c9abd89 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,16 +1,9 @@ - - - - ./tests/Unit/ - - - + + + + + ./tests/Unit/ + + From bf71da7e1ecfb3331cfe8e8a1d4cc4e854fa1b7f Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Sat, 25 Mar 2023 16:22:52 +0000 Subject: [PATCH 3/7] Turns off phpunit warning report --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index c9abd89..46ff28a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + From 69b71f923c225d189001eaca38df181afe4bdad8 Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Sat, 25 Mar 2023 16:24:30 +0000 Subject: [PATCH 4/7] Turns ON phpunit warning repor --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 46ff28a..c9abd89 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + From af92b42117306b458f9e8e2aae58b7c4e1d75d46 Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Sat, 25 Mar 2023 16:35:11 +0000 Subject: [PATCH 5/7] adds test workflow --- .github/workflows/php1.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/php1.yml diff --git a/.github/workflows/php1.yml b/.github/workflows/php1.yml new file mode 100644 index 0000000..d66f74f --- /dev/null +++ b/.github/workflows/php1.yml @@ -0,0 +1,40 @@ +name: PHP Lint & Test +on: [push] +jobs: + lint-test: + name: PHP ${{ matrix.php-versions }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: ['8.1'] + steps: + - name: Checkout + uses: actions/checkout@v3 + + # Docs: https://github.com/shivammathur/setup-php + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install + + - name: PHP Lint + run: vendor/bin/phpcs + + - name: PHP test + run: vendor/bin/phpunit --testdox From eac147c7c3533bdad15cf8a22845db52231da949 Mon Sep 17 00:00:00 2001 From: Mohan Raj Date: Sat, 25 Mar 2023 16:40:07 +0000 Subject: [PATCH 6/7] fix phpcs warnings --- plugin.php | 17 +++++++++-------- tests/bootstrap.php | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/plugin.php b/plugin.php index 8f7beb4..2a9b41a 100644 --- a/plugin.php +++ b/plugin.php @@ -19,6 +19,7 @@ declare( strict_types = 1 ); namespace MR\FeatureFlags; + use MR\FeatureFlags\Api\Flags; // If this file is called directly, abort. @@ -52,8 +53,8 @@ function(): void { $feature_flag_meta = get_option( FeatureFlags::$option_name ); - $flags_list = []; - if(is_array($feature_flag_meta)) { + $flags_list = []; + if ( is_array( $feature_flag_meta ) ) { $flags_list = $feature_flag_meta; } @@ -108,7 +109,7 @@ function load_settings_scripts(): void { add_action( 'admin_enqueue_scripts', - function(string $page): void { + function( string $page ): void { $plugin_url = plugin_dir_url( MR_FEATURE_FLAGS_PLUGIN_PATH ); $script_asset_file = include_once plugin_dir_path( MR_FEATURE_FLAGS_PLUGIN_PATH ) . 'build/index.asset.php'; @@ -121,8 +122,8 @@ function(string $page): void { ); $feature_flag_meta = get_option( Utils::$option_name ); - $flags_list = []; - if(is_array($feature_flag_meta)) { + $flags_list = []; + if ( is_array( $feature_flag_meta ) ) { $flags_list = $feature_flag_meta; } @@ -146,9 +147,9 @@ function(string $page): void { -add_filter( 'plugin_action_links_mr-feature-flags/plugin.php', function ( $links ) - { - +add_filter( + 'plugin_action_links_mr-feature-flags/plugin.php', + function ( $links ) { $url = esc_url( add_query_arg( 'page', diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a04dd1b..4dd974b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,10 @@ Date: Sat, 25 Mar 2023 16:42:24 +0000 Subject: [PATCH 7/7] Removes old PHP action --- .github/workflows/php.yml | 42 ++++++++++++++++++++++++++++---------- .github/workflows/php1.yml | 40 ------------------------------------ 2 files changed, 31 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/php1.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 32cbe27..49e09e7 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,20 +1,40 @@ name: PHP - on: [push] - jobs: - build-test: + lint-test: + name: ${{ matrix.php-versions }} Lint & Test runs-on: ubuntu-latest - + strategy: + fail-fast: false + matrix: + php-versions: ['8.1'] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - - uses: php-actions/composer@v6 + # Docs: https://github.com/shivammathur/setup-php + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} - - name: PHPUnit Tests - uses: php-actions/phpunit@master + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 with: - bootstrap: vendor/autoload.php - configuration: phpunit.xml - args: --testdox + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install + + - name: PHP Lint + run: vendor/bin/phpcs + + - name: PHP test + run: vendor/bin/phpunit --testdox diff --git a/.github/workflows/php1.yml b/.github/workflows/php1.yml deleted file mode 100644 index d66f74f..0000000 --- a/.github/workflows/php1.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: PHP Lint & Test -on: [push] -jobs: - lint-test: - name: PHP ${{ matrix.php-versions }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-versions: ['8.1'] - steps: - - name: Checkout - uses: actions/checkout@v3 - - # Docs: https://github.com/shivammathur/setup-php - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - # Use composer.json for key, if composer.lock is not committed. - # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install Composer dependencies - run: composer install - - - name: PHP Lint - run: vendor/bin/phpcs - - - name: PHP test - run: vendor/bin/phpunit --testdox