forked from RedHatInsights/patchman-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (151 loc) · 6.13 KB
/
stage-nightly-tests.yml
File metadata and controls
176 lines (151 loc) · 6.13 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
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
name: 'Stage: E2E Tests'
on:
pull_request:
types: [ opened, reopened, synchronize, labeled, unlabeled ]
schedule:
- cron: '0 0 * * *' # This cron expression runs the action every 24 hours at midnight UTC
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
playwright-integration-tests:
if: ${{ ! contains(github.event.pull_request.labels.*.name, 'skip-integration-tests') }}
runs-on:
- codebuild-patch-frontend-${{ github.run_id }}-${{ github.run_attempt }}
- instance-size:large
- buildspec-override:true
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Cache - node_modules
uses: actions/cache@v5
with:
path: |
node_modules
dist
key: ${{ runner.os }}-frontend-node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: ${{ runner.os }}-frontend-node-modules-
- name: Install dependencies
run: 'npm ci'
- name: Setup Playwright
run: 'npx playwright install chromium --only-shell'
- name: Create .env file
run: |
# Check if the secrets are set
if [ -z "$ADMIN_USERNAME" ]; then
echo "Error: ADMIN_USERNAME secret is not set."
exit 1
fi
if [ -z "$ADMIN_PASSWORD" ]; then
echo "Error: ADMIN_PASSWORD secret is not set."
exit 1
fi
# Create the .env file and write the secrets and other variables to it
{
# Mandatory secrets (they should exist)
echo "ADMIN_USERNAME=$ADMIN_USERNAME"
echo "ADMIN_PASSWORD=$ADMIN_PASSWORD"
# Other variables (some might be optional/missing)
echo "CI=true"
echo "INTEGRATION=true"
echo "RH_CLIENT_PROXY=\"$RH_PROXY_URL\""
echo "DOCKER_SOCKET=/var/run/docker.sock"
echo "ORG_ID_1=\"$STAGE_ORG_ID\""
echo "ACTIVATION_KEY_1=\"$STAGE_ACTIVATION_KEY\""
} >> .env 2>/dev/null
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "BASE_URL=https://stage.foo.redhat.com:1337" >> .env
else
echo "BASE_URL=$STAGE_BASE_URL" >> .env
echo "PROXY=$RH_PROXY_URL" >> .env
fi
echo ".env file created successfully."
### Pull request specific steps ###
# This prevents an error related to minimum watchers when running the front-end and playwright
- name: Increase file watchers limit
if: ${{ github.event_name == 'pull_request' }}
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Update /etc/hosts
if: ${{ github.event_name == 'pull_request' }}
run: sudo npx fec patch-etc-hosts
- name: Build frontend
if: ${{ github.event_name == 'pull_request' }}
run: npm run build
- name: Frontend run (static)
if: ${{ github.event_name == 'pull_request' }}
run: npx fec static --port 8003 &
- name: Wait for frontend to be ready
if: ${{ github.event_name == 'pull_request' }}
timeout-minutes: 3
run: npx wait-on http://localhost:8003/apps/patch/
- name: Run testing proxy
if: ${{ github.event_name == 'pull_request' }}
run: docker run -d --network=host -e HTTPS_PROXY=$RH_PROXY_URL -e ROUTES_JSON_PATH=/config/routes-ci.json -v "$(pwd)/config:/config:ro,Z" --name frontend-development-proxy quay.io/redhat-user-workloads/hcc-platex-services-tenant/frontend-development-proxy:latest
### End of pull request specific steps ###
- name: Run Playwright tests
run: CURRENTS_PROJECT_ID=nKL5NV CURRENTS_RECORD_KEY=$CURRENTS_RECORD_KEY CURRENTS_CI_BUILD_ID="${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}" npx playwright test
- name: Publish Test Report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: './playwright-ctrf/playwright-ctrf.json'
if: ${{ !cancelled() }}
- name: Store Test report
uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 10
- name: Notify Slack on success
uses: slackapi/slack-github-action@v3.0.3
if: ${{ success() && github.event_name == 'schedule' && !cancelled() }}
with:
webhook: ${{ secrets.SLACK_WEBHOOOK }}
webhook-type: incoming-webhook
payload: |
{
"attachments": [
{
"color": "#2EB67D",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/ | :milky_way: Nightly Stage Test (Patch)>: *SUCCESS* :partymeow:"
}
}
]
}
]
}
- name: Notify Slack on failure
uses: slackapi/slack-github-action@v3.0.3
if: ${{ failure() && github.event_name == 'schedule' && !cancelled() }}
with:
webhook: ${{ secrets.SLACK_WEBHOOOK }}
webhook-type: incoming-webhook
payload: |
{
"attachments": [
{
"color": "#d72839",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/ | :milky_way: Nightly Stage Test (Patch)>: *FAILED* :big-sad:"
}
}
]
}
]
}