Skip to content

Commit 09b900a

Browse files
committed
PHP Code quality refactor to use plugin slug script
1 parent fc793d4 commit 09b900a

File tree

2 files changed

+12
-34
lines changed

2 files changed

+12
-34
lines changed

.github/workflows/code-quality.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,31 @@ jobs:
2828
- name: Checkout
2929
uses: actions/checkout@v4
3030

31+
- name: Get changed plugin directory
32+
id: plugin
33+
run: |
34+
bash .github/scripts/get-plugin-slug.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
35+
3136
- name: Detect changed plugins with quality config
3237
id: detect
3338
run: |
34-
git fetch --prune --unshallow
35-
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' || true)
36-
37-
if [ -z "$CHANGED_FILES" ]; then
38-
echo "No plugin files changed"
39+
if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
40+
echo "No plugin slug detected"
3941
echo "plugins=[]" >> $GITHUB_OUTPUT
4042
echo "has-plugins=false" >> $GITHUB_OUTPUT
4143
exit 0
4244
fi
4345
44-
# Extract unique plugin names and check for phpcs.xml
45-
PLUGINS_WITH_CONFIG=()
46-
CHECKED_PLUGINS=()
47-
48-
for file in $CHANGED_FILES; do
49-
plugin=$(echo $file | cut -d/ -f2)
50-
51-
# Skip if we already checked this plugin
52-
if [[ " ${CHECKED_PLUGINS[@]} " =~ " $plugin " ]]; then
53-
continue
54-
fi
55-
56-
CHECKED_PLUGINS+=("$plugin")
57-
58-
if [ -f "plugins/$plugin/phpcs.xml" ]; then
59-
PLUGINS_WITH_CONFIG+=("$plugin")
60-
echo "✅ Found phpcs.xml for plugin: $plugin"
61-
else
62-
echo "ℹ️ No phpcs.xml found for plugin: $plugin, skipping quality checks"
63-
fi
64-
done
46+
PLUGIN="${{ steps.plugin.outputs.slug }}"
6547
66-
# Convert to JSON array
67-
if [ ${#PLUGINS_WITH_CONFIG[@]} -gt 0 ]; then
68-
PLUGINS_JSON=$(printf '%s\n' "${PLUGINS_WITH_CONFIG[@]}" | jq -R -s -c 'split("\n")[:-1]')
69-
echo "plugins=${PLUGINS_JSON}" >> $GITHUB_OUTPUT
48+
if [ -f "plugins/$PLUGIN/phpcs.xml" ]; then
49+
echo "plugins=[\"$PLUGIN\"]" >> $GITHUB_OUTPUT
7050
echo "has-plugins=true" >> $GITHUB_OUTPUT
71-
echo "Found ${#PLUGINS_WITH_CONFIG[@]} plugin(s) with quality config: ${PLUGINS_WITH_CONFIG[*]}"
51+
echo "Found phpcs.xml for plugin: $PLUGIN"
7252
else
7353
echo "plugins=[]" >> $GITHUB_OUTPUT
7454
echo "has-plugins=false" >> $GITHUB_OUTPUT
75-
echo "No plugins found with quality configuration"
55+
echo "ℹ️ No phpcs.xml found for plugin: $PLUGIN, skipping quality checks"
7656
fi
7757
quality-checks:
7858
needs: detect-plugins

plugins/hwp-previews/src/Plugin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*
1414
* This class serves as the main entry point for the plugin, handling initialization, action and filter hooks.
1515
*
16-
* @link https://github.com/wpengine/hwptoolkit/tree/main/plugins/hwp-previews
17-
*
1816
* @package HWP\Previews
1917
*/
2018
final class Plugin {

0 commit comments

Comments
 (0)