Skip to content

Commit a9c6bff

Browse files
git action
1 parent a5fdb63 commit a9c6bff

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

.github/workflows/main.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: PHPCS & PHPCBF
2+
3+
on:
4+
push:
5+
branches: [orgV1.1.9]
6+
pull_request:
7+
branches: [orgV1.1.9]
8+
9+
jobs:
10+
phpcs:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Install PHP
17+
run: sudo apt-get update && sudo apt-get install -y php-cli php-zip unzip curl
18+
19+
- name: Install Composer
20+
run: curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
21+
22+
- name: Install PHPCS + Standards
23+
run: |
24+
composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
25+
composer global require \
26+
squizlabs/php_codesniffer \
27+
wp-coding-standards/wpcs \
28+
woocommerce/woocommerce-sniffs \
29+
phpcompatibility/php-compatibility \
30+
phpcompatibility/phpcompatibility-wp \
31+
phpcompatibility/phpcompatibility-paragonie \
32+
phpcsstandards/phpcsutils \
33+
phpcsstandards/phpcsextra
34+
35+
- name: Add Composer global bin to PATH
36+
run: echo "$HOME/.composer/vendor/bin" >> $GITHUB_PATH
37+
38+
- name: Verify PHPCS installation
39+
run: phpcs -i
40+
41+
- name: Run PHPCS
42+
run: |
43+
phpcs --standard=phpcs.xml \
44+
--report=full \
45+
--report-file=phpcs-report.txt \
46+
--report=checkstyle \
47+
--report-file=phpcs-report.xml \
48+
--warning-severity=0 \
49+
--extensions=php,html .
50+
continue-on-error: true
51+
52+
- name: Run PHPCBF (Auto-fix)
53+
run: |
54+
phpcbf --standard=phpcs.xml \
55+
--report=full \
56+
--report-file=phpcbf-report.txt \
57+
--warning-severity=0 \
58+
--extensions=php,html .
59+
continue-on-error: true
60+
61+
- name: Install WP-CLI
62+
run: |
63+
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
64+
chmod +x wp-cli.phar
65+
sudo mv wp-cli.phar /usr/local/bin/wp
66+
67+
- name: Generate POT file
68+
run: |
69+
wp i18n make-pot . languages/track-orders-for-woocommerce.pot \
70+
--exclude=node_modules,vendor,tests,public/js,admin/js,packages,build,dist
71+
72+
- name: Install gettext
73+
run: sudo apt-get update && sudo apt-get install -y gettext
74+
75+
- name: Compile .mo files from .po (if any exist)
76+
run: |
77+
if ls languages/*.po 1> /dev/null 2>&1; then
78+
for file in languages/*.po; do
79+
msgfmt "$file" -o "${file%.po}.mo"
80+
done
81+
fi
82+
83+
- name: Generate default PO file (en_US)
84+
run: |
85+
if [ ! -f languages/en_US.po ]; then
86+
cp languages/track-orders-for-woocommerce.pot languages/track-orders-for-woocommerce-en_US.po
87+
fi
88+
89+
- name: Upload PHPCS Reports
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: reports-and-languages
93+
path: |
94+
phpcs-report.txt
95+
phpcs-report.xml
96+
phpcbf-report.txt
97+
languages/*.pot
98+
languages/*.mo

phpcs.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="WordPress Coding Standards">
3+
<description>WooCommerce extension PHP_CodeSniffer ruleset.</description>
4+
5+
<!-- Exclude folders -->
6+
<exclude-pattern>tests/</exclude-pattern>
7+
<exclude-pattern>woo-includes/woo-functions.php</exclude-pattern>
8+
<exclude-pattern>woo-includes/class-wc-dependencies.php</exclude-pattern>
9+
<exclude-pattern>*/node_modules/*</exclude-pattern>
10+
<exclude-pattern>*/vendor/*</exclude-pattern>
11+
12+
<!-- WordPress settings -->
13+
<config name="minimum_supported_wp_version" value="4.7" />
14+
<config name="testVersion" value="5.6-" />
15+
16+
<!-- WordPress Coding Standards -->
17+
<rule ref="WordPress-Extra">
18+
<exclude name="Generic.Commenting.DocComment.SpacingAfter" />
19+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar" />
20+
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma" />
21+
<exclude name="PEAR.Functions.FunctionCallSignature" />
22+
<exclude name="Squiz.Commenting" />
23+
<exclude name="Squiz.PHP.DisallowSizeFunctionsInLoops.Found" />
24+
<exclude name="Squiz.WhiteSpace" />
25+
<!-- These old sniffs don’t exist anymore in WPCS v3+ -->
26+
<exclude name="WordPress.Arrays" />
27+
<exclude name="WordPress.Files.FileName" />
28+
<exclude name="WordPress.NamingConventions" />
29+
<exclude name="WordPress.Security.ValidatedSanitizedInput.MissingUnslash" />
30+
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralText" />
31+
<exclude name="WordPress.WhiteSpace" />
32+
</rule>
33+
34+
<!-- WooCommerce Standard (correct name is just WooCommerce) -->
35+
<rule ref="WooCommerce">
36+
<exclude name="Core.Commenting.CommentTags.AuthorTag" />
37+
<exclude name="WordPress.PHP.DontExtract" />
38+
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
39+
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
40+
</rule>
41+
42+
<!-- PHPCompatibility -->
43+
<rule ref="PHPCompatibility">
44+
<exclude-pattern>tests/</exclude-pattern>
45+
</rule>
46+
47+
<!-- PHPCSExtra (Universal, Modernize, NormalizedArrays) -->
48+
<rule ref="Universal"/>
49+
<rule ref="Modernize"/>
50+
<rule ref="NormalizedArrays"/>
51+
52+
<!-- Scan PHP + HTML -->
53+
<arg name="extensions" value="php,html"/>
54+
</ruleset>

0 commit comments

Comments
 (0)