Skip to content

Commit d28d495

Browse files
authored
Chore: Enable PR testing in Drone (grafana#26189)
* Add Drone configuration Signed-off-by: Arve Knudsen <[email protected]> * Add more steps Signed-off-by: Arve Knudsen <[email protected]> * Add more steps Signed-off-by: Arve Knudsen <[email protected]> * Build front-end before testing it Signed-off-by: Arve Knudsen <[email protected]> * Upgrade grafana/build-container Signed-off-by: Arve Knudsen <[email protected]> * Add packaging step Signed-off-by: Arve Knudsen <[email protected]> * Trigger on push Signed-off-by: Arve Knudsen <[email protected]> * Remove some steps Signed-off-by: Arve Knudsen <[email protected]> * Enable steps Signed-off-by: Arve Knudsen <[email protected]> * Install Dockerize Signed-off-by: Arve Knudsen <[email protected]> * Use node image for test-frontend Signed-off-by: Arve Knudsen <[email protected]> * Increase number of test workers Signed-off-by: Arve Knudsen <[email protected]> * Make plugin installation depend on frontend tests Signed-off-by: Arve Knudsen <[email protected]> * Make integration tests depend on frontend tests Signed-off-by: Arve Knudsen <[email protected]> * Use grafana/build-container also for front-end tests Signed-off-by: Arve Knudsen <[email protected]> * Upgrade dependencies in order to fix front-end tests Signed-off-by: Arve Knudsen <[email protected]> * Depend on es-check Signed-off-by: Arve Knudsen <[email protected]> * Dont' depend on tests before building front-end Signed-off-by: Arve Knudsen <[email protected]> * Add more steps Signed-off-by: Arve Knudsen <[email protected]> * Fix packaging Signed-off-by: Arve Knudsen <[email protected]> * Simplify Signed-off-by: Arve Knudsen <[email protected]> * Try to build images Signed-off-by: Arve Knudsen <[email protected]> * Fix e2e tests Signed-off-by: Arve Knudsen <[email protected]> * Remove steps Signed-off-by: Arve Knudsen <[email protected]> * Install netcat Signed-off-by: Arve Knudsen <[email protected]> * Include golangci-lint with grafana/build-container Signed-off-by: Arve Knudsen <[email protected]> * Build storybook and docs website Signed-off-by: Arve Knudsen <[email protected]> * Fix e2e tests Signed-off-by: Arve Knudsen <[email protected]> * Use build image with root user Signed-off-by: Arve Knudsen <[email protected]> * Drop CircleCI dependencies Signed-off-by: Arve Knudsen <[email protected]> * Fix e2e tests Signed-off-by: Arve Knudsen <[email protected]> * Fix e2e under Drone Signed-off-by: Arve Knudsen <[email protected]> * Execute e2e server separately Signed-off-by: Arve Knudsen <[email protected]> * Use own plugin for building Docker images Signed-off-by: Arve Knudsen <[email protected]> * Use Starlark to configure Drone Signed-off-by: Arve Knudsen <[email protected]> * Add enterprise steps to pipeline Signed-off-by: Arve Knudsen <[email protected]> * Add more enterprise steps to pipeline Signed-off-by: Arve Knudsen <[email protected]> * Maintain Yarn cache Signed-off-by: Arve Knudsen <[email protected]> * Build enterprise Docker images Signed-off-by: Arve Knudsen <[email protected]> * Build Ubuntu Docker images Signed-off-by: Arve Knudsen <[email protected]> * Refactor Signed-off-by: Arve Knudsen <[email protected]> * Add Postgres integration test Signed-off-by: Arve Knudsen <[email protected]> * Add MySQL integration test Signed-off-by: Arve Knudsen <[email protected]> * Fix integration tests Signed-off-by: Arve Knudsen <[email protected]> * Parameterize integration test DB connections Signed-off-by: Arve Knudsen <[email protected]> * Categorize integration tests Signed-off-by: Arve Knudsen <[email protected]> * Use grabpl integration-tests Signed-off-by: Arve Knudsen <[email protected]> * Remove unintended change Signed-off-by: Arve Knudsen <[email protected]> * Drone: Disable Ubuntu Docker images for PR pipeline Signed-off-by: Arve Knudsen <[email protected]> * Regenerate yarn.lock Signed-off-by: Arve Knudsen <[email protected]> * Upgrade grabpl Signed-off-by: Arve Knudsen <[email protected]> * Restore Yarn cache before installing in grafana-enterprise Signed-off-by: Arve Knudsen <[email protected]> * Use separate pipelines for OSS and enterprise Signed-off-by: Arve Knudsen <[email protected]> * Let OSS builds depend on tests Signed-off-by: Arve Knudsen <[email protected]> * Restore Go cache before building back-end Signed-off-by: Arve Knudsen <[email protected]> * Reduce number of variants built for PRs Signed-off-by: Arve Knudsen <[email protected]> * Fix building of Docker images Signed-off-by: Arve Knudsen <[email protected]> * Drone: Simplify logic Signed-off-by: Arve Knudsen <[email protected]> * Drone: Use Starlark Signed-off-by: Arve Knudsen <[email protected]> * Drone: Fix syntax error Signed-off-by: Arve Knudsen <[email protected]> * Convert .drone.star to YAML Signed-off-by: Arve Knudsen <[email protected]> * Upgrade AWS Go SDK Signed-off-by: Arve Knudsen <[email protected]> * Drone: Fix Go linting Signed-off-by: Arve Knudsen <[email protected]> * Undo irrelevant changes Signed-off-by: Arve Knudsen <[email protected]> * Revert "Undo irrelevant changes" This reverts commit 5152f65. * Undo irrelevant changes Signed-off-by: Arve Knudsen <[email protected]> * e2e: Support Circle Signed-off-by: Arve Knudsen <[email protected]> * Remove unused script Signed-off-by: Arve Knudsen <[email protected]> * TypeScript fixes Signed-off-by: Arve Knudsen <[email protected]> * TypeScript fixes Signed-off-by: Arve Knudsen <[email protected]> * Remove unused script Signed-off-by: Arve Knudsen <[email protected]> * More Drone support Signed-off-by: Arve Knudsen <[email protected]> * Remove unused script Signed-off-by: Arve Knudsen <[email protected]> * Fix build on Circle Signed-off-by: Arve Knudsen <[email protected]> * Remove TODO comment Signed-off-by: Arve Knudsen <[email protected]>
1 parent 1391575 commit d28d495

25 files changed

+1009
-206
lines changed

.drone.star

+488
Large diffs are not rendered by default.

.drone.yml

+351
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,351 @@
1+
---
2+
kind: pipeline
3+
type: docker
4+
name: test-pr-oss
5+
6+
platform:
7+
os: linux
8+
arch: amd64
9+
10+
steps:
11+
- name: install-deps
12+
image: grafana/build-container:1.2.21
13+
commands:
14+
- curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v$${GRABPL_VERSION}/grabpl
15+
- chmod +x grabpl
16+
- mkdir -p bin
17+
- mv grabpl bin
18+
- curl -fLO https://github.com/jwilder/dockerize/releases/download/v$${DOCKERIZE_VERSION}/dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz
19+
- tar -C bin -xzvf dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz
20+
- rm dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz
21+
- yarn install --frozen-lockfile --no-progress
22+
- cp -r $(yarn cache dir) yarn-cache
23+
environment:
24+
DOCKERIZE_VERSION: 0.6.1
25+
GRABPL_VERSION: 0.4.15
26+
27+
- name: lint-go
28+
image: grafana/build-container:1.2.21
29+
commands:
30+
- make lint-go
31+
environment:
32+
CGO_ENABLED: 1
33+
depends_on:
34+
- install-deps
35+
36+
- name: codespell
37+
image: grafana/build-container:1.2.21
38+
commands:
39+
- "echo -e \"unknwon\nreferer\nerrorstring\neror\niam\" > words_to_ignore.txt"
40+
- codespell -I words_to_ignore.txt docs/
41+
depends_on:
42+
- install-deps
43+
44+
- name: shellcheck
45+
image: grafana/build-container:1.2.21
46+
commands:
47+
- curl -fLO http://storage.googleapis.com/grafana-downloads/ci-dependencies/shellcheck-v$${VERSION}.linux.x86_64.tar.xz
48+
- echo $$CHKSUM shellcheck-v$${VERSION}.linux.x86_64.tar.xz | sha512sum --check --strict --status
49+
- tar xf shellcheck-v$${VERSION}.linux.x86_64.tar.xz
50+
- mv shellcheck-v$${VERSION}/shellcheck /usr/local/bin/
51+
- rm -rf shellcheck-v$${VERSION}*
52+
- ./bin/grabpl shellcheck
53+
environment:
54+
CHKSUM: beca3d7819a6bdcfbd044576df4fc284053b48f468b2f03428fe66f4ceb2c05d9b5411357fa15003cb0311406c255084cf7283a3b8fce644c340c2f6aa910b9f
55+
VERSION: 0.7.1
56+
depends_on:
57+
- install-deps
58+
59+
- name: build-backend
60+
image: grafana/build-container:1.2.21
61+
commands:
62+
- rm -rf $(go env GOCACHE) && cp -r go-cache $(go env GOCACHE)
63+
- ./bin/grabpl build-backend --github-token "$${GITHUB_TOKEN}" --edition oss --build-id $DRONE_BUILD_NUMBER --variants linux-x64,linux-x64-musl,osx64,win64
64+
environment:
65+
GITHUB_TOKEN:
66+
from_secret: github_token
67+
depends_on:
68+
- install-deps
69+
- lint-go
70+
- test-backend
71+
72+
- name: build-frontend
73+
image: grafana/build-container:1.2.21
74+
commands:
75+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
76+
- ./bin/grabpl build-frontend --no-install-deps --github-token "$${GITHUB_TOKEN}" --edition oss --build-id $DRONE_BUILD_NUMBER
77+
environment:
78+
GITHUB_TOKEN:
79+
from_secret: github_token
80+
depends_on:
81+
- install-deps
82+
- test-frontend
83+
84+
- name: test-backend
85+
image: grafana/build-container:1.2.21
86+
commands:
87+
- go test -covermode=atomic ./pkg/...
88+
- ./bin/grabpl integration-tests
89+
- cp -r $(go env GOCACHE) go-cache
90+
depends_on:
91+
- install-deps
92+
- lint-go
93+
94+
- name: test-frontend
95+
image: grafana/build-container:1.2.21
96+
commands:
97+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
98+
- yarn run prettier:check
99+
- yarn run packages:typecheck
100+
- yarn run typecheck
101+
- yarn run test
102+
depends_on:
103+
- install-deps
104+
105+
- name: build-plugins
106+
image: grafana/build-container:1.2.21
107+
commands:
108+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
109+
- ./bin/grabpl build-plugins --edition oss --no-install-deps
110+
depends_on:
111+
- install-deps
112+
- lint-go
113+
114+
- name: package
115+
image: grafana/build-container:1.2.21
116+
commands:
117+
- . scripts/build/gpg-test-vars.sh && ./bin/grabpl package --github-token "$${GITHUB_TOKEN}" --edition oss --build-id $DRONE_BUILD_NUMBER --variants linux-x64,linux-x64-musl,osx64,win64
118+
environment:
119+
GITHUB_TOKEN:
120+
from_secret: github_token
121+
depends_on:
122+
- build-backend
123+
- build-frontend
124+
- build-plugins
125+
- test-backend
126+
- test-frontend
127+
- codespell
128+
- shellcheck
129+
130+
- name: end-to-end-tests-server
131+
image: grafana/build-container:1.2.21
132+
detach: true
133+
commands:
134+
- ./e2e/start-server
135+
depends_on:
136+
- package
137+
138+
- name: end-to-end-tests
139+
image: grafana/ci-e2e:12.18-1
140+
commands:
141+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
142+
- ./node_modules/.bin/cypress install
143+
- ./e2e/wait-for-grafana
144+
- ./e2e/run-suite
145+
environment:
146+
HOST: end-to-end-tests-server
147+
depends_on:
148+
- end-to-end-tests-server
149+
150+
- name: publish-storybook
151+
image: grafana/build-container:1.2.21
152+
commands:
153+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
154+
- yarn storybook:build
155+
depends_on:
156+
- package
157+
158+
- name: build-docs-website
159+
image: grafana/docs-base:latest
160+
commands:
161+
- mkdir -p /hugo/content/docs/grafana
162+
- cp -r docs/sources /hugo/content/docs/grafana/latest
163+
- cd /hugo && make prod
164+
165+
- name: copy-packages-for-docker
166+
image: grafana/build-container:1.2.21
167+
commands:
168+
- cp dist/*.tar.gz packaging/docker/
169+
depends_on:
170+
- package
171+
172+
- name: build-docker-images
173+
image: grafana/drone-grafana-docker:0.2.0
174+
settings:
175+
archs: amd64
176+
dry_run: true
177+
edition: oss
178+
depends_on:
179+
- copy-packages-for-docker
180+
181+
- name: postgres-integration-test
182+
image: grafana/build-container:1.2.21
183+
commands:
184+
- apt-get update
185+
- apt-get install -yq postgresql-client
186+
- ./bin/dockerize -wait tcp://postgres:5432 -timeout 120s
187+
- psql -p 5432 -h postgres -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql
188+
- rm -rf $(go env GOCACHE) && cp -r go-cache $(go env GOCACHE)
189+
- go clean -testcache
190+
- ./bin/grabpl integration-tests --database postgres
191+
environment:
192+
GRAFANA_TEST_DB: postgres
193+
PGPASSWORD: grafanatest
194+
POSTGRES_HOST: postgres
195+
depends_on:
196+
- test-backend
197+
- test-frontend
198+
199+
- name: mysql-integration-test
200+
image: grafana/build-container:1.2.21
201+
commands:
202+
- apt-get update
203+
- apt-get install -yq default-mysql-client
204+
- ./bin/dockerize -wait tcp://mysql:3306 -timeout 120s
205+
- cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h mysql -P 3306 -u root -prootpass
206+
- rm -rf $(go env GOCACHE) && cp -r go-cache $(go env GOCACHE)
207+
- go clean -testcache
208+
- ./bin/grabpl integration-tests --database mysql
209+
environment:
210+
GRAFANA_TEST_DB: mysql
211+
MYSQL_HOST: mysql
212+
depends_on:
213+
- test-backend
214+
- test-frontend
215+
216+
services:
217+
- name: postgres
218+
image: postgres:12.3-alpine
219+
environment:
220+
POSTGRES_DB: grafanatest
221+
POSTGRES_PASSWORD: grafanatest
222+
POSTGRES_USER: grafanatest
223+
224+
- name: mysql
225+
image: mysql:5.6.48
226+
environment:
227+
MYSQL_DATABASE: grafana_tests
228+
MYSQL_PASSWORD: password
229+
MYSQL_ROOT_PASSWORD: rootpass
230+
MYSQL_USER: grafana
231+
232+
trigger:
233+
event:
234+
- pull_request
235+
236+
---
237+
kind: pipeline
238+
type: docker
239+
name: test-pr-enterprise
240+
241+
platform:
242+
os: linux
243+
arch: amd64
244+
245+
steps:
246+
- name: install-deps
247+
image: grafana/build-container:1.2.21
248+
commands:
249+
- curl -fLO https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v$${GRABPL_VERSION}/grabpl
250+
- chmod +x grabpl
251+
- mkdir -p bin
252+
- mv grabpl bin
253+
- curl -fLO https://github.com/jwilder/dockerize/releases/download/v$${DOCKERIZE_VERSION}/dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz
254+
- tar -C bin -xzvf dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz
255+
- rm dockerize-linux-amd64-v$${DOCKERIZE_VERSION}.tar.gz
256+
- yarn install --frozen-lockfile --no-progress
257+
- cp -r $(yarn cache dir) yarn-cache
258+
environment:
259+
DOCKERIZE_VERSION: 0.6.1
260+
GRABPL_VERSION: 0.4.15
261+
when:
262+
repo:
263+
- grafana/grafana
264+
- aknuds1/grafana
265+
266+
- name: build-backend
267+
image: grafana/build-container:1.2.21
268+
commands:
269+
- ./bin/grabpl build-backend --github-token "$${GITHUB_TOKEN}" --edition enterprise --build-id $DRONE_BUILD_NUMBER --variants linux-x64,linux-x64-musl,osx64,win64
270+
environment:
271+
GITHUB_TOKEN:
272+
from_secret: github_token
273+
when:
274+
repo:
275+
- grafana/grafana
276+
- aknuds1/grafana
277+
depends_on:
278+
- install-deps
279+
280+
- name: build-frontend
281+
image: grafana/build-container:1.2.21
282+
commands:
283+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
284+
- ./bin/grabpl build-frontend --no-install-deps --github-token "$${GITHUB_TOKEN}" --edition enterprise --build-id $DRONE_BUILD_NUMBER
285+
environment:
286+
GITHUB_TOKEN:
287+
from_secret: github_token
288+
when:
289+
repo:
290+
- grafana/grafana
291+
- aknuds1/grafana
292+
depends_on:
293+
- install-deps
294+
295+
- name: build-plugins
296+
image: grafana/build-container:1.2.21
297+
commands:
298+
- rm -rf $(yarn cache dir) && cp -r yarn-cache $(yarn cache dir)
299+
- ./bin/grabpl build-plugins --edition enterprise --no-install-deps
300+
when:
301+
repo:
302+
- grafana/grafana
303+
- aknuds1/grafana
304+
depends_on:
305+
- install-deps
306+
307+
- name: package
308+
image: grafana/build-container:1.2.21
309+
commands:
310+
- . scripts/build/gpg-test-vars.sh && ./bin/grabpl package --github-token "$${GITHUB_TOKEN}" --edition enterprise --build-id $DRONE_BUILD_NUMBER --variants linux-x64,linux-x64-musl,osx64,win64
311+
environment:
312+
GITHUB_TOKEN:
313+
from_secret: github_token
314+
when:
315+
repo:
316+
- grafana/grafana
317+
- aknuds1/grafana
318+
depends_on:
319+
- build-backend
320+
- build-frontend
321+
- build-plugins
322+
323+
- name: copy-packages-for-docker
324+
image: grafana/build-container:1.2.21
325+
commands:
326+
- cp dist/*.tar.gz packaging/docker/
327+
when:
328+
repo:
329+
- grafana/grafana
330+
- aknuds1/grafana
331+
depends_on:
332+
- package
333+
334+
- name: build-docker-images
335+
image: grafana/drone-grafana-docker:0.2.0
336+
settings:
337+
archs: amd64
338+
dry_run: true
339+
edition: enterprise
340+
when:
341+
repo:
342+
- grafana/grafana
343+
- aknuds1/grafana
344+
depends_on:
345+
- copy-packages-for-docker
346+
347+
trigger:
348+
event:
349+
- pull_request
350+
351+
...

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ trim_trailing_whitespace = false
2525
[Makefile]
2626
indent_style = tab
2727
indent_size = 2
28+
29+
[*.star]
30+
indent_size = 4

e2e/run-suite

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/bin/bash
2+
set -xeo pipefail
23

34
. e2e/variables
45

6+
HOST=${HOST:-$DEFAULT_HOST}
7+
PORT=${PORT:-$DEFAULT_PORT}
8+
59
echo -e "Starting Cypress scenarios"
610

711
CMD="start"
812
PARAMS=""
913
SLOWMO=0
10-
URL=${BASE_URL:-"http://$DEFAULT_HOST:$DEFAULT_PORT"}
14+
URL=${BASE_URL:-"http://$HOST:$PORT"}
1115
SUITE=${SUITE:-$DEFAULT_SUITE}
1216

1317
if [ "$1" == "debug" ]; then
@@ -23,6 +27,6 @@ fi
2327

2428
cd packages/grafana-e2e
2529

26-
yarn $CMD --env BASE_URL=$URL,CIRCLE_SHA1=$CIRCLE_SHA1,SLOWMO=$SLOWMO \
30+
yarn $CMD --env BASE_URL=$URL,SLOWMO=$SLOWMO \
2731
--config integrationFolder=../../e2e/$SUITE/specs,screenshotsFolder=../../e2e/$SUITE/screenshots,videosFolder=../../e2e/$SUITE/videos,fileServerFolder=./cypress,viewportWidth=1920,viewportHeight=1080,trashAssetsBeforeRuns=false \
2832
$PARAMS

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"e2e:debug": "./e2e/start-and-run-suite debug",
1414
"e2e:dev": "./e2e/start-and-run-suite dev",
1515
"jest": "jest --notify --watch",
16-
"jest-ci": "mkdir -p reports/junit && export JEST_JUNIT_OUTPUT_DIR=reports/junit && jest --ci --reporters=default --reporters=jest-junit --maxWorkers 2",
16+
"jest-ci": "mkdir -p reports/junit && export JEST_JUNIT_OUTPUT_DIR=reports/junit && jest --ci --reporters=default --reporters=jest-junit -w ${TEST_MAX_WORKERS:-100%}",
1717
"lint": "eslint public/app e2e/suite1 public/test --ext=.js,.ts,.tsx",
1818
"lint:fix": "yarn lint --fix",
1919
"packages:build": "lerna run clean && lerna run build --ignore @grafana-plugins/input-datasource",

0 commit comments

Comments
 (0)