-
Notifications
You must be signed in to change notification settings - Fork 101
66 lines (53 loc) · 2.04 KB
/
Copy pathphpcs.yml
File metadata and controls
66 lines (53 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: PHPCS
# cspell:ignore shivammathur
#
# Runs PHP_CodeSniffer against only the lines changed by the branch, so a PR is
# held to the coding standard for what it touches without failing on pre-existing
# violations elsewhere. Every remaining issue is printed in full to the job log
# (no ReviewDog-style truncation), which keeps larger reports reviewable in CI.
on:
workflow_dispatch:
pull_request:
paths:
- '**.php'
jobs:
phpcs:
name: Run PHPCS on changed lines
runs-on: ubuntu-latest
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GH_BOT_TOKEN }}"}}'
steps:
- uses: actions/checkout@v6
- name: Configure PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, intl
coverage: none
- uses: ramsey/composer-install@v3
- name: Run PHPCS on changed lines
env:
GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
# On a pull_request the base is the PR's target branch; fall back to
# master for a manual workflow_dispatch run.
BASE_REF="${GITHUB_BASE_REF:-master}"
git remote set-branches origin "$BASE_REF"
if ! git fetch origin --depth=1; then
# A re-run can replay a stale event payload: if the PR's base
# branch was renamed after this run was first queued,
# GITHUB_BASE_REF still names the old, now-deleted branch. Ask
# the API for the PR's current base and retry once before
# giving up.
if [ -z "$PR_NUMBER" ]; then
exit 1
fi
BASE_REF="$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json baseRefName --jq .baseRefName)"
if [ -z "$BASE_REF" ]; then
exit 1
fi
git remote set-branches origin "$BASE_REF"
git fetch origin --depth=1
fi
composer phpcs-ci "origin/$BASE_REF"