55 branches :
66 - main
77 paths :
8- - ' plugins/hwp-previews/**.php'
9- - ' plugins/hwp-previews/**.js'
10- - ' plugins/hwp-previews/**.css'
11- - ' plugins/hwp-previews/**.json'
12-
8+ - ' plugins/**.php'
9+ - ' plugins/**.js'
10+ - ' plugins/**.css'
11+ - ' plugins/**.json'
1312 pull_request :
1413 branches :
1514 - main
1615 paths :
17- - " plugins/hwp-previews/ **"
16+ - " plugins/**"
1817
1918jobs :
19+ detect-plugins :
20+ runs-on : ubuntu-latest
21+ name : Detect plugins with E2E tests
22+ outputs :
23+ plugins : ${{ steps.detect.outputs.plugins }}
24+ has-plugins : ${{ steps.detect.outputs.has-plugins }}
25+ steps :
26+ - name : Checkout
27+ uses : actions/checkout@v4
28+
29+ - name : Get changed plugin directory
30+ id : plugin
31+ run : |
32+ bash .github/scripts/get-plugin-slug.sh ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
33+
34+ - name : Detect changed plugins with E2E config
35+ id : detect
36+ run : |
37+ if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
38+ echo "No plugin slug detected"
39+ echo "plugins=[]" >> $GITHUB_OUTPUT
40+ echo "has-plugins=false" >> $GITHUB_OUTPUT
41+ exit 0
42+ fi
43+
44+ PLUGIN="${{ steps.plugin.outputs.slug }}"
45+
46+ # Check for .wp-env.json file in the plugin directory
47+ if [ -f "plugins/$PLUGIN/.wp-env.json" ]; then
48+ echo "plugins=[\"$PLUGIN\"]" >> $GITHUB_OUTPUT
49+ echo "has-plugins=true" >> $GITHUB_OUTPUT
50+ echo "✅ Found .wp-env.json for plugin: $PLUGIN"
51+ else
52+ echo "plugins=[]" >> $GITHUB_OUTPUT
53+ echo "has-plugins=false" >> $GITHUB_OUTPUT
54+ echo "ℹ️ No .wp-env.json found for plugin: $PLUGIN, skipping E2E tests"
55+ fi
56+
2057 playwright-e2e-tests :
58+ needs : detect-plugins
59+ if : needs.detect-plugins.outputs.has-plugins == 'true'
2160 runs-on : ubuntu-24.04
22-
61+ strategy :
62+ matrix :
63+ plugin : ${{ fromJson(needs.detect-plugins.outputs.plugins) }}
64+ fail-fast : false
65+ name : ${{ matrix.plugin }} Playwright E2E Tests
2366 steps :
2467 - name : Checkout code
2568 uses : actions/checkout@v4
@@ -32,27 +75,27 @@ jobs:
3275
3376 - name : Install dependencies
3477 run : npm ci
78+ working-directory : plugins/${{ matrix.plugin }}
3579
3680 - name : Setup PHP with Cached Composer
3781 uses : ./.github/actions/setup-php-composer
3882 with :
3983 php-version : 8.2
40- working-directory : plugins/hwp-previews
84+ working-directory : plugins/${{ matrix.plugin }}
4185 composer-options : ' --no-progress --optimize-autoloader --no-dev'
4286
4387 - name : Install playwright browsers
4488 run : npx playwright install --with-deps
45- working-directory : plugins/hwp-previews
89+ working-directory : plugins/${{ matrix.plugin }}
4690
4791 - name : Start wp-env
48- run : |
49- npm run wp-env start
50- working-directory : plugins/hwp-previews
92+ run : npm run wp-env start
93+ working-directory : plugins/${{ matrix.plugin }}
5194
5295 - name : Run Playwright tests
5396 run : npm run test:e2e
54- working-directory : plugins/hwp-previews
97+ working-directory : plugins/${{ matrix.plugin }}
5598
5699 - name : Stop wp-env
57100 run : npm run wp-env stop
58- working-directory : plugins/hwp-previews
101+ working-directory : plugins/${{ matrix.plugin }}
0 commit comments