-
Notifications
You must be signed in to change notification settings - Fork 300
135 lines (127 loc) · 4.86 KB
/
functional_tests_cron.yml
File metadata and controls
135 lines (127 loc) · 4.86 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
name: Functional Test Suite (cron)
permissions: {}
on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch:
inputs:
test_env:
description: 'Environment to run the functional test suite against'
required: false
default: ''
type: choice
options:
- ''
- stage
- production
jobs:
functional-tests:
name: Functional tests (${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}) [${{ github.event_name }}]
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
test_env: ${{ github.event_name == 'schedule' && fromJson('["stage","production"]') || fromJson('["unset"]') }}
steps:
- name: Fail manual run if environment is missing
if: github.event_name == 'workflow_dispatch' && inputs.test_env == ''
run: |
echo "Please select an environment for manual runs"
exit 1
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: 20.20.x
- name: Install dependencies
run: npm ci
- name: Store Playwright’s Version
run: |
# Get the current Playwright version listed in package.json
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright Browsers for Playwright's Version
id: cache-playwright-browsers
uses: actions/cache@v5
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }}
- name: Setup Playwright Browser
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps
- name: Run Playwright tests - ${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}
if: github.event.pull_request.user.login != 'dependabot[bot]'
run: npm run functional-tests
timeout-minutes: 40
env:
E2E_TEST_ENV: ${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}
E2E_TEST_SECRET: ${{ secrets.E2E_TEST_SECRET }}
E2E_TEST_ACCOUNT_BASE_EMAIL: ${{ secrets.E2E_TEST_ACCOUNT_BASE_EMAIL }}
E2E_TEST_ACCOUNT_BASE_PASSWORD: ${{ secrets.E2E_TEST_ACCOUNT_BASE_PASSWORD }}
- uses: actions/upload-artifact@v6
if: always()
with:
name: playwright-report-${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}
path: playwright-report/
retention-days: 30
- uses: actions/upload-artifact@v6
if: always()
with:
name: test-results-${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}
path: src/functional-tests/test-results/
retention-days: 30
- name: Send GitHub Action trigger data to Slack workflow
id: slack
uses: slackapi/slack-github-action@v2.1.1
if: failure() && github.ref == 'refs/heads/main'
with:
webhook: ${{ secrets.SLACK_GHA_FAILURES_WEBHOOK }}
webhook-type: webhook-trigger
# For posting a message using Block Kit
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Link to job:* *<https://github.com/mozilla/blurts-server/actions/runs/${{ github.run_id }}|Functional tests>*"
}
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Workflow:* \n ${{ github.workflow }}"
},
{
"type": "mrkdwn",
"text": "*Environment:* \n ${{ github.event_name == 'workflow_dispatch' && inputs.test_env || matrix.test_env }}"
},
{
"type": "mrkdwn",
"text": "*Status:* \n ${{ job.status }}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Ref:*\n ${{ github.ref }} "
},
{
"type": "mrkdwn",
"text": "*Triggered by:*\n ${{ github.triggering_actor }}"
}
]
}
]
}