-
Notifications
You must be signed in to change notification settings - Fork 3
73 lines (65 loc) · 2.48 KB
/
Copy pathcode-quality.yml
File metadata and controls
73 lines (65 loc) · 2.48 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
67
68
69
70
71
72
73
# This does the following:
# 1. Detects modified plugins that have phpcs.xml configuration
# 2. Runs PHP Code Quality checks on those plugins using the custom action
# 3. Creates a matrix job for each plugin that has a quality configuration
# Bonus: This means you can have plugin specific badges e.g.
# [](https://github.com/wpengine/hwptoolkit/actions)
name: Code Quality
on:
push:
branches:
- main
paths:
- 'plugins/**.php'
pull_request:
paths:
- 'plugins/**.php'
jobs:
detect-plugins:
runs-on: ubuntu-latest
name: Detect plugins has php code quality configuration
outputs:
plugins: ${{ steps.detect.outputs.plugins }}
has-plugins: ${{ steps.detect.outputs.has-plugins }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed plugin directory
id: plugin
run: |
bash .github/scripts/get-plugin-slug.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
- name: Detect changed plugins with quality config
id: detect
run: |
if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
echo "No plugin slug detected"
echo "plugins=[]" >> $GITHUB_OUTPUT
echo "has-plugins=false" >> $GITHUB_OUTPUT
exit 0
fi
PLUGIN="${{ steps.plugin.outputs.slug }}"
if [ -f "plugins/$PLUGIN/phpcs.xml" ]; then
echo "plugins=[\"$PLUGIN\"]" >> $GITHUB_OUTPUT
echo "has-plugins=true" >> $GITHUB_OUTPUT
echo "✅ Found phpcs.xml for plugin: $PLUGIN"
else
echo "plugins=[]" >> $GITHUB_OUTPUT
echo "has-plugins=false" >> $GITHUB_OUTPUT
echo "ℹ️ No phpcs.xml found for plugin: $PLUGIN, skipping quality checks"
fi
quality-checks:
needs: detect-plugins
if: needs.detect-plugins.outputs.has-plugins == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }}
fail-fast: false
name: ${{ matrix.plugin }} php code quality checks
steps:
- name: Checkout
uses: actions/checkout@v4
- name: PHP Code Quality for ${{ matrix.plugin }}
uses: ./.github/actions/code-quality
with:
working-directory: plugins/${{ matrix.plugin }}