-
Notifications
You must be signed in to change notification settings - Fork 67
143 lines (138 loc) · 5.15 KB
/
Copy pathplaywright.yml
File metadata and controls
143 lines (138 loc) · 5.15 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Playwright Tests
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
cache-dependency-path: package-lock.json
- name: Build Stackable Free Plugin
run: |
npm ci --legacy-peer-deps
npm run build:no-translate
- name: Archive plugin build
run: tar --exclude=./node_modules --exclude=./.git -czf /tmp/stackable-playwright-build.tar.gz .
- uses: actions/upload-artifact@v4
with:
name: stackable-playwright-build
path: /tmp/stackable-playwright-build.tar.gz
retention-days: 1
test:
needs: build
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false # Ensures the matrix doesn't stop if one job fails
matrix:
include:
# stackable-playwright-matrix-start
- php_version: '8.5'
wp_version: '7.0.1'
- php_version: '7.4'
wp_version: '7.0.1'
- php_version: '7.4'
wp_version: '6.8.5'
- php_version: '7.4'
wp_version: '6.9.4'
# stackable-playwright-matrix-end
name: PHP ${{ matrix.php_version }} and WP ${{ matrix.wp_version || 'latest' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
cache-dependency-path: package-lock.json
- name: Restore plugin build
uses: actions/download-artifact@v4
with:
name: stackable-playwright-build
- name: Extract plugin build
run: tar -xzf stackable-playwright-build.tar.gz
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Set the version suffix for the output
run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV
- name: Set WP Version and create .wp-env.json
run: |
WP_VERSION="${{ matrix.wp_version }}"
core='"Wordpress/Wordpress#'${{ matrix.wp_version }}'"'
if [[ -z "$WP_VERSION" || "$WP_VERSION" == "null" ]]; then
WP_VERSION="latest"
core=null
fi
echo "WP_VERSION=$WP_VERSION" >> $GITHUB_ENV
echo '{
"core": '$core',
"phpVersion": "${{ matrix.php_version }}",
"plugins": [ "." ],
"config": {
"SCRIPT_DEBUG": false
}
}' > .wp-env.json
cat .wp-env.json
- name: Cache Playwright Browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright Browsers
timeout-minutes: 15
run: |
for attempt in 1 2 3; do
npx playwright install chromium --with-deps && exit 0
echo "Playwright install failed on attempt $attempt"
sleep $((attempt * 30))
done
exit 1
- name: Start wp-env
run: npx @wordpress/env start
- name: Print current WP version
run: npx @wordpress/env run tests-cli wp core version
- name: Create post with existing blocks
run: |
POST_ID=$(npx @wordpress/env run tests-cli wp post create wp-content/plugins/Stackable/e2e/config/post-content.txt --post_title="Existing Blocks" --post_status=publish --porcelain)
echo "WP_TEST_POSTID=$POST_ID" >> $GITHUB_ENV
continue-on-error: true
- name: Disable guided tours
run: |
TOUR_STATES='["design-system", "editor", "design-library", "blocks"]'
npx @wordpress/env run tests-cli wp option update stackable_guided_tour_states "$TOUR_STATES" --format=json
- name: Run playwright tests
id: run-playwright-tests
env:
WP_BASE_URL: http://localhost:8889
WP_AUTH_STORAGE: wp-auth.json
WP_USERNAME: admin
WP_PASSWORD: password
STACKABLE_SLUG: Stackable/plugin
WP_TEST_POSTID: ${{ env.WP_TEST_POSTID }}
run: npm run test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }}
id: artifact-upload-step
with:
name: playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }}
path: playwright-report/
overwrite: true
retention-days: 30
- uses: markpatterson27/markdown-to-output@v1
id: mto
if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }}
with:
filepath: ./playwright-stk/errors.md
- name: Add test results to summary
if: ${{ !cancelled() && steps.run-playwright-tests.outcome == 'failure' }}
run: |
echo "${{ steps.mto.outputs.body }}" >> $GITHUB_STEP_SUMMARY
echo "Report: [playwright-report-php_${{ matrix.php_version }}-wp_${{ env.WP_VERSION }}-${{ env.VERSION_SUFFIX }}.zip](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }})" >> $GITHUB_STEP_SUMMARY