1+ # This does the following:
2+ # 1. Detects modified plugins that have .wp-env.json configuration
3+ # 2. Runs Playwright E2E 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+
8+
19name : End-to-End Tests
210
311on :
412 push :
513 branches :
614 - main
715 paths :
8- - ' plugins/hwp-previews/**.php'
9- - ' plugins/hwp-previews/**.js'
10- - ' plugins/hwp-previews/**.css'
11- - ' plugins/hwp-previews/**.json'
12-
16+ - ' plugins/**.php'
17+ - ' plugins/**.js'
18+ - ' plugins/**.css'
19+ - ' plugins/**.json'
1320 pull_request :
1421 branches :
1522 - main
1623 paths :
17- - " plugins/hwp-previews/ **"
24+ - " plugins/**"
1825
1926jobs :
27+ detect-plugin :
28+ runs-on : ubuntu-latest
29+ name : Detect plugin with E2E tests
30+ outputs :
31+ plugin : ${{ steps.detect.outputs.plugin }}
32+ has-plugin : ${{ steps.detect.outputs.has-plugin }}
33+ steps :
34+ - name : Checkout
35+ uses : actions/checkout@v4
36+
37+ - name : Get changed plugin directory
38+ id : plugin
39+ run : |
40+ bash .github/scripts/get-plugin-slug.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
41+
42+ - name : Detect changed plugin with E2E config
43+ id : detect
44+ run : |
45+ if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
46+ echo "No plugin slug detected"
47+ echo "plugin=" >> $GITHUB_OUTPUT
48+ echo "has-plugin=false" >> $GITHUB_OUTPUT
49+ exit 0
50+ fi
51+
52+ PLUGIN="${{ steps.plugin.outputs.slug }}"
53+
54+ # Check for .wp-env.json file in the plugin directory
55+ if [ -f "plugins/$PLUGIN/.wp-env.json" ]; then
56+ echo "plugin=$PLUGIN" >> $GITHUB_OUTPUT
57+ echo "has-plugin=true" >> $GITHUB_OUTPUT
58+ echo "✅ Found .wp-env.json for plugin: $PLUGIN"
59+ else
60+ echo "plugin=" >> $GITHUB_OUTPUT
61+ echo "has-plugin=false" >> $GITHUB_OUTPUT
62+ echo "ℹ️ No .wp-env.json found for plugin: $PLUGIN, skipping E2E tests"
63+ fi
64+
2065 playwright-e2e-tests :
66+ needs : detect-plugin
67+ if : needs.detect-plugin.outputs.has-plugin == 'true'
2168 runs-on : ubuntu-24.04
69+ name : ${{ needs.detect-plugin.outputs.plugin }} Playwright E2E Tests
70+ env :
71+ PLUGIN : ${{ needs.detect-plugin.outputs.plugin }}
2272
2373 steps :
2474 - name : Checkout code
@@ -37,22 +87,22 @@ jobs:
3787 uses : ./.github/actions/setup-php-composer
3888 with :
3989 php-version : 8.2
40- working-directory : plugins/hwp-previews
90+ working-directory : plugins/${{ env.PLUGIN }}
4191 composer-options : ' --no-progress --optimize-autoloader --no-dev'
4292
4393 - name : Install playwright browsers
4494 run : npx playwright install --with-deps
45- working-directory : plugins/hwp-previews
95+ working-directory : plugins/${{ env.PLUGIN }}
4696
4797 - name : Start wp-env
4898 run : |
4999 npm run wp-env start
50- working-directory : plugins/hwp-previews
100+ working-directory : plugins/${{ env.PLUGIN }}
51101
52102 - name : Run Playwright tests
53103 run : npm run test:e2e
54- working-directory : plugins/hwp-previews
104+ working-directory : plugins/${{ env.PLUGIN }}
55105
56106 - name : Stop wp-env
57107 run : npm run wp-env stop
58- working-directory : plugins/hwp-previews
108+ working-directory : plugins/${{ env.PLUGIN }}
0 commit comments