|
| 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 |
0 commit comments