From 4b0fcec2b7caeab4b275cbd82e96bab58a10f8cb Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Thu, 30 Jun 2022 12:08:45 -0300 Subject: [PATCH 1/4] Run PHPCS in CI --- .github/workflows/phpcs.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/phpcs.yml diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..2146b72 --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,33 @@ +name: PHPCS check +on: + push + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + phpcs: + name: PHPCS check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + 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" + + - name: Run PHPCS checks + continue-on-error: true + run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml + + - name: Show PHPCS results in PR + run: cs2pr ./phpcs-report.xml From 221e10a56f7e8aa494c009cf693ca5c6d2177551 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Thu, 30 Jun 2022 12:09:43 -0300 Subject: [PATCH 2/4] Add badge to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cd3af39..9ad9ebb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![PHPCS](https://github.com/woocommerce/wc-smooth-generator/actions/workflows/phpcs.yml/badge.svg)](https://github.com/woocommerce/wc-smooth-generator/actions/workflows/phpcs.yml) + # WooCommerce Smooth Generator A smooth products, customer and order generator using WP-CLI. Future versions will include scheduled auto generation functionality. From 05d6b0b79018ec5ebe36258da0df2a17a3c1d677 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Thu, 30 Jun 2022 12:17:55 -0300 Subject: [PATCH 3/4] Make PHPCS pass in CI / Ignore unnecessary checks --- includes/Admin/Settings.php | 4 ++-- includes/Generator/Product.php | 4 ++-- phpcs.xml.dist | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index 5e356f2..119f1dc 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -70,12 +70,12 @@ public static function process_page_submit() { $num_to_generate = absint( $_POST['num_products_to_generate'] ); wc_smooth_generate_schedule( 'product', $num_to_generate ); add_action( 'admin_notices', array( __CLASS__, 'product_generating_notice' ) ); - } else if ( ! empty( $_POST['generate_orders'] ) && ! empty( $_POST['num_orders_to_generate'] ) ) { + } elseif ( ! empty( $_POST['generate_orders'] ) && ! empty( $_POST['num_orders_to_generate'] ) ) { check_admin_referer( 'generate', 'smoothgenerator_nonce' ); $num_to_generate = absint( $_POST['num_orders_to_generate'] ); wc_smooth_generate_schedule( 'order', $num_to_generate ); add_action( 'admin_notices', array( __CLASS__, 'order_generating_notice' ) ); - } else if ( ! empty( $_POST['cancel_all_generations'] ) ) { + } elseif ( ! empty( $_POST['cancel_all_generations'] ) ) { check_admin_referer( 'generate', 'smoothgenerator_nonce' ); wc_smooth_generate_cancel_all(); } diff --git a/includes/Generator/Product.php b/includes/Generator/Product.php index 49e7538..d4e49d9 100644 --- a/includes/Generator/Product.php +++ b/includes/Generator/Product.php @@ -126,8 +126,8 @@ protected static function create_global_attribute( $raw_name ) { $taxonomy_name = wc_attribute_taxonomy_name( $slug ); register_taxonomy( $taxonomy_name, - apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ), - apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array( + apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ), // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment + apply_filters( 'woocommerce_taxonomy_args_' . $taxonomy_name, array( // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment 'labels' => array( 'name' => $raw_name, ), diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 32309e0..0876dab 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -10,6 +10,7 @@ */vendor/* */node_modules/* + Gruntfile\.js From 33b1a0251150e23ae9c98aa09e42118dc94c74f7 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Thu, 30 Jun 2022 12:24:22 -0300 Subject: [PATCH 4/4] Changelog --- changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.txt b/changelog.txt index fc6956e..63875a4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** Changelog *** +2022-06-30 - version 1.0.5 +* Dev - Run PHPCS checks in CI. + 2021-12-15 - version 1.0.4 * Add - coupon generator and a new option for orders to allow for coupon generation. * Add - use product name to generate more realistic product term names.