-
Notifications
You must be signed in to change notification settings - Fork 42
239 lines (239 loc) · 10.3 KB
/
tests-end-to-end-seating.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
name: 'End-to-End Tests - Seating'
on:
pull_request:
paths:
- 'tests/**.ts'
- 'src/**.php'
- 'src/resources/**.js'
- 'composer.json'
- 'composer.lock'
- '.github/workflows/tests-end-to-end-seating.yml'
jobs:
test:
strategy:
fail-fast: false
matrix:
suite:
- seating
runs-on: ubuntu-latest
steps:
# ------------------------------------------------------------------------------
# Checkout the repo
# ------------------------------------------------------------------------------
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 1000
token: ${{ secrets.GH_BOT_TOKEN }}
submodules: recursive
# ------------------------------------------------------------------------------
# Checkout slic
# ------------------------------------------------------------------------------
- name: Checkout slic
uses: actions/checkout@v2
with:
repository: stellarwp/slic
ref: main
path: slic
fetch-depth: 1
# ------------------------------------------------------------------------------
# Prepare our composer cache directory
# ------------------------------------------------------------------------------
- name: Get Composer Cache Directory
id: get-composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)-${{ secrets.COMPOSER_CACHE_KEY }}"
- uses: actions/cache@v2
id: composer-cache
with:
path: ${{ steps.get-composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ secrets.COMPOSER_CACHE_KEY }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
# ------------------------------------------------------------------------------
# Initialize slic
# ------------------------------------------------------------------------------
- name: Set up slic env vars
run: |
echo "SLIC_BIN=${GITHUB_WORKSPACE}/slic/slic" >> $GITHUB_ENV
echo "SLIC_WP_DIR=${GITHUB_WORKSPACE}/slic/_wordpress" >> $GITHUB_ENV
echo "SLIC_WORDPRESS_DOCKERFILE=Dockerfile.base" >> $GITHUB_ENV
- name: Set run context for slic
run: echo "SLIC=1" >> $GITHUB_ENV && echo "CI=1" >> $GITHUB_ENV
- name: Start ssh-agent
run: |
mkdir -p "${HOME}/.ssh";
ssh-agent -a /tmp/ssh_agent.sock;
- name: Export SSH_AUTH_SOCK env var
run: echo "SSH_AUTH_SOCK=/tmp/ssh_agent.sock" >> $GITHUB_ENV
- name: Set up slic for CI
run: |
cd ${GITHUB_WORKSPACE}/..
${SLIC_BIN} here
${SLIC_BIN} interactive off
${SLIC_BIN} build-prompt off
${SLIC_BIN} build-subdir off
${SLIC_BIN} xdebug off
${SLIC_BIN} composer-cache set /home/runner/.cache/composer
${SLIC_BIN} debug on
${SLIC_BIN} info
${SLIC_BIN} config
# ------------------------------------------------------------------------------
# Start the Chrome container
# ------------------------------------------------------------------------------
- name: Start the Chrome container
run: ${SLIC_BIN} up chrome
# ------------------------------------------------------------------------------
# Fetch branches for dependent repos
# ------------------------------------------------------------------------------
- name: Fetch head branch from TEC
uses: octokit/[email protected]
id: fetch-tec-head-branch
with:
route: GET /repos/{owner}/{repo}/branches/${{ github.head_ref }}
owner: the-events-calendar
repo: the-events-calendar
env:
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
continue-on-error: true
- name: Fetch base branch from TEC
uses: octokit/[email protected]
id: fetch-tec-base-branch
if: steps.fetch-tec-head-branch.outcome != 'success'
with:
route: GET /repos/{owner}/{repo}/branches/${{ github.base_ref }}
owner: the-events-calendar
repo: the-events-calendar
env:
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
continue-on-error: true
# ------------------------------------------------------------------------------
# Set TEC branch
# ------------------------------------------------------------------------------
- name: Set TEC with head branch
if: steps.fetch-tec-head-branch.outcome == 'success'
run: echo "TEC_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
- name: Set TEC with base branch
if: steps.fetch-tec-head-branch.outcome != 'success' && steps.fetch-tec-base-branch.outcome == 'success'
run: echo "TEC_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
- name: Set TEC with master branch
if: steps.fetch-tec-head-branch.outcome != 'success' && steps.fetch-tec-base-branch.outcome != 'success'
run: echo "TEC_BRANCH=master" >> $GITHUB_ENV
# ------------------------------------------------------------------------------
# Clone and init TEC
# ------------------------------------------------------------------------------
- name: Clone TEC
uses: actions/checkout@v2
with:
fetch-depth: 1
repository: the-events-calendar/the-events-calendar
ref: ${{ env.TEC_BRANCH }}
token: ${{ secrets.GH_BOT_TOKEN }}
path: the-events-calendar
submodules: recursive
- name: Init TEC (including npm)
run: |
mv ${GITHUB_WORKSPACE}/the-events-calendar ${GITHUB_WORKSPACE}/../the-events-calendar
docker network prune -f
${SLIC_BIN} use the-events-calendar
${SLIC_BIN} composer install --no-dev
${SLIC_BIN} npm install
${SLIC_BIN} npm run build
- name: Set up TEC Common (including npm)
run: |
docker network prune -f
${SLIC_BIN} use the-events-calendar/common
${SLIC_BIN} composer install --no-dev
${SLIC_BIN} npm install
${SLIC_BIN} npm run build
# ------------------------------------------------------------------------------
# Set up ET Common
# ------------------------------------------------------------------------------
- name: Set up ET Common (including npm)
run: |
docker network prune -f
${SLIC_BIN} use event-tickets/common
${SLIC_BIN} composer install --no-dev
${SLIC_BIN} npm install
${SLIC_BIN} npm run build
# ------------------------------------------------------------------------------
# Set up ET (including npm)
# ------------------------------------------------------------------------------
- name: Set up ET
run: |
${SLIC_BIN} use event-tickets
${SLIC_BIN} composer install
${SLIC_BIN} npm install
${SLIC_BIN} npm run build
# ------------------------------------------------------------------------------
# Init WordPress container
# ------------------------------------------------------------------------------
- name: Init the WordPress container
run: |
${SLIC_BIN} up wordpress
${SLIC_BIN} wp core version
${SLIC_BIN} wp core update --force --version=6.4.1
${SLIC_BIN} wp core version
# ------------------------------------------------------------------------------
# Install and activate TwentyTwenty
# ------------------------------------------------------------------------------
- name: Install and activate TwentyTwenty
run: ${SLIC_BIN} wp theme install twentytwenty --activate
# ------------------------------------------------------------------------------
# Install Playwright dependencies (chromium)
# ------------------------------------------------------------------------------
- name: Install Playwright dependencies
run: ${SLIC_BIN} playwright install chromium
env:
CI: 'true'
# ------------------------------------------------------------------------------
# Clone, init and spin up the Seating service
# ------------------------------------------------------------------------------
- name: Set the env var for the Seating service directory
run: echo "SEATING_SERVICE_DIR=$(realpath {GITHUB_WORKSPACE}/../event-tickets-seating-service)" >> $GITHUB_ENV
- name: Clone the Seating service
uses: actions/checkout@v2
with:
fetch-depth: 1
repository: the-events-calendar/event-tickets-seating-service
ref: routes-local-development
path: ${{ SEATING_SERVICE_DIR }}
submodules: recursive
token: ${{ secrets.GH_BOT_TOKEN }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ${{ SEATING_SERVICE_DIR }}/.nvmrc
- name: Init the Seating service
working-directory: ${{ SEATING_SERVICE_DIR }}
run: |
npm ci
npm run build
- name: Install pm2
run: |
npm install -g pm2
pm2 -V
pm2 list
- name: Start the Seating service using pm2
working-directory: ${{ SEATING_SERVICE_DIR }}
run: |
pm2 start npm --name "seating-ci" -- run local:up
pm2 list
# ------------------------------------------------------------------------------
# Run Playwright tests
# ------------------------------------------------------------------------------
- name: Run suite tests
run: |
${SLIC_BIN} playwright test tests/end-to-end/${{ matrix.suite }}
env:
CI: 'true'
# ------------------------------------------------------------------------------
# Upload artifacts (On failure) -- @todo find the location of the artifacts in Playwright
# ------------------------------------------------------------------------------
- name: Upload artifacts on failure
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: playwright-${{ matrix.suite }}-report
path: tests/_output/playwright/
retention-days: 7