|
1 | | -name: E2E Test |
| 1 | +name: E2e Tests |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + pull-requests: write |
2 | 6 |
|
3 | 7 | env: |
| 8 | + CI: true |
4 | 9 | COMPOSER_VERSION: "2" |
5 | 10 | COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache" |
6 | 11 | NODE_VERSION: "20" |
7 | 12 | NODE_CACHE: "${{ github.workspace }}/node_modules_cache" |
8 | | - CYPRESS_GOOGLE_MAPS_API_KEY: ${{ secrets.CYPRESS_GOOGLE_MAPS_API_KEY }} |
| 13 | + GOOGLE_MAPS_API_KEY: ${{ secrets.CYPRESS_GOOGLE_MAPS_API_KEY }} |
| 14 | + VECTOR_EMBEDDINGS_API_KEY: ${{ secrets.VECTOR_EMBEDDINGS_API_KEY }} |
| 15 | + VECTOR_EMBEDDINGS_API_URL: ${{ secrets.VECTOR_EMBEDDINGS_API_URL }} |
| 16 | + VECTOR_EMBEDDINGS_MODEL: ${{ secrets.VECTOR_EMBEDDINGS_MODEL }} |
| 17 | + AI_SEARCH_SUMMARY_API_URL: ${{ secrets.AI_SEARCH_SUMMARY_API_URL }} |
| 18 | + AI_SEARCH_SUMMARY_MODEL: ${{ secrets.AI_SEARCH_SUMMARY_MODEL }} |
9 | 19 |
|
10 | 20 | on: |
11 | | - schedule: |
12 | | - - cron: '0 0 * * *' |
13 | 21 | push: |
14 | 22 | branches: |
15 | 23 | - develop |
|
20 | 28 | - '[0-9].[0-9x]*' # Version branches: 4.x.x, 4.1.x, 5.x |
21 | 29 |
|
22 | 30 | jobs: |
23 | | - cypress_local: |
| 31 | + e2e_local: |
24 | 32 | name: ES ${{ matrix.esVersion }} - ${{ matrix.core.name }} |
25 | 33 | runs-on: ubuntu-latest |
| 34 | + defaults: |
| 35 | + run: |
| 36 | + working-directory: ./elasticpress-labs |
26 | 37 | strategy: |
27 | 38 | fail-fast: false |
28 | 39 | matrix: |
29 | | - esVersion: ['7.10.1', '8.12.2'] |
| 40 | + esVersion: ['7.10.1', '8.12.2', '9.1.5', 'EP.io'] |
30 | 41 | core: |
31 | 42 | - {name: 'WP latest', version: ''} |
32 | | - - {name: 'WP minimum', version: '6.0'} |
| 43 | + - {name: 'WP minimum', version: '6.2'} |
33 | 44 |
|
34 | 45 | steps: |
35 | 46 | - name: Checkout |
36 | 47 | uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + path: elasticpress-labs |
| 50 | + |
| 51 | + - name: Set path variable |
| 52 | + run: | |
| 53 | + echo "WORKING_DIR=$(pwd)" >> $GITHUB_ENV |
37 | 54 |
|
38 | 55 | - name: Prepare npm cache |
39 | 56 | uses: actions/cache@v4 |
@@ -69,120 +86,56 @@ jobs: |
69 | 86 | - name: Install dependencies |
70 | 87 | run: npm ci --include=dev |
71 | 88 |
|
| 89 | + - name: Install Playwright Browsers |
| 90 | + run: npx playwright install --with-deps |
| 91 | + |
72 | 92 | - name: Set up WP environment with Elasticsearch |
73 | 93 | run: ES_VERSION=${{ matrix.esVersion }} npm run env:start |
| 94 | + if: matrix.esVersion != 'EP.io' |
74 | 95 |
|
75 | | - - name: Check ES response |
76 | | - run: curl --connect-timeout 5 --max-time 10 --retry 5 --retry-max-time 40 --retry-all-errors http://localhost:8890 |
77 | | - |
78 | | - - name: Build asset |
79 | | - run: npm run build |
80 | | - |
81 | | - - name: Set up database |
82 | | - run: npm run cypress:setup -- --wp-version=${{ matrix.core.version }} |
83 | | - |
84 | | - - name: Test |
85 | | - run: npm run cypress:run |
86 | | - |
87 | | - - name: Make artifacts available |
88 | | - uses: actions/upload-artifact@v4 |
89 | | - if: failure() |
90 | | - with: |
91 | | - name: cypress-artifact-${{ matrix.esVersion }}-${{ matrix.core.name }} |
92 | | - retention-days: 2 |
93 | | - path: | |
94 | | - ${{ github.workspace }}/tests/cypress/screenshots/ |
95 | | - ${{ github.workspace }}/tests/cypress/videos/ |
96 | | - ${{ github.workspace }}/tests/cypress/logs/ |
97 | | -
|
98 | | - - name: Stop Elasticsearch |
99 | | - if: always() |
100 | | - run: npm run es:stop |
101 | | - |
102 | | - cypress_epio: |
103 | | - name: EP.io - ${{ matrix.core.name }} |
104 | | - runs-on: ubuntu-latest |
105 | | - strategy: |
106 | | - fail-fast: false |
107 | | - matrix: |
108 | | - core: |
109 | | - - {name: 'WP latest', version: ''} |
110 | | - - {name: 'WP minimum', version: '6.0'} |
111 | | - |
112 | | - steps: |
113 | | - - name: Checkout |
114 | | - uses: actions/checkout@v4 |
115 | | - |
116 | | - - name: Prepare npm cache |
117 | | - uses: actions/cache@v4 |
118 | | - with: |
119 | | - path: ${{ env.NODE_CACHE }} |
120 | | - key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }} |
121 | | - restore-keys: | |
122 | | - npm-${{ env.NODE_VERSION }}- |
123 | | - - name: Prepare composer cache |
124 | | - uses: actions/cache@v4 |
125 | | - with: |
126 | | - path: ${{ env.COMPOSER_CACHE }} |
127 | | - key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }} |
128 | | - restore-keys: | |
129 | | - composer-${{ env.COMPOSER_VERSION }}- |
130 | | -
|
131 | | - - name: Set PHP version |
132 | | - uses: shivammathur/setup-php@v2 |
133 | | - with: |
134 | | - php-version: '8.2' |
135 | | - extensions: :php-psr |
136 | | - tools: cs2pr |
137 | | - coverage: none |
138 | | - |
139 | | - - name: composer install |
140 | | - run: composer install |
141 | | - |
142 | | - - name: "Install node v${{ env.NODE_VERSION }}" |
143 | | - uses: actions/setup-node@v4 |
144 | | - with: |
145 | | - node-version: ${{ env.NODE_VERSION }} |
146 | | - |
147 | | - - name: Install dependencies |
148 | | - run: npm ci --include=dev |
149 | | - |
150 | | - - name: Set up WP environment |
| 96 | + - name: Set up WP environment with Elasticsearch (EP.io) |
151 | 97 | run: | |
152 | 98 | npm run env start |
153 | 99 | npm run env:install-tests-cli |
| 100 | + if: matrix.esVersion == 'EP.io' |
| 101 | + |
| 102 | + - name: Check ES response |
| 103 | + run: curl --connect-timeout 5 --max-time 10 --retry 5 --retry-max-time 40 --retry-all-errors http://localhost:8890 |
| 104 | + if: matrix.esVersion != 'EP.io' |
154 | 105 |
|
155 | 106 | - name: Build asset |
156 | 107 | run: npm run build |
157 | 108 |
|
158 | 109 | - name: Set up database |
| 110 | + run: npm run e2e:setup -- --wp-version=${{ matrix.core.version }} --ep-branch=develop --cf-access-client-id="${{ secrets.CF_ACCESS_CLIENT_ID }}" --cf-access-client-secret="${{ secrets.CF_ACCESS_CLIENT_SECRET }}" |
| 111 | + if: matrix.esVersion != 'EP.io' |
| 112 | + |
| 113 | + - name: Set up database (EP.io) |
159 | 114 | env: |
160 | 115 | EPIO_HOST: ${{ vars.EPIO_HOST }} |
161 | 116 | EPIO_INDEX_PREFIX: ${{ vars.EPIO_INDEX_PREFIX }} |
162 | | - run: npm run cypress:setup -- --ep-host="$EPIO_HOST" --es-shield='${{ secrets.EP_CREDENTIALS }}' --ep-index-prefix="$EPIO_INDEX_PREFIX" --wp-version=${{ matrix.core.version }} |
| 117 | + run: npm run e2e:setup -- --ep-host="$EPIO_HOST" --es-shield='${{ secrets.EP_CREDENTIALS }}' --ep-index-prefix="$EPIO_INDEX_PREFIX" --wp-version=${{ matrix.core.version }} --ep-branch=develop --cf-access-client-id="${{ secrets.CF_ACCESS_CLIENT_ID }}" --cf-access-client-secret="${{ secrets.CF_ACCESS_CLIENT_SECRET }}" |
| 118 | + if: matrix.esVersion == 'EP.io' |
163 | 119 |
|
164 | | - - name: Test |
165 | | - run: npm run cypress:run |
| 120 | + - name: Run Playwright tests |
| 121 | + run: npm run playwright:test |
166 | 122 |
|
167 | 123 | - name: Make artifacts available |
168 | 124 | uses: actions/upload-artifact@v4 |
169 | 125 | if: failure() |
170 | 126 | with: |
171 | | - name: cypress-artifact-epio-${{ matrix.core.name }} |
| 127 | + name: playwright-report-${{ matrix.esVersion }}-${{ matrix.core.name }} |
172 | 128 | retention-days: 2 |
173 | | - path: | |
174 | | - ${{ github.workspace }}/tests/cypress/screenshots/ |
175 | | - ${{ github.workspace }}/tests/cypress/videos/ |
176 | | - ${{ github.workspace }}/tests/cypress/logs/ |
| 129 | + path: ${{ env.WORKING_DIR }}/tests/e2e/playwright-report/ |
177 | 130 |
|
178 | 131 | - name: Delete Elasticsearch search templates |
179 | | - if: always() |
| 132 | + if: ${{ !cancelled() && matrix.esVersion == 'EP.io' }} |
180 | 133 | run: | |
181 | 134 | ./bin/wp-env-cli tests-wordpress "wp --allow-root plugin activate elasticpress elasticpress-labs" |
182 | 135 | ./bin/wp-env-cli tests-wordpress "wp --allow-root elasticpress-tests delete-all-search-templates" |
183 | 136 |
|
184 | 137 | - name: Delete Elasticsearch indices |
185 | | - if: always() |
| 138 | + if: ${{ !cancelled() && matrix.esVersion == 'EP.io' }} |
186 | 139 | run: | |
187 | 140 | ./bin/wp-env-cli tests-wordpress "wp --allow-root plugin activate elasticpress elasticpress-labs" |
188 | 141 | ./bin/wp-env-cli tests-wordpress "wp --allow-root elasticpress-tests delete-all-indices" |
0 commit comments