Skip to content

Commit 36fdf0c

Browse files
authored
Merge pull request #239 from wp-graphql/feature/github-actions
Adds Two New Workflows
2 parents 0603f83 + bd4f35e commit 36fdf0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+284
-243
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Testing Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- master
8+
pull_request:
9+
branches:
10+
- develop
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
env:
16+
coverage: 0
17+
debug: 0
18+
strategy:
19+
matrix:
20+
php: ['7.3', '7.2', '7.1', '7.0']
21+
wordpress: ['5.3', '5.0', '4.9']
22+
include:
23+
- php: '7.0'
24+
use_xdebug: 1
25+
- php: '7.0'
26+
wordpress: '5.0'
27+
coverage: 1
28+
29+
exclude:
30+
- php: '7.3'
31+
wordpress: '4.9'
32+
- php: '7.2'
33+
wordpress: '4.9'
34+
- php: '7.0'
35+
wordpress: '5.3'
36+
fail-fast: false
37+
name: WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v1
41+
42+
- name: Build "testing" Docker Image
43+
run: |
44+
docker-compose build \
45+
--build-arg PHP_VERSION=${{ matrix.php }} \
46+
--build-arg WP_VERSION=${{ matrix.wordpress }} \
47+
--build-arg USE_XDEBUG=${{ matrix.use_xdebug }} \
48+
testing
49+
50+
- name: Run Tests w/ Docker.
51+
run: |
52+
docker-compose run --rm \
53+
-e COVERAGE=${{ matrix.coverage }} \
54+
-e DEBUG=${{ matrix.debug }} \
55+
testing --scale app=0
56+
57+
- name: Push Codecoverage to Coveralls.io
58+
if: matrix.coverage == 1
59+
env:
60+
COVERALLS_RUN_LOCALLY: 1
61+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
62+
run: |
63+
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar
64+
chmod +x php-coveralls.phar
65+
66+
php php-coveralls.phar -v
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: WordPress Coding Standards
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- master
8+
pull_request:
9+
branches:
10+
- develop
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v1
18+
19+
- name: Setup PHP
20+
if: matrix.phpcs == 1
21+
uses: shivammathur/setup-php@v1
22+
with:
23+
php-version: 7.3
24+
extensions: mbstring, intl
25+
tools: composer
26+
27+
- name: Get Composer Cache Directory
28+
id: composer-cache
29+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
30+
31+
- name: Install dependencies
32+
run: |
33+
composer require \
34+
squizlabs/php_codesniffer \
35+
phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs \
36+
dealerdirect/phpcodesniffer-composer-installer
37+
composer install --no-dev
38+
39+
- name: Cache dependencies
40+
uses: actions/cache@v1
41+
with:
42+
path: ${{ steps.composer-cache.outputs.dir }}
43+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
44+
restore-keys: ${{ runner.os }}-composer
45+
46+
- name: Run PHP CodeSniffer
47+
run: vendor/bin/phpcs

.phpcs.ruleset.xml renamed to .phpcs.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<description>Generally-applicable sniffs for WordPress plugins.</description>
44

55
<!-- What to scan -->
6-
<file>.</file>
6+
<file>wp-graphql-woocommerce.php</file>
7+
<file>access-functions.php</file>
8+
<file>class-inflect.php</file>
9+
<file>includes/</file>
710
<exclude-pattern>/vendor/</exclude-pattern>
811
<exclude-pattern>/node_modules/</exclude-pattern>
912
<exclude-pattern>/tests/</exclude-pattern>
@@ -19,21 +22,18 @@
1922

2023
<!-- Rules: Check PHP version compatibility -->
2124
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
22-
<config name="testVersion" value="5.3-"/>
25+
<config name="testVersion" value="5.6-"/>
2326
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
2427
<rule ref="PHPCompatibilityWP"/>
2528

2629
<!-- Rules: WordPress Coding Standards -->
2730
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
2831
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
29-
<config name="minimum_supported_wp_version" value="4.6"/>
30-
<rule ref="WordPress">
31-
<exclude name="WordPress.VIP"/>
32-
</rule>
32+
<config name="minimum_supported_wp_version" value="4.9"/>
3333
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
3434
<properties>
3535
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
36-
<property name="prefixes" type="array" value="WPGraphQL\WooCommerce"/>
36+
<property name="prefixes" type="array" value="WPGraphQL\WooCommerce,woographql,WPGRAPHQL_WOOCOMMERCE,WP_GraphQL_WooCommerce,graphql_,wc_graphql_"/>
3737
</properties>
3838
</rule>
3939
<rule ref="WordPress.WP.I18n">

.travis.yml

Lines changed: 0 additions & 115 deletions
This file was deleted.

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
############################################################################
44

55
# Using the 'DESIRED_' prefix to avoid confusion with environment variables of the same name.
6-
ARG DESIRED_WP_VERSION
7-
ARG DESIRED_PHP_VERSION
6+
ARG WP_VERSION
7+
ARG PHP_VERSION
88

9-
FROM kidunot89/woographql-app:wp${DESIRED_WP_VERSION}-php${DESIRED_PHP_VERSION}
9+
FROM kidunot89/woographql-app:wp${WP_VERSION}-php${PHP_VERSION}
1010

1111

1212
LABEL author=kidunot89
@@ -15,11 +15,11 @@ LABEL author_uri=https://github.com/kidunot89
1515
SHELL [ "/bin/bash", "-c" ]
1616

1717
# Redeclare ARGs and set as environmental variables for reuse.
18-
ARG DESIRED_WP_VERSION
19-
ARG DESIRED_PHP_VERSION
18+
ARG WP_VERSION
19+
ARG PHP_VERSION
2020
ARG USE_XDEBUG
21-
ENV WP_VERSION=${DESIRED_WP_VERSION}
22-
ENV PHP_VERSION=${DESIRED_PHP_VERSION}
21+
ENV WP_VERSION=${WP_VERSION}
22+
ENV PHP_VERSION=${PHP_VERSION}
2323
ENV USING_XDEBUG=${USE_XDEBUG}
2424

2525
# Install php extensions
@@ -37,7 +37,7 @@ RUN if [ "$PHP_VERSION" != "5.6" ] && [ "$PHP_VERSION" != "7.0" ] && [[ -z "$USI
3737
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
3838
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
3939
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini; \
40-
elif [ "$PHP_VERSION" == "7.0" ]; then \
40+
elif [ "$PHP_VERSION" == "7.0" ] || [ ! -z "$USING_XDEBUG" ]; then \
4141
yes | pecl install xdebug-2.6.1 \
4242
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
4343
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<a href="https://woographql.axistaylor.com/" target="_blank">Docs</a> • <a href="https://www.axistaylor.com" target="_blank">AxisTaylor</a> • <a href="https://wpgql-slack.herokuapp.com/" target="_blank">Join Slack</a>
66

7-
[![Build Status](https://travis-ci.org/wp-graphql/wp-graphql-woocommerce.svg?branch=develop)](https://travis-ci.org/wp-graphql/wp-graphql-woocommerce) [![Coverage Status](https://coveralls.io/repos/github/wp-graphql/wp-graphql-woocommerce/badge.svg?branch=develop)](https://coveralls.io/github/wp-graphql/wp-graphql-woocommerce?branch=develop)
7+
[![Actions Status](https://github.com/wp-graphql/wp-graphql-woocommerce/workflows/Testing Integration/badge.svg)](https://github.com/wp-graphql/wp-graphql-woocommerce/actions)[![Coverage Status](https://coveralls.io/repos/github/wp-graphql/wp-graphql-woocommerce/badge.svg?branch=develop)](https://coveralls.io/github/wp-graphql/wp-graphql-woocommerce?branch=develop)
88

99
## Quick Install
1010
1. Install & activate [WooCommerce](https://woocommerce.com/)

access-functions.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function wc_graphql_get_order_statuses() {
9494
*/
9595
function wc_graphql_price( $price, $args = array() ) {
9696
$args = apply_filters(
97-
'wc_price_args',
97+
'wc_price_args', // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
9898
wp_parse_args(
9999
$args,
100100
array(
@@ -109,13 +109,32 @@ function wc_graphql_price( $price, $args = array() ) {
109109

110110
$unformatted_price = $price;
111111
$negative = $price < 0;
112-
$price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
113-
$price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] ), $price, $args['decimals'], $args['decimal_separator'], $args['thousand_separator'] );
114112

113+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
114+
$price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
115+
116+
117+
$price = apply_filters(
118+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
119+
'formatted_woocommerce_price',
120+
number_format(
121+
$price,
122+
$args['decimals'],
123+
$args['decimal_separator'],
124+
$args['thousand_separator']
125+
),
126+
$price,
127+
$args['decimals'],
128+
$args['decimal_separator'],
129+
$args['thousand_separator']
130+
);
131+
132+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
115133
if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $args['decimals'] > 0 ) {
116134
$price = wc_trim_zeros( $price );
117135
}
118136

137+
// phpcs:ignore PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault.NotSet
119138
$symbol = html_entity_decode( get_woocommerce_currency_symbol( $args['currency'] ) );
120139
$return = ( $negative ? '-' : '' ) . sprintf( $args['price_format'], $symbol, $price );
121140

@@ -127,7 +146,7 @@ function wc_graphql_price( $price, $args = array() ) {
127146
* @param array $args Pass on the args.
128147
* @param float $unformatted_price Price as float to allow plugins custom formatting. Since 3.2.0.
129148
*/
130-
return apply_filters( 'wc_graphql_price', $return, $price, $args, $unformatted_price, $symbol );
149+
return apply_filters( 'graphql_woocommerce_price', $return, $price, $args, $unformatted_price, $symbol );
131150
}
132151

133152
/**
@@ -142,9 +161,9 @@ function wc_graphql_price_range( $from, $to ) {
142161
/* translators: 1: price from 2: price to */
143162
_x( '%1$s %2$s %3$s', 'Price range: from-to', 'wp-graphql-woocommerce' ),
144163
is_numeric( $from ) ? wc_graphql_price( $from ) : $from,
145-
apply_filters( 'graphql_format_price_range_separator', '-', $from, $to ),
164+
apply_filters( 'graphql_woocommerce_format_price_range_separator', '-', $from, $to ),
146165
is_numeric( $to ) ? wc_graphql_price( $to ) : $to
147166
);
148167

149-
return apply_filters( 'graphql_format_price_range', $price, $from, $to );
168+
return apply_filters( 'graphql_woocommerce_format_price_range', $price, $from, $to );
150169
}

class-inflect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/**
1616
* Class Inflect
1717
*/
18-
class Inflect {
18+
class Inflect { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
1919
/**
2020
* Stores plural suffixes.
2121
*

0 commit comments

Comments
 (0)