forked from 10up/ElasticPress
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (101 loc) · 3.2 KB
/
cypress-tests.yml
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
name: E2E Test
env:
NODE_VERSION: "16"
NODE_CACHE: "${{ github.workspace }}/node_modules_cache"
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop
- '[0-9].[0-9x]*' # Version branches: 4.x.x, 4.1.x, 5.x
jobs:
cypress_local:
name: Cypress - Local
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare npm cache
uses: actions/cache@v3
with:
path: ${{ env.NODE_CACHE }}
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.NODE_VERSION }}-
- name: "Install node v${{ env.NODE_VERSION }}"
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci --include=dev
- name: Set up WP environment with Elasticsearch
run: npm run env:start
- name: Build asset
run: npm run build
- name: Set up database
run: npm run cypress:setup
- name: Test
run: npm run cypress:run
- name: Make artifacts available
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-artifact
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/
- name: Stop Elasticsearch
if: always()
run: cd bin/es-docker/ && docker-compose down
cypress_epio:
name: Cypress - EP.io
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare npm cache
uses: actions/cache@v3
with:
path: ${{ env.NODE_CACHE }}
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.NODE_VERSION }}-
- name: "Install node v${{ env.NODE_VERSION }}"
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci --include=dev
- name: Set up WP environment
run: |
npm run env start
npm run env:install-tests-cli
- name: Build asset
run: npm run build
- name: Set up database
run: npm run cypress:setup -- --ep-host=${{ secrets.EPIO_HOST }} --es-shield='${{ secrets.EPIO_SHIELD }}' --ep-index-prefix=${{ secrets.EPIO_INDEX_PREFIX }}
- name: Test
run: npm run cypress:run
- name: Make artifacts available
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-artifact-epio
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/
- name: Delete Elasticsearch indices
if: always()
run: |
PLUGIN_NAME=$(basename "$PWD")
./bin/wp-env-cli tests-wordpress "wp --allow-root plugin activate ${PLUGIN_NAME} --network"
./bin/wp-env-cli tests-wordpress "wp --allow-root elasticpress-tests delete-all-indices"