-
Notifications
You must be signed in to change notification settings - Fork 21
242 lines (201 loc) · 7.51 KB
/
playwright-actions.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
240
241
242
name: build-playwright-test
on:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
playwright-tests:
runs-on:
- codebuild-content-services-frontend-repo-${{ github.run_id }}-${{ github.run_attempt }}
- instance-size:medium
- buildspec-override:true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create front-end .env file
run: |
# Check if the secrets are set
if [ -z "$USER1USERNAME" ]; then
echo "Error: USER1USERNAME secret is not set."
exit 1
fi
if [ -z "$USER1PASSWORD" ]; then
echo "Error: USER1PASSWORD secret is not set."
exit 1
fi
# Create the .env file and write the secrets and other variables to it
{
echo "USER1USERNAME=$USER1USERNAME"
echo "USER1PASSWORD=$USER1PASSWORD"
echo "BASE_URL=https://stage.foo.redhat.com:1337"
echo "CI=true"
} >> .env
echo ".env file created successfully."
- name: Get current PR URL
id: get-pr-url
run: |
# Extract the pull request URL from the event payload
pr_url=$(jq -r '.pull_request.html_url' < "$GITHUB_EVENT_PATH")
echo "Pull Request URL: $pr_url"
# Set the PR URL as an output using the environment file
echo "pr_url=$pr_url" >> $GITHUB_ENV
- name: Get appropriate back-end branch
run: |
chmod +x .github/workflowScripts/getBackendBranch.sh
.github/workflowScripts/getBackendBranch.sh "${{ env.pr_url }}"
- name: Compare .nvmrc files
id: compare-nvmrc
run: |
# Get both .nvmrc files
backendNvmrc="content-sources-backend/_playwright-tests/.nvmrc"
frontendNvmrc=".nvmrc"
# Check if both files exist
if [ ! -f "$backendNvmrc" ]; then
echo "Error: $backendNvmrc does not exist."
exit 1
fi
if [ ! -f "$frontendNvmrc" ]; then
echo "Error: $frontendNvmrc does not exist."
exit 1
fi
# Compare the contents of the two files
if ! cmp -s "$backendNvmrc" "$frontendNvmrc"; then
echo "Error: The .nvmrc files are not the same."
exit 1
fi
echo "The .nvmrc versions are the same!"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Cache - API-test node_modules
if: always()
uses: actions/cache@v4
with:
path: content-sources-backend/_playwright-tests/node_modules
key: ${{ runner.os }}-api-node-modules-${{ hashFiles('content_sources_backend/_playwright-tests/yarn.lock') }}
restore-keys: |
${{ runner.os }}-api-node-modules-
- name: Cache - node_modules
if: always()
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-frontend-node-modules-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-frontend-node-modules-
- name: Cache - Backend compose files
if: always()
uses: actions/cache@v4
with:
path: |
content-sources-backend/release
key: ${{ runner.os }}-compose-${{ hashFiles('content-sources-backend/compose_files/pulp/docker-compose.yml') }}-${{ hashFiles('content_sources_backend/compose_files/candlepin/Dockerfile') }}
restore-keys: |
${{ runner.os }}-compose-
- name: Cache Playwright browsers
if: always()
id: cache-playwright-browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('playwright.config.ts') }}
restore-keys: |
${{ runner.os }}-playwright-
- name: Install front-end dependencies
run: yarn install
- name: Build front-end FEC container
run: |
yarn build
- name: Increase file watchers limit
run: |
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Update /etc/hosts
run: |
sudo npm run patch:hosts
- name: Install front-end Playwright Browsers
run: yarn playwright install --with-deps
- name: Start front-end server
run: |
BACKEND_PORT=8000 yarn start:stage &
npx wait-on https://localhost:1337
- name: Run get_go_version.sh script
working-directory: content-sources-backend
id: get-go-version
run: |
chmod +x ./scripts/get_go_version.sh
GO_VERSION=$(./scripts/get_go_version.sh ./go.mod)
echo "go-version=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "${{ steps.get-go-version.outputs.go-version }}"
- name: Set up Make
working-directory: content-sources-backend
run: |
sudo apt-get install make
- name: Copy the example config
working-directory: content-sources-backend
run: |
cp ./configs/config.yaml.example ./configs/config.yaml
- name: Backend compose-up
working-directory: content-sources-backend
run: make compose-down compose-clean compose-up
- name: Backend run
working-directory: content-sources-backend
run: make run &
- name: Wait for backend to be ready
run: |
echo "Waiting for backend to be ready..."
npx wait-on http://localhost:8000
- name: Run front-end Playwright tests
run: yarn playwright test
# continue-on-error: true
- name: Publish front-end Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: "./playwright-ctrf/playwright-ctrf.json"
if: always()
- name: Store front-end Test report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-ctrf-frontend
path: ./playwright-ctrf
retention-days: 10
- name: Create backend .env file
working-directory: content-sources-backend/_playwright-tests
run: |
echo "BASE_URL=http://127.0.0.1:8000" >> .env
echo "TOKEN=apple" >> .env
echo "CI=true" >> .env
- name: Install API playwright and dependencies
working-directory: content-sources-backend/_playwright-tests
run: yarn install
- name: Install Playwright Browsers
working-directory: content-sources-backend/_playwright-tests
run: yarn playwright install --with-deps
- name: Run API Playwright tests
working-directory: content-sources-backend/_playwright-tests
run: yarn playwright test
# continue-on-error: true
- name: Publish API Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: "./content-sources-backend/_playwright-tests/playwright-ctrf/playwright-ctrf.json"
if: always()
- name: Store API Test report
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-ctrf-backend
path: ./content-sources-backend/_playwright-tests/playwright-ctrf
retention-days: 10