From 20f62e1841f98737530585afb89026f0f4ece892 Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Tue, 3 May 2022 12:54:47 +0100 Subject: [PATCH] CI: Split main tests pipeline (#48628) * Split tests pipeline * Rename dependencies --- .drone.yml | 99 +++++++++++++++++++++---------- scripts/drone/pipelines/main.star | 56 +++++++++++++---- 2 files changed, 112 insertions(+), 43 deletions(-) diff --git a/.drone.yml b/.drone.yml index 040fe7132c7..37882603361 100644 --- a/.drone.yml +++ b/.drone.yml @@ -656,7 +656,68 @@ volumes: --- depends_on: [] kind: pipeline -name: main-test +name: main-test-frontend +node: + type: no-parallel +platform: + arch: amd64 + os: linux +services: [] +steps: +- commands: + - echo $DRONE_RUNNER_NAME + image: alpine:3.15 + name: identify-runner +- commands: + - mkdir -p bin + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.41/grabpl + - chmod +x bin/grabpl + image: byrnedo/alpine-curl:0.1.8 + name: grabpl +- commands: + - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} + depends_on: + - grabpl + image: grafana/build-container:1.5.4 + name: gen-version +- commands: + - yarn install --immutable + depends_on: + - grabpl + image: grafana/build-container:1.5.4 + name: yarn-install +- commands: + - yarn run prettier:check + - yarn run lint + - yarn run i18n:compile + - yarn run typecheck + depends_on: + - yarn-install + environment: + TEST_MAX_WORKERS: 50% + image: grafana/build-container:1.5.4 + name: lint-frontend +- commands: + - yarn run ci:test-frontend + depends_on: + - yarn-install + environment: + TEST_MAX_WORKERS: 50% + image: grafana/build-container:1.5.4 + name: test-frontend +trigger: + branch: main + event: + - push +type: docker +volumes: +- host: + path: /var/run/docker.sock + name: docker +--- +depends_on: [] +kind: pipeline +name: main-test-backend node: type: no-parallel platform: @@ -684,12 +745,6 @@ steps: - make gen-go image: grafana/build-container:1.5.4 name: wire-install -- commands: - - yarn install --immutable - depends_on: - - grabpl - image: grafana/build-container:1.5.4 - name: yarn-install - commands: - ./bin/grabpl verify-drone depends_on: @@ -722,17 +777,6 @@ steps: CGO_ENABLED: "1" image: grafana/build-container:1.5.4 name: lint-backend -- commands: - - yarn run prettier:check - - yarn run lint - - yarn run i18n:compile - - yarn run typecheck - depends_on: - - yarn-install - environment: - TEST_MAX_WORKERS: 50% - image: grafana/build-container:1.5.4 - name: lint-frontend - commands: - ./bin/grabpl test-backend --edition oss depends_on: @@ -745,14 +789,6 @@ steps: - wire-install image: grafana/build-container:1.5.4 name: test-backend-integration -- commands: - - yarn run ci:test-frontend - depends_on: - - yarn-install - environment: - TEST_MAX_WORKERS: 50% - image: grafana/build-container:1.5.4 - name: test-frontend trigger: branch: main event: @@ -1266,7 +1302,8 @@ volumes: medium: memory --- depends_on: -- main-test +- main-test-frontend +- main-test-backend - main-build-e2e-publish - main-integration-tests kind: pipeline @@ -1355,7 +1392,8 @@ trigger: type: docker --- depends_on: -- main-test +- main-test-frontend +- main-test-backend - main-build-e2e-publish - main-integration-tests - main-windows @@ -1409,7 +1447,8 @@ volumes: name: docker --- depends_on: -- main-test +- main-test-frontend +- main-test-backend - main-build-e2e-publish - main-integration-tests - main-windows @@ -4614,6 +4653,6 @@ kind: secret name: gcp_upload_artifacts_key --- kind: signature -hmac: 6be0c058bd66d0282afe37bd5af923f345ca71ec0fd874514ae08f759e23adfd +hmac: 650895e4350d8423d0a77aa728ed07696ee301ad440b9982e336a05bb364cdf8 ... diff --git a/scripts/drone/pipelines/main.star b/scripts/drone/pipelines/main.star index f7cce1a56b3..6821ff0ed70 100644 --- a/scripts/drone/pipelines/main.star +++ b/scripts/drone/pipelines/main.star @@ -69,9 +69,47 @@ load('scripts/drone/vault.star', 'from_secret') ver_mode = 'main' +trigger = { + 'event': ['push',], + 'branch': 'main', +} + +def main_test_frontend(): + init_steps = [ + identify_runner_step(), + download_grabpl_step(), + gen_version_step(ver_mode), + yarn_install_step(), + ] + test_steps = [ + lint_frontend_step(), + test_frontend_step(), + ] + return pipeline( + name='main-test-frontend', edition="oss", trigger=trigger, services=[], steps=init_steps + test_steps, + ) + +def main_test_backend(): + init_steps = [ + identify_runner_step(), + download_grabpl_step(), + gen_version_step(ver_mode), + wire_install_step(), + ] + test_steps = [ + lint_drone_step(), + codespell_step(), + shellcheck_step(), + lint_backend_step(edition="oss"), + test_backend_step(edition="oss"), + test_backend_integration_step(edition="oss"), + ] + return pipeline( + name='main-test-backend', edition="oss", trigger=trigger, services=[], steps=init_steps + test_steps, + ) + def get_steps(edition): - services = integration_test_services(edition) init_steps = [ identify_runner_step(), download_grabpl_step(), @@ -170,10 +208,6 @@ def trigger_test_release(): def main_pipelines(edition): services = integration_test_services(edition) volumes = integration_test_services_volumes() - trigger = { - 'event': ['push',], - 'branch': 'main', - } drone_change_trigger = { 'event': ['push',], 'branch': 'main', @@ -191,11 +225,7 @@ def main_pipelines(edition): } init_steps, test_steps, build_steps, integration_test_steps, windows_steps, store_steps = get_steps(edition=edition) - pipelines = [docs_pipelines(edition, ver_mode, trigger), pipeline( - name='main-test', edition=edition, trigger=trigger, services=[], - steps=init_steps + test_steps, - volumes=[], - ), pipeline( + pipelines = [docs_pipelines(edition, ver_mode, trigger), main_test_frontend(), main_test_backend(), pipeline( name='main-build-e2e-publish', edition=edition, trigger=trigger, services=[], steps=init_steps + build_steps, volumes=volumes, @@ -206,17 +236,17 @@ def main_pipelines(edition): ), pipeline( name='main-windows', edition=edition, trigger=dict(trigger, repo=['grafana/grafana']), steps=[identify_runner_step('windows')] + windows_steps, - depends_on=['main-test', 'main-build-e2e-publish', 'main-integration-tests'], platform='windows', + depends_on=['main-test-frontend', 'main-test-backend', 'main-build-e2e-publish', 'main-integration-tests'], platform='windows', ), notify_pipeline( name='notify-drone-changes', slack_channel='slack-webhooks-test', trigger=drone_change_trigger, template=drone_change_template, secret='drone-changes-webhook', ), pipeline( name='main-publish', edition=edition, trigger=dict(trigger, repo=['grafana/grafana']), steps=[download_grabpl_step(), identify_runner_step(),] + store_steps, - depends_on=['main-test', 'main-build-e2e-publish', 'main-integration-tests', 'main-windows', ], + depends_on=['main-test-frontend', 'main-test-backend', 'main-build-e2e-publish', 'main-integration-tests', 'main-windows', ], ), notify_pipeline( name='main-notify', slack_channel='grafana-ci-notifications', trigger=dict(trigger, status=['failure']), - depends_on=['main-test', 'main-build-e2e-publish', 'main-integration-tests', 'main-windows', 'main-publish'], + depends_on=['main-test-frontend', 'main-test-backend', 'main-build-e2e-publish', 'main-integration-tests', 'main-windows', 'main-publish'], template=failure_template, secret='slack_webhook' )]