2021-02-09 10:39:56 +00:00
|
|
|
name: Run code sniff on PR
|
2023-01-12 01:09:36 +00:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
paths-ignore:
|
|
|
|
- '**/changelog/**'
|
2021-10-13 03:38:36 +00:00
|
|
|
defaults:
|
2022-10-31 18:53:01 +00:00
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
|
|
PHPCS: ./plugins/woocommerce/vendor/bin/phpcs # Run WooCommerce phpcs setup in phpcs-changed instead of default
|
2023-01-02 17:28:11 +00:00
|
|
|
|
|
|
|
permissions: {}
|
|
|
|
|
2021-02-09 10:39:56 +00:00
|
|
|
jobs:
|
2022-10-31 18:53:01 +00:00
|
|
|
test:
|
|
|
|
name: Code sniff (PHP 7.4, WP Latest)
|
|
|
|
timeout-minutes: 15
|
|
|
|
runs-on: ubuntu-20.04
|
2023-01-02 17:28:11 +00:00
|
|
|
permissions:
|
2023-01-12 01:09:36 +00:00
|
|
|
contents: read
|
2022-10-31 18:53:01 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2021-02-09 10:39:56 +00:00
|
|
|
|
2022-10-31 18:53:01 +00:00
|
|
|
- name: Get Changed Files
|
|
|
|
id: changed-files
|
|
|
|
uses: tj-actions/changed-files@v32
|
|
|
|
with:
|
|
|
|
files: |
|
|
|
|
**/*.php
|
2021-02-09 10:39:56 +00:00
|
|
|
|
2022-10-31 18:53:01 +00:00
|
|
|
- name: Setup WooCommerce Monorepo
|
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
uses: ./.github/actions/setup-woocommerce-monorepo
|
|
|
|
with:
|
|
|
|
build: false
|
2021-02-09 10:39:56 +00:00
|
|
|
|
2022-10-31 18:53:01 +00:00
|
|
|
- name: Tool versions
|
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
run: |
|
|
|
|
php --version
|
|
|
|
composer --version
|
|
|
|
phpcs-changed --version
|
|
|
|
|
|
|
|
- name: Run PHPCS
|
|
|
|
if: steps.changed-files.outputs.any_changed == 'true'
|
|
|
|
run: |
|
|
|
|
HEAD_REF=$(git rev-parse HEAD)
|
|
|
|
git checkout $HEAD_REF
|
2022-12-05 14:21:26 +00:00
|
|
|
phpcs-changed -s --git --git-base ${{ github.base_ref }} ${{ steps.changed-files.outputs.all_changed_files }}
|