-
Notifications
You must be signed in to change notification settings - Fork 298
172 lines (150 loc) · 6.08 KB
/
e2e-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
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
name: e2e tests
"on":
workflow_call:
inputs:
grafana-image-tag:
required: true
type: string
browsers:
required: true
type: string
run-expensive-tests:
description: >
Whether or not to run Playwright tests that're annotated as "@expensive"
(ex. tests that incur costs such as sending SMSes via Twilio/Mailslurp)
required: true
type: boolean
secrets:
# NOTE: these are only required for the "expensive" e2e tests, which are only run via
# a daily GitHub Actions cron job (see .github/workflows/daily-e2e-tests.yml)
TWILIO_ACCOUNT_SID:
required: false
TWILIO_AUTH_TOKEN:
required: false
TWILIO_PHONE_NUMBER:
required: false
TWILIO_VERIFY_SID:
required: false
MAILSLURP_API_KEY:
required: false
jobs:
end-to-end-tests:
# default "ubuntu-latest" runners only provide 2 CPU cores + 7GB of RAM. this seems to lead to HTTP 504s from
# the oncall backend, and hence, flaky tests. Let's use CI runners w/ more resources to avoid this (plus
# this will allow us to run more backend containers and parralelize the tests)
runs-on: ubuntu-latest-16-cores
name: "Grafana: ${{ inputs.grafana-image-tag }}"
environment:
name: github-pages
permissions:
id-token: write
pages: "write"
steps:
- name: Checkout
uses: actions/checkout@v3
# TODO: re-enable this when we get the docker build build-context caching working.. see other TODO comment below
# - uses: actions/setup-python@v4
# with:
# python-version: "3.11.4"
# cache: "pip"
# cache-dependency-path: |
# engine/requirements.txt
# engine/requirements-dev.txt
- name: Collect Workflow Telemetry
uses: runforesight/workflow-telemetry-action@v1
with:
comment_on_pr: false
proc_trace_chart_show: false
proc_trace_table_show: false
- name: Install Kind
uses: helm/[email protected]
with:
config: ./dev/kind.yml
install_only: true
- uses: actions/setup-node@v3
with:
node-version: 18.16.0
cache: "yarn"
cache-dependency-path: grafana-plugin/yarn.lock
- name: Install Tilt
run: |
curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash
- name: Install ctlptl
run: |
CTLPTL_VERSION="0.8.20"
curl -fsSL https://github.com/tilt-dev/ctlptl/releases/download/v$CTLPTL_VERSION/ctlptl.$CTLPTL_VERSION.linux.x86_64.tar.gz | \
tar -xzv -C /usr/local/bin ctlptl
- name: Use cached frontend dependencies
id: cache-frontend-dependencies
uses: actions/cache@v3
with:
path: grafana-plugin/node_modules
key: ${{ runner.os }}-frontend-node-modules-${{ hashFiles('grafana-plugin/yarn.lock') }}
- name: Install frontend dependencies
if: steps.cache-frontend-dependencies.outputs.cache-hit != 'true'
working-directory: grafana-plugin
run: yarn install --frozen-lockfile --prefer-offline --network-timeout 500000
- name: Use cached plugin frontend build
id: cache-plugin-frontend
uses: actions/cache@v3
with:
path: grafana-plugin/dist
key: ${{ runner.os }}-plugin-frontend-${{ hashFiles('grafana-plugin/src/**/*', 'grafana-plugin/yarn.lock') }}
- name: Build plugin frontend
if: steps.cache-plugin-frontend.outputs.cache-hit != 'true'
working-directory: grafana-plugin
run: yarn build:dev
# helpful reference for properly caching the playwright binaries/dependencies
# https://playwrightsolutions.com/playwright-github-action-to-cache-the-browser-binaries/
- name: Get installed Playwright version
id: playwright-version
working-directory: grafana-plugin
run: >
echo "PLAYWRIGHT_VERSION=$(cat ./package.json |
jq -r '.devDependencies["@playwright/test"]')" >> $GITHUB_ENV
- name: Cache Playwright binaries/dependencies
id: playwright-cache
uses: actions/cache@v3
with:
path: "~/.cache/ms-playwright"
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-${{ inputs.browsers }}
# For the next two steps, use the binary directly from node_modules/.bin as opposed to npx playwright
# due to this bug (https://github.com/microsoft/playwright/issues/13188)
- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: grafana-plugin
run: ./node_modules/.bin/playwright install --with-deps ${{ inputs.browsers }}
# use the cached browsers, but we still need to install the necessary system dependencies
# (system deps are installed in the cache-miss step above by the --with-deps flag)
# - name: Install Playwright System Dependencies
# if: steps.playwright-cache.outputs.cache-hit == 'true'
# working-directory: grafana-plugin
# run: ./node_modules/.bin/playwright install-deps ${{ inputs.browsers }}
- name: Create cluster
run: |
make cluster/up
- name: Tilt CI
uses: docker://mcr.microsoft.com/playwright:next-jammy
shell: bash
env:
GRAFANA_IMAGE_TAG: ${{ inputs.grafana-image-tag }}
run: tilt ci
# - name: Setup Pages
# if: failure()
# uses: actions/configure-pages@v2
- name: Upload artifact
if: failure()
uses: actions/upload-pages-artifact@v1
with:
path: ./grafana-plugin/playwright-report/
# - name: Deploy to GitHub Pages
# if: failure()
# id: deployment
# uses: actions/deploy-pages@v3
# with:
# preview: true
- name: Linked Github Page
if: failure()
run: |
echo "Test report has been deployed to [GitHub Pages](https://grafana.github.io/oncall/) :rocket:" \
>> $GITHUB_STEP_SUMMARY