1+ # This does the following:
2+ # 1. Detects modified plugins that have codeception.dist.yml configuration setup
3+ # 2. Runs Codeception tests on those plugins using the custom action
4+ # 3. Creates a matrix job for each plugin that has a quality configuration
5+ # Bonus: This means you can have plugin specific badges e.g.
6+ # [](https://github.com/wpengine/hwptoolkit/actions)
7+
18name : Testing Integration
29
310on :
@@ -18,12 +25,85 @@ concurrency:
1825 cancel-in-progress : true
1926
2027jobs :
28+ detect-plugins :
29+ runs-on : ubuntu-latest
30+ name : Detect plugins with test config
31+ outputs :
32+ plugins : ${{ steps.detect.outputs.plugins }}
33+ has-plugins : ${{ steps.detect.outputs.has-plugins }}
34+ steps :
35+ - name : Checkout
36+ uses : actions/checkout@v4
37+
38+ - name : Detect changed plugins with test config
39+ id : detect
40+ run : |
41+ git fetch --prune --unshallow
42+
43+ # Get changed files based on event type
44+ if [ "${{ github.event_name }}" = "pull_request" ]; then
45+ CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' || true)
46+ else
47+ CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD | grep '^plugins/' || true)
48+ fi
49+
50+ if [ -z "$CHANGED_FILES" ]; then
51+ echo "No plugin files changed"
52+ echo "plugins=[]" >> $GITHUB_OUTPUT
53+ echo "has-plugins=false" >> $GITHUB_OUTPUT
54+ exit 0
55+ fi
56+
57+ # Extract unique plugin names and check for test config
58+ PLUGINS_WITH_CONFIG=()
59+ CHECKED_PLUGINS=()
60+
61+ for file in $CHANGED_FILES; do
62+ plugin=$(echo $file | cut -d/ -f2)
63+
64+ # Skip if we already checked this plugin
65+ if [[ " ${CHECKED_PLUGINS[@]} " =~ " $plugin " ]]; then
66+ continue
67+ fi
68+
69+ CHECKED_PLUGINS+=("$plugin")
70+
71+ # Check for both codeception.dist.yml and composer.json
72+ if [ -f "plugins/$plugin/codeception.dist.yml" ] && [ -f "plugins/$plugin/composer.json" ]; then
73+ PLUGINS_WITH_CONFIG+=("$plugin")
74+ echo "✅ Found test config for plugin: $plugin (codeception.dist.yml + composer.json)"
75+ else
76+ echo "ℹ️ Missing test config for plugin: $plugin, skipping tests"
77+ if [ ! -f "plugins/$plugin/codeception.dist.yml" ]; then
78+ echo " - Missing: codeception.dist.yml"
79+ fi
80+ if [ ! -f "plugins/$plugin/composer.json" ]; then
81+ echo " - Missing: composer.json"
82+ fi
83+ fi
84+ done
85+
86+ # Convert to JSON array
87+ if [ ${#PLUGINS_WITH_CONFIG[@]} -gt 0 ]; then
88+ PLUGINS_JSON=$(printf '%s\n' "${PLUGINS_WITH_CONFIG[@]}" | jq -R -s -c 'split("\n")[:-1]')
89+ echo "plugins=${PLUGINS_JSON}" >> $GITHUB_OUTPUT
90+ echo "has-plugins=true" >> $GITHUB_OUTPUT
91+ echo "Found ${#PLUGINS_WITH_CONFIG[@]} plugin(s) with test config: ${PLUGINS_WITH_CONFIG[*]}"
92+ else
93+ echo "plugins=[]" >> $GITHUB_OUTPUT
94+ echo "has-plugins=false" >> $GITHUB_OUTPUT
95+ echo "No plugins found with test configuration"
96+ fi
97+
2198 continuous_integration :
99+ needs : detect-plugins
100+ if : needs.detect-plugins.outputs.has-plugins == 'true'
22101 runs-on : ubuntu-latest
23- name : WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
102+ name : ${{ matrix.plugin }} integration tests (WP ${{ matrix.wordpress }}, PHP ${{ matrix.php }})
24103
25104 strategy :
26105 matrix :
106+ plugin : ${{ fromJson(needs.detect-plugins.outputs.plugins) }}
27107 php : ["8.3","8.2","8.1"]
28108 wordpress : ["6.8","6.7","6.6","6.5"]
29109 include :
@@ -35,32 +115,10 @@ jobs:
35115 steps :
36116 - name : Checkout
37117 uses : actions/checkout@v4
38-
39- - name : Get changed plugin directory
40- id : plugin
41- run : |
42- git fetch --prune --unshallow
43- plugin=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '^plugins/' | head -1 | cut -d/ -f2)
44- echo "slug=$plugin" >> $GITHUB_OUTPUT
45-
46- - name : Validate codeception.dist.yml
47- run : |
48- if [ ! -f "plugins/${{ steps.plugin.outputs.slug }}/codeception.dist.yml" ]; then
49- echo "Exiting as no codeception file found for this plugin - /${{ steps.plugin.outputs.slug }}"
50- exit 1
51- fi
52-
53- - name : Validate composer.json
54- run : |
55- if [ ! -f "plugins/${{ steps.plugin.outputs.slug }}/composer.json" ]; then
56- echo "Exiting as no composer file found for this plugin - ${{ steps.plugin.outputs.slug }}"
57- exit 1
58- fi
59-
60- - name : Run Codeception Tests
118+ - name : ${{ matrix.plugin }} codeception tests
61119 uses : ./.github/actions/codeception
62120 with :
63- working-directory : plugins/${{ steps .plugin.outputs.slug }}
121+ working-directory : plugins/${{ matrix .plugin }}
64122 php : ${{ matrix.php }}
65123 wordpress : ${{ matrix.wordpress }}
66124 extensions : json,mbstring
0 commit comments