From ea3e41ea62de4a78c301c129b1863d5d89fc7e38 Mon Sep 17 00:00:00 2001 From: Dimitris Sotirakis Date: Tue, 22 Feb 2022 20:06:14 +0200 Subject: [PATCH] CI: Add docs pipeline for `main` pipelines (#45740) * Add docs pipeline for main * Extract trigger docs * Change trigger for main --- .drone.star | 2 +- .drone.yml | 64 ++++++++++++++++++++++++++----- scripts/drone/pipelines/docs.star | 18 ++++----- scripts/drone/pipelines/main.star | 8 +++- scripts/drone/pipelines/pr.star | 8 +++- 5 files changed, 77 insertions(+), 23 deletions(-) diff --git a/.drone.star b/.drone.star index d2723f88be8..0829f79f299 100644 --- a/.drone.star +++ b/.drone.star @@ -14,7 +14,7 @@ load('scripts/drone/vault.star', 'secrets') def main(ctx): edition = 'oss' - return pr_pipelines(edition=edition) + docs_pipelines(edition=edition) + main_pipelines(edition=edition) + release_pipelines() + \ + return pr_pipelines(edition=edition) + main_pipelines(edition=edition) + release_pipelines() + \ publish_image_pipelines('public') + publish_image_pipelines('security') + \ publish_artifacts_pipelines('security') + publish_artifacts_pipelines('public') + \ publish_npm_pipelines('public') + publish_packages_pipeline() + \ diff --git a/.drone.yml b/.drone.yml index 0659a398acd..6982e8d30c3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -464,6 +464,59 @@ volumes: --- depends_on: [] kind: pipeline +name: main-docs +node: + type: no-parallel +platform: + arch: amd64 + os: linux +services: [] +steps: +- commands: + - mkdir -p bin + - curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v2.9.4/grabpl + - chmod +x bin/grabpl + image: byrnedo/alpine-curl:0.1.8 + name: grabpl +- commands: + - echo $DRONE_RUNNER_NAME + image: alpine:3.15 + name: identify-runner +- commands: + - make gen-go + - ./bin/grabpl gen-version --build-id ${DRONE_BUILD_NUMBER} + - yarn install --immutable + image: grafana/build-container:1.4.9 + name: initialize +- commands: + - yarn packages:build + - yarn packages:docsExtract + - yarn packages:docsToMarkdown + - ./scripts/ci-reference-docs-lint.sh ci + depends_on: + - initialize + image: grafana/build-container:1.4.9 + name: build-frontend-docs +- commands: + - mkdir -p /hugo/content/docs/grafana + - cp -r docs/sources/* /hugo/content/docs/grafana/latest/ + - cd /hugo && make prod + depends_on: + - build-frontend-docs + image: grafana/docs-base:latest + name: build-docs-website +trigger: + branch: main + event: + - push +type: docker +volumes: +- host: + path: /var/run/docker.sock + name: docker +--- +depends_on: [] +kind: pipeline name: main-test node: type: no-parallel @@ -802,15 +855,6 @@ steps: failure: ignore image: grafana/build-container:1.4.9 name: publish-frontend-metrics -- commands: - - yarn packages:build - - yarn packages:docsExtract - - yarn packages:docsToMarkdown - - ./scripts/ci-reference-docs-lint.sh ci - depends_on: - - initialize - image: grafana/build-container:1.4.9 - name: build-frontend-docs - commands: - ls dist/*.tar.gz* - cp dist/*.tar.gz* packaging/docker/ @@ -4261,6 +4305,6 @@ kind: secret name: gcp_upload_artifacts_key --- kind: signature -hmac: f209cfff82a4817d7bae67872ce1a34a4a26915451ae35b4f8c9848003b18b91 +hmac: db5cfbb53d8385e4eab31a818388c5c3cc57693e4bcd0764dcf058fc2aa93cbe ... diff --git a/scripts/drone/pipelines/docs.star b/scripts/drone/pipelines/docs.star index 6a18241d308..be19f140c73 100644 --- a/scripts/drone/pipelines/docs.star +++ b/scripts/drone/pipelines/docs.star @@ -23,9 +23,8 @@ load( 'pipeline', ) -ver_mode = 'pr' -def docs_pipelines(edition): +def docs_pipelines(edition, ver_mode, trigger): steps = [download_grabpl_step()] + initialize_step(edition, platform='linux', ver_mode=ver_mode) # Insert remaining steps @@ -34,8 +33,14 @@ def docs_pipelines(edition): build_docs_website_step(), ]) - trigger = { - 'event': [ + return pipeline( + name='{}-docs'.format(ver_mode), edition=edition, trigger=trigger, services=[], steps=steps, + ) + + +def trigger_docs(): + return { + 'event': [ 'pull_request', ], 'paths': { @@ -45,8 +50,3 @@ def docs_pipelines(edition): ], }, } - return [ - pipeline( - name='pr-docs', edition=edition, trigger=trigger, services=[], steps=steps, - ), - ] diff --git a/scripts/drone/pipelines/main.star b/scripts/drone/pipelines/main.star index 583f3854160..9220d81e366 100644 --- a/scripts/drone/pipelines/main.star +++ b/scripts/drone/pipelines/main.star @@ -18,7 +18,6 @@ load( 'e2e_tests_step', 'e2e_tests_artifacts', 'build_storybook_step', - 'build_frontend_docs_step', 'copy_packages_for_docker_step', 'build_docker_images_step', 'publish_images_step', @@ -55,6 +54,11 @@ load( 'drone_change_template', ) +load( + 'scripts/drone/pipelines/docs.star', + 'docs_pipelines', +) + ver_mode = 'main' def get_steps(edition, is_downstream=False): @@ -110,7 +114,6 @@ def get_steps(edition, is_downstream=False): store_storybook_step(edition=edition, ver_mode=ver_mode), test_a11y_frontend_step(ver_mode=ver_mode, edition=edition), frontend_metrics_step(edition=edition), - build_frontend_docs_step(edition=edition), copy_packages_for_docker_step(), build_docker_images_step(edition=edition, ver_mode=ver_mode, publish=False), build_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True, publish=False), @@ -171,6 +174,7 @@ def main_pipelines(edition): integration_test_steps.append(benchmark_ldap_step()) pipelines = [ + docs_pipelines(edition, ver_mode, trigger), pipeline( name='main-test', edition=edition, trigger=trigger, services=[], steps=[download_grabpl_step()] + initialize_step(edition, platform='linux', ver_mode=ver_mode) + test_steps, diff --git a/scripts/drone/pipelines/pr.star b/scripts/drone/pipelines/pr.star index c1cdf182d51..f60e3332fc0 100644 --- a/scripts/drone/pipelines/pr.star +++ b/scripts/drone/pipelines/pr.star @@ -45,6 +45,12 @@ load( 'drone_change_template', ) +load( + 'scripts/drone/pipelines/docs.star', + 'docs_pipelines', + 'trigger_docs', +) + ver_mode = 'pr' def pr_pipelines(edition): @@ -133,5 +139,5 @@ def pr_pipelines(edition): name='pr-integration-tests', edition=edition, trigger=trigger, services=services, steps=[download_grabpl_step()] + integration_test_steps, volumes=volumes, - ), + ), docs_pipelines(edition, ver_mode, trigger_docs()) ]