Remove drone & dead code in pkg/build; update go modules (#109935)
* remove drone & dead code in pkg/build; update go modules * remove .drone.star * Remove drone scripts and drone references in Makefile * make update-workspace * remove deadcode tool * Remove daggerbuild/scripts: deadcode * Remove drone files / folders in CODEOWNERS * make update-workspace * remove more dead code
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
"""
|
||||
Utilities / functions for working with dagger pipelines
|
||||
"""
|
||||
|
||||
def with_dagger_install(commands = [], dagger_version = ""):
|
||||
return [
|
||||
"wget -qO- https://github.com/dagger/dagger/releases/download/{}/dagger_{}_linux_amd64.tar.gz | tar zx -C /bin".format(dagger_version, dagger_version),
|
||||
"apk add docker",
|
||||
] + commands
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ensure DRONE_SERVER and DRONE_TOKEN env variables are set
|
||||
if [ -z "$DRONE_SERVER" ]; then
|
||||
echo "DRONE_SERVER environment variable is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$DRONE_TOKEN" ]; then
|
||||
echo "DRONE_TOKEN environment variable is not set."
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,179 +0,0 @@
|
||||
"""
|
||||
This module provides functions for cronjob pipelines and steps used within.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load("scripts/drone/vault.star", "from_secret")
|
||||
|
||||
aquasec_trivy_image = "aquasec/trivy:0.21.0"
|
||||
|
||||
def cronjobs():
|
||||
return [
|
||||
scan_docker_image_pipeline("latest"),
|
||||
scan_docker_image_pipeline("main"),
|
||||
scan_docker_image_pipeline("latest-ubuntu"),
|
||||
scan_docker_image_pipeline("main-ubuntu"),
|
||||
scan_build_test_publish_docker_image_pipeline(),
|
||||
]
|
||||
|
||||
def authenticate_gcr_step():
|
||||
return {
|
||||
"name": "authenticate-gcr",
|
||||
"image": "docker:dind",
|
||||
"commands": ["echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io"],
|
||||
"environment": {
|
||||
"GCR_CREDENTIALS": from_secret("gcr_credentials"),
|
||||
},
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}, {"name": "config", "path": "/root/.docker/"}],
|
||||
}
|
||||
|
||||
def cron_job_pipeline(cronName, name, steps):
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "amd64",
|
||||
},
|
||||
"name": name,
|
||||
"trigger": {
|
||||
"event": "cron",
|
||||
"cron": cronName,
|
||||
},
|
||||
"clone": {
|
||||
"retries": 3,
|
||||
},
|
||||
"steps": steps,
|
||||
"volumes": [
|
||||
{
|
||||
"name": "docker",
|
||||
"host": {
|
||||
"path": "/var/run/docker.sock",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "config",
|
||||
"temp": {},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
def scan_docker_image_pipeline(tag):
|
||||
"""Generates a cronjob pipeline for nightly scans of grafana Docker images.
|
||||
|
||||
Args:
|
||||
tag: determines which image tag is scanned.
|
||||
|
||||
Returns:
|
||||
Drone cronjob pipeline.
|
||||
"""
|
||||
docker_image = "grafana/grafana:{}".format(tag)
|
||||
|
||||
return cron_job_pipeline(
|
||||
cronName = "nightly",
|
||||
name = "scan-" + docker_image + "-image",
|
||||
steps = [
|
||||
authenticate_gcr_step(),
|
||||
scan_docker_image_unknown_low_medium_vulnerabilities_step(docker_image),
|
||||
scan_docker_image_high_critical_vulnerabilities_step(docker_image),
|
||||
slack_job_failed_step("grafana-backend-ops", docker_image),
|
||||
],
|
||||
)
|
||||
|
||||
def scan_build_test_publish_docker_image_pipeline():
|
||||
"""Generates a cronjob pipeline for nightly scans of grafana Docker images.
|
||||
|
||||
Returns:
|
||||
Drone cronjob pipeline.
|
||||
"""
|
||||
|
||||
return cron_job_pipeline(
|
||||
cronName = "nightly",
|
||||
name = "scan-build-test-and-publish-docker-images",
|
||||
steps = [
|
||||
authenticate_gcr_step(),
|
||||
scan_docker_image_unknown_low_medium_vulnerabilities_step("all"),
|
||||
scan_docker_image_high_critical_vulnerabilities_step("all"),
|
||||
slack_job_failed_step("grafana-backend-ops", "build-images"),
|
||||
],
|
||||
)
|
||||
|
||||
def scan_docker_image_unknown_low_medium_vulnerabilities_step(docker_image):
|
||||
"""Generates a step for scans of Grafana Docker images.
|
||||
|
||||
Args:
|
||||
docker_image: determines which image is scanned.
|
||||
|
||||
Returns:
|
||||
Drone cronjob step .
|
||||
"""
|
||||
|
||||
cmds = []
|
||||
if docker_image == "all":
|
||||
for key in images:
|
||||
cmds = cmds + ["trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM " + images[key]]
|
||||
else:
|
||||
cmds = ["trivy image --exit-code 0 --severity UNKNOWN,LOW,MEDIUM " + docker_image]
|
||||
return {
|
||||
"name": "scan-unknown-low-medium-vulnerabilities",
|
||||
"image": aquasec_trivy_image,
|
||||
"commands": cmds,
|
||||
"depends_on": ["authenticate-gcr"],
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}, {"name": "config", "path": "/root/.docker/"}],
|
||||
}
|
||||
|
||||
def scan_docker_image_high_critical_vulnerabilities_step(docker_image):
|
||||
"""Generates a step for scans of Grafana Docker images.
|
||||
|
||||
Args:
|
||||
docker_image: determines which image is scanned.
|
||||
|
||||
Returns:
|
||||
Drone cronjob step .
|
||||
"""
|
||||
|
||||
cmds = []
|
||||
if docker_image == "all":
|
||||
for key in images:
|
||||
cmds = cmds + ["trivy --exit-code 1 --severity HIGH,CRITICAL " + images[key]]
|
||||
else:
|
||||
cmds = ["trivy image --exit-code 1 --severity HIGH,CRITICAL " + docker_image]
|
||||
return {
|
||||
"name": "scan-high-critical-vulnerabilities",
|
||||
"image": aquasec_trivy_image,
|
||||
"commands": cmds,
|
||||
"depends_on": ["authenticate-gcr"],
|
||||
"environment": {
|
||||
"GOOGLE_APPLICATION_CREDENTIALS": from_secret("gcr_credentials_json"),
|
||||
},
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}, {"name": "config", "path": "/root/.docker/"}],
|
||||
}
|
||||
|
||||
def slack_job_failed_step(channel, image):
|
||||
return {
|
||||
"name": "slack-notify-failure",
|
||||
"image": images["plugins_slack"],
|
||||
"settings": {
|
||||
"webhook": from_secret("slack_webhook_backend"),
|
||||
"channel": channel,
|
||||
"template": "Nightly docker image scan job for " +
|
||||
image +
|
||||
" failed: {{build.link}}",
|
||||
},
|
||||
"when": {"status": "failure"},
|
||||
}
|
||||
|
||||
def post_to_grafana_com_step():
|
||||
return {
|
||||
"name": "post-to-grafana-com",
|
||||
"image": images["publish"],
|
||||
"environment": {
|
||||
"GRAFANA_COM_API_KEY": from_secret("grafana_api_key"),
|
||||
"GCP_KEY": from_secret("gcp_key"),
|
||||
},
|
||||
"depends_on": ["compile-build-cmd"],
|
||||
"commands": ["./bin/build publish grafana-com --edition oss"],
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
"""
|
||||
This module returns all the pipelines used in the event of pushes to the main branch.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/pipelines/build.star",
|
||||
"build_e2e",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/pipelines/docs.star",
|
||||
"docs_pipelines",
|
||||
"trigger_docs_main",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/pipelines/trigger_downstream.star",
|
||||
"enterprise_downstream_pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"failure_template",
|
||||
"notify_pipeline",
|
||||
)
|
||||
|
||||
ver_mode = "main"
|
||||
trigger = {
|
||||
"event": [
|
||||
"push",
|
||||
],
|
||||
"branch": "main",
|
||||
"paths": {
|
||||
"exclude": [
|
||||
"*.md",
|
||||
"docs/**",
|
||||
"latest.json",
|
||||
],
|
||||
},
|
||||
"repo": [
|
||||
"grafana/grafana",
|
||||
],
|
||||
}
|
||||
|
||||
def main_pipelines():
|
||||
# This is how we should define any new pipelines. At some point we should update existing ones.
|
||||
# Let's make an effort to reduce the amount of string constants in "depends_on" lists.
|
||||
pipelines = [
|
||||
docs_pipelines(ver_mode, trigger_docs_main()),
|
||||
build_e2e(trigger, ver_mode),
|
||||
enterprise_downstream_pipeline(),
|
||||
notify_pipeline(
|
||||
name = "main-notify",
|
||||
slack_channel = "grafana-ci-notifications",
|
||||
trigger = dict(trigger, status = ["failure"]),
|
||||
depends_on = [
|
||||
"main-build-e2e-publish",
|
||||
],
|
||||
template = failure_template,
|
||||
secret = "slack_webhook",
|
||||
),
|
||||
]
|
||||
|
||||
return pipelines
|
||||
@@ -1,87 +0,0 @@
|
||||
"""
|
||||
This module returns all pipelines used in the event of a pull request.
|
||||
It also includes a function generating a PR trigger from a list of included and excluded paths.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/pipelines/build.star",
|
||||
"build_e2e",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/pipelines/docs.star",
|
||||
"docs_pipelines",
|
||||
"trigger_docs_pr",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/pipelines/verify_drone.star",
|
||||
"verify_drone",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/pipelines/verify_starlark.star",
|
||||
"verify_starlark",
|
||||
)
|
||||
|
||||
ver_mode = "pr"
|
||||
trigger = {
|
||||
"event": [
|
||||
"pull_request",
|
||||
],
|
||||
"paths": {
|
||||
"exclude": [
|
||||
"*.md",
|
||||
"docs/**",
|
||||
"latest.json",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def pr_pipelines():
|
||||
return [
|
||||
verify_drone(
|
||||
get_pr_trigger(
|
||||
include_paths = ["scripts/drone/**", ".drone.yml", ".drone.star"],
|
||||
),
|
||||
ver_mode,
|
||||
),
|
||||
verify_starlark(
|
||||
get_pr_trigger(
|
||||
include_paths = ["scripts/drone/**", ".drone.star"],
|
||||
),
|
||||
ver_mode,
|
||||
),
|
||||
build_e2e(trigger, ver_mode),
|
||||
docs_pipelines(ver_mode, trigger_docs_pr()),
|
||||
]
|
||||
|
||||
def get_pr_trigger(include_paths = None, exclude_paths = None):
|
||||
"""Generates a trigger filter from the lists of included and excluded path patterns.
|
||||
|
||||
This function is primarily intended to generate a trigger for code changes
|
||||
as the patterns 'docs/**' and '*.md' are always excluded.
|
||||
|
||||
Args:
|
||||
include_paths: a list of path patterns using the same syntax as gitignore.
|
||||
Changes affecting files matching these path patterns trigger the pipeline.
|
||||
exclude_paths: a list of path patterns using the same syntax as gitignore.
|
||||
Changes affecting files matching these path patterns do not trigger the pipeline.
|
||||
|
||||
Returns:
|
||||
Drone trigger.
|
||||
"""
|
||||
paths_ex = ["docs/**", "*.md"]
|
||||
paths_in = []
|
||||
if include_paths:
|
||||
for path in include_paths:
|
||||
paths_in.extend([path])
|
||||
if exclude_paths:
|
||||
for path in exclude_paths:
|
||||
paths_ex.extend([path])
|
||||
return {
|
||||
"event": [
|
||||
"pull_request",
|
||||
],
|
||||
"paths": {
|
||||
"exclude": paths_ex,
|
||||
"include": paths_in,
|
||||
},
|
||||
}
|
||||
@@ -1,279 +0,0 @@
|
||||
"""
|
||||
This module returns all the pipelines used in the event of a release along with supporting functions.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/github.star",
|
||||
"github_app_generate_token_step",
|
||||
"github_app_pipeline_volumes",
|
||||
"github_app_step_volumes",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"compile_build_cmd",
|
||||
"publish_grafanacom_step",
|
||||
"publish_linux_packages_step",
|
||||
"verify_grafanacom_step",
|
||||
"yarn_install_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
"gcp_grafanauploads_base64",
|
||||
"npm_token",
|
||||
"prerelease_bucket",
|
||||
"rgm_gcp_key_base64",
|
||||
)
|
||||
|
||||
ver_mode = "release"
|
||||
semver_regex = r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
|
||||
|
||||
def retrieve_npm_packages_step():
|
||||
return {
|
||||
"name": "retrieve-npm-packages",
|
||||
"image": images["publish"],
|
||||
"depends_on": [
|
||||
"compile-build-cmd",
|
||||
"yarn-install",
|
||||
],
|
||||
"failure": "ignore",
|
||||
"environment": {
|
||||
"GCP_KEY": from_secret(gcp_grafanauploads_base64),
|
||||
"PRERELEASE_BUCKET": from_secret(prerelease_bucket),
|
||||
},
|
||||
"commands": ["./bin/build artifacts npm retrieve --tag ${DRONE_TAG}"],
|
||||
}
|
||||
|
||||
def release_pr_step(depends_on = []):
|
||||
return {
|
||||
"name": "create-release-pr",
|
||||
"image": images["curl"],
|
||||
"depends_on": depends_on,
|
||||
"environment": {
|
||||
"GH_CLI_URL": "https://github.com/cli/cli/releases/download/v2.50.0/gh_2.50.0_linux_amd64.tar.gz",
|
||||
},
|
||||
"commands": [
|
||||
"export GITHUB_TOKEN=$(cat /github-app/token)",
|
||||
"apk add perl",
|
||||
"v_target=`echo $${{TAG}} | perl -pe 's/{}/v\\1.\\2.x/'`".format(semver_regex),
|
||||
# Install gh CLI
|
||||
"curl -L $${GH_CLI_URL} | tar -xz --strip-components=1 -C /usr",
|
||||
# Run the release-pr workflow
|
||||
"gh workflow run " +
|
||||
"-f dry_run=$${DRY_RUN} " +
|
||||
"-f version=$${TAG} " +
|
||||
# If the submitter has set a target branch, then use that, otherwise use the default
|
||||
"-f target=$${v_target} " +
|
||||
"-f latest=$${LATEST} " +
|
||||
"--repo=grafana/grafana release-pr.yml",
|
||||
],
|
||||
"volumes": github_app_step_volumes(),
|
||||
}
|
||||
|
||||
def release_npm_packages_step():
|
||||
return {
|
||||
"name": "release-npm-packages",
|
||||
"image": images["node"],
|
||||
"depends_on": [
|
||||
"compile-build-cmd",
|
||||
"retrieve-npm-packages",
|
||||
],
|
||||
"failure": "ignore",
|
||||
"environment": {
|
||||
"NPM_TOKEN": from_secret(npm_token),
|
||||
},
|
||||
"commands": ["./bin/build artifacts npm release --tag ${DRONE_TAG}"],
|
||||
}
|
||||
|
||||
def publish_artifacts_step():
|
||||
return {
|
||||
"name": "publish-artifacts",
|
||||
"image": images["publish"],
|
||||
"environment": {
|
||||
"GCP_KEY": from_secret(gcp_grafanauploads_base64),
|
||||
"PRERELEASE_BUCKET": from_secret("prerelease_bucket"),
|
||||
},
|
||||
"commands": [
|
||||
"./bin/build artifacts packages --artifacts-editions=oss --tag $${DRONE_TAG} --src-bucket $${PRERELEASE_BUCKET}",
|
||||
],
|
||||
"depends_on": ["compile-build-cmd"],
|
||||
}
|
||||
|
||||
def publish_storybook_step():
|
||||
return {
|
||||
"name": "publish-storybook",
|
||||
"image": images["publish"],
|
||||
"environment": {
|
||||
"GCP_KEY": from_secret(gcp_grafanauploads_base64),
|
||||
"PRERELEASE_BUCKET": from_secret("prerelease_bucket"),
|
||||
},
|
||||
"commands": [
|
||||
"./bin/build artifacts storybook --tag ${DRONE_TAG}",
|
||||
],
|
||||
"depends_on": ["compile-build-cmd"],
|
||||
}
|
||||
|
||||
def publish_artifacts_pipelines(mode):
|
||||
"""Published artifacts after they've been stored and tested in prerelease buckets.
|
||||
|
||||
Args:
|
||||
mode: public or security.
|
||||
Defaults to ''.
|
||||
|
||||
Returns:
|
||||
List of Drone pipelines.
|
||||
"""
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": [mode],
|
||||
}
|
||||
steps = [
|
||||
compile_build_cmd(),
|
||||
publish_artifacts_step(),
|
||||
publish_storybook_step(),
|
||||
github_app_generate_token_step(),
|
||||
release_pr_step(depends_on = ["publish-artifacts", github_app_generate_token_step()["name"]]),
|
||||
]
|
||||
|
||||
return [
|
||||
pipeline(
|
||||
name = "create-release-pr",
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": "release-pr",
|
||||
},
|
||||
steps = [
|
||||
release_pr_step(),
|
||||
],
|
||||
volumes = github_app_pipeline_volumes(),
|
||||
),
|
||||
pipeline(
|
||||
name = "publish-artifacts-{}".format(mode),
|
||||
trigger = trigger,
|
||||
steps = steps,
|
||||
environment = {"EDITION": "oss"},
|
||||
volumes = github_app_pipeline_volumes(),
|
||||
),
|
||||
]
|
||||
|
||||
def publish_packages_pipeline():
|
||||
"""Generates pipelines used for publishing packages for OSS.
|
||||
|
||||
Returns:
|
||||
List of Drone pipelines. One for each of OSS and enterprise packages.
|
||||
"""
|
||||
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": ["public"],
|
||||
}
|
||||
oss_steps = [
|
||||
compile_build_cmd(),
|
||||
publish_linux_packages_step(package_manager = "deb"),
|
||||
publish_linux_packages_step(package_manager = "rpm"),
|
||||
publish_grafanacom_step(ver_mode = "release"),
|
||||
verify_grafanacom_step(),
|
||||
]
|
||||
|
||||
deps = [
|
||||
"publish-artifacts-public",
|
||||
"publish-docker-public",
|
||||
]
|
||||
|
||||
return [
|
||||
pipeline(
|
||||
name = "verify-grafanacom-artifacts",
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": "verify-grafanacom-artifacts",
|
||||
},
|
||||
steps = [
|
||||
verify_grafanacom_step(depends_on = []),
|
||||
],
|
||||
),
|
||||
pipeline(
|
||||
name = "publish-packages",
|
||||
trigger = trigger,
|
||||
steps = oss_steps,
|
||||
depends_on = deps,
|
||||
environment = {"EDITION": "oss"},
|
||||
),
|
||||
pipeline(
|
||||
name = "publish-grafanacom",
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": "publish-grafanacom",
|
||||
},
|
||||
steps = [
|
||||
compile_build_cmd(),
|
||||
publish_grafanacom_step(ver_mode = "release", depends_on = ["compile-build-cmd"]),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
def publish_npm_pipelines():
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": ["public"],
|
||||
}
|
||||
steps = [
|
||||
compile_build_cmd(),
|
||||
yarn_install_step(),
|
||||
retrieve_npm_packages_step(),
|
||||
release_npm_packages_step(),
|
||||
]
|
||||
|
||||
return [
|
||||
pipeline(
|
||||
name = "publish-npm-packages-public",
|
||||
trigger = trigger,
|
||||
steps = steps,
|
||||
environment = {"EDITION": "oss"},
|
||||
),
|
||||
]
|
||||
|
||||
def verify_release_pipeline(
|
||||
name = "verify-prerelease-assets",
|
||||
bucket = from_secret(prerelease_bucket),
|
||||
gcp_key = from_secret(rgm_gcp_key_base64),
|
||||
version = "${DRONE_TAG}",
|
||||
trigger = {},
|
||||
depends_on = [
|
||||
"release-build-e2e-publish",
|
||||
]):
|
||||
"""
|
||||
Runs a script that 'gsutil stat's every artifact that should have been produced by the pre-release process.
|
||||
|
||||
Returns:
|
||||
A single Drone pipeline that runs the script.
|
||||
"""
|
||||
step = {
|
||||
"name": "gsutil-stat",
|
||||
"depends_on": ["clone"],
|
||||
"image": images["cloudsdk"],
|
||||
"environment": {
|
||||
"BUCKET": bucket,
|
||||
"GCP_KEY": gcp_key,
|
||||
},
|
||||
"commands": [
|
||||
"apt-get update && apt-get install -yq gettext",
|
||||
"printenv GCP_KEY | base64 -d > /tmp/key.json",
|
||||
"gcloud auth activate-service-account --key-file=/tmp/key.json",
|
||||
"./scripts/list-release-artifacts.sh {} | xargs -n1 gsutil stat >> /tmp/stat.log".format(version),
|
||||
"! cat /tmp/stat.log | grep \"No URLs matched\"",
|
||||
],
|
||||
}
|
||||
return pipeline(
|
||||
depends_on = depends_on,
|
||||
name = name,
|
||||
trigger = trigger,
|
||||
steps = [step],
|
||||
)
|
||||
@@ -1,47 +0,0 @@
|
||||
"""
|
||||
This module returns all the pipelines used in the event of pushes to an RRC branch.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"enterprise_downstream_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
ver_mode = "rrc"
|
||||
trigger = {
|
||||
"ref": {
|
||||
"include": [
|
||||
"refs/tags/rrc*",
|
||||
],
|
||||
},
|
||||
"branch": [
|
||||
"instant",
|
||||
"fast",
|
||||
"steady",
|
||||
"slow",
|
||||
],
|
||||
}
|
||||
|
||||
def rrc_patch_pipelines():
|
||||
pipelines = [
|
||||
rrc_enterprise_downstream_pipeline(trigger = trigger),
|
||||
]
|
||||
|
||||
return pipelines
|
||||
|
||||
def rrc_enterprise_downstream_pipeline(trigger):
|
||||
# Triggers a downstream pipeline in the grafana-enterprise repository for the rrc branch
|
||||
environment = {"EDITION": "oss"}
|
||||
steps = [
|
||||
enterprise_downstream_step(ver_mode = ver_mode),
|
||||
]
|
||||
return pipeline(
|
||||
name = "rrc-trigger-downstream",
|
||||
trigger = trigger,
|
||||
steps = steps,
|
||||
environment = environment,
|
||||
)
|
||||
@@ -1,170 +0,0 @@
|
||||
"""This module contains the comprehensive build pipeline."""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/github.star",
|
||||
"github_app_generate_token_step",
|
||||
"github_app_pipeline_volumes",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"build_frontend_package_step",
|
||||
"build_storybook_step",
|
||||
"build_test_plugins_step",
|
||||
"cloud_plugins_e2e_tests_step",
|
||||
"compile_build_cmd",
|
||||
"download_grabpl_step",
|
||||
"e2e_tests_artifacts",
|
||||
"enterprise_downstream_step",
|
||||
"frontend_metrics_step",
|
||||
"grafana_server_step",
|
||||
"identify_runner_step",
|
||||
"playwright_e2e_report_post_link",
|
||||
"playwright_e2e_report_upload",
|
||||
"playwright_e2e_tests_step",
|
||||
"publish_images_step",
|
||||
"release_canary_npm_packages_step",
|
||||
"store_storybook_step",
|
||||
"test_a11y_frontend_step",
|
||||
"trigger_oss",
|
||||
"update_package_json_version",
|
||||
"upload_cdn_step",
|
||||
"upload_packages_step",
|
||||
"verify_gen_cue_step",
|
||||
"verify_gen_jsonnet_step",
|
||||
"yarn_install_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/rgm.star",
|
||||
"rgm_artifacts_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
# This function isn't actually unused but I don't know why the linter thinks it is...
|
||||
# @unused
|
||||
def build_e2e(trigger, ver_mode):
|
||||
"""Perform e2e building, testing, and publishing.
|
||||
|
||||
Args:
|
||||
trigger: controls which events can trigger the pipeline execution.
|
||||
ver_mode: used in the naming of the pipeline. Either 'pr' or 'main'.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
|
||||
environment = {"EDITION": "oss"}
|
||||
init_steps = [
|
||||
github_app_generate_token_step(),
|
||||
identify_runner_step(),
|
||||
download_grabpl_step(),
|
||||
compile_build_cmd(),
|
||||
verify_gen_cue_step(),
|
||||
verify_gen_jsonnet_step(),
|
||||
yarn_install_step(),
|
||||
]
|
||||
|
||||
build_steps = []
|
||||
|
||||
create_packages = rgm_artifacts_step(
|
||||
artifacts = [
|
||||
"targz:grafana:linux/amd64",
|
||||
"targz:grafana:linux/arm64",
|
||||
"targz:grafana:linux/arm/v7",
|
||||
"docker:grafana:linux/amd64",
|
||||
"docker:grafana:linux/amd64:ubuntu",
|
||||
"docker:grafana:linux/arm64",
|
||||
"docker:grafana:linux/arm64:ubuntu",
|
||||
"docker:grafana:linux/arm/v7",
|
||||
"docker:grafana:linux/arm/v7:ubuntu",
|
||||
],
|
||||
file = "packages.txt",
|
||||
tag_format = "{{ .version_base }}-{{ .buildID }}-{{ .arch }}",
|
||||
ubuntu_tag_format = "{{ .version_base }}-{{ .buildID }}-ubuntu-{{ .arch }}",
|
||||
)
|
||||
|
||||
publish_docker = publish_images_step(
|
||||
depends_on = [create_packages["name"]],
|
||||
docker_repo = "grafana",
|
||||
trigger = trigger_oss,
|
||||
ver_mode = ver_mode,
|
||||
)
|
||||
|
||||
if ver_mode == "pr":
|
||||
build_steps.extend(
|
||||
[
|
||||
build_frontend_package_step(),
|
||||
enterprise_downstream_step(ver_mode = ver_mode),
|
||||
],
|
||||
)
|
||||
else:
|
||||
# The only other event or "ver_mode" where this is used is 'main'
|
||||
update_package_json = update_package_json_version()
|
||||
create_packages["depends_on"] = [update_package_json["name"]]
|
||||
|
||||
build_steps.extend([
|
||||
update_package_json,
|
||||
build_frontend_package_step(depends_on = ["update-package-json-version"]),
|
||||
])
|
||||
|
||||
build_steps.extend(
|
||||
[
|
||||
create_packages,
|
||||
publish_docker,
|
||||
build_test_plugins_step(),
|
||||
grafana_server_step(),
|
||||
# Note: Main E2E test suites (dashboards, panels, smoke-tests, various) have been migrated to GitHub Actions
|
||||
# Only keeping tests that are not yet covered by GitHub Actions
|
||||
cloud_plugins_e2e_tests_step(
|
||||
"cloud-plugins-suite",
|
||||
cloud = "azure",
|
||||
trigger = trigger_oss,
|
||||
),
|
||||
playwright_e2e_tests_step(),
|
||||
playwright_e2e_report_upload(),
|
||||
playwright_e2e_report_post_link(),
|
||||
e2e_tests_artifacts(), # Collects artifacts from remaining E2E tests
|
||||
build_storybook_step(ver_mode = ver_mode),
|
||||
test_a11y_frontend_step(ver_mode = ver_mode),
|
||||
],
|
||||
)
|
||||
|
||||
if ver_mode == "main":
|
||||
build_steps.extend(
|
||||
[
|
||||
store_storybook_step(trigger = trigger_oss, ver_mode = ver_mode),
|
||||
frontend_metrics_step(trigger = trigger_oss),
|
||||
publish_images_step(
|
||||
depends_on = [create_packages["name"]],
|
||||
docker_repo = "grafana-oss",
|
||||
trigger = trigger_oss,
|
||||
ver_mode = ver_mode,
|
||||
),
|
||||
release_canary_npm_packages_step(trigger = trigger_oss),
|
||||
upload_packages_step(
|
||||
depends_on = [create_packages["name"]],
|
||||
trigger = trigger_oss,
|
||||
ver_mode = ver_mode,
|
||||
),
|
||||
upload_cdn_step(
|
||||
depends_on = [create_packages["name"]],
|
||||
trigger = trigger_oss,
|
||||
ver_mode = ver_mode,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
publish_suffix = ""
|
||||
if ver_mode == "main":
|
||||
publish_suffix = "-publish"
|
||||
|
||||
return pipeline(
|
||||
name = "{}-build-e2e{}".format(ver_mode, publish_suffix),
|
||||
environment = environment,
|
||||
services = [],
|
||||
steps = init_steps + build_steps,
|
||||
trigger = trigger,
|
||||
volumes = github_app_pipeline_volumes(),
|
||||
)
|
||||
@@ -1,84 +0,0 @@
|
||||
"""
|
||||
This module returns all the pipelines used in the event of documentation changes along with supporting functions.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"build_docs_website_step",
|
||||
"identify_runner_step",
|
||||
"verify_gen_cue_step",
|
||||
"yarn_install_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
docs_paths = {
|
||||
"include": [
|
||||
"*.md",
|
||||
"docs/**",
|
||||
"packages/**/*.md",
|
||||
"latest.json",
|
||||
],
|
||||
}
|
||||
|
||||
def docs_pipelines(ver_mode, trigger):
|
||||
environment = {"EDITION": "oss"}
|
||||
steps = [
|
||||
identify_runner_step(),
|
||||
yarn_install_step(),
|
||||
lint_docs(),
|
||||
build_docs_website_step(),
|
||||
verify_gen_cue_step(),
|
||||
]
|
||||
|
||||
return pipeline(
|
||||
name = "{}-docs".format(ver_mode),
|
||||
trigger = trigger,
|
||||
services = [],
|
||||
steps = steps,
|
||||
environment = environment,
|
||||
)
|
||||
|
||||
def lint_docs():
|
||||
return {
|
||||
"name": "lint-docs",
|
||||
"image": images["node"],
|
||||
"depends_on": [
|
||||
"yarn-install",
|
||||
],
|
||||
"environment": {
|
||||
"NODE_OPTIONS": "--max_old_space_size=8192",
|
||||
},
|
||||
"commands": [
|
||||
"yarn run prettier:checkDocs",
|
||||
],
|
||||
}
|
||||
|
||||
def trigger_docs_main():
|
||||
return {
|
||||
"branch": "main",
|
||||
"event": [
|
||||
"push",
|
||||
],
|
||||
"repo": [
|
||||
"grafana/grafana",
|
||||
],
|
||||
"paths": docs_paths,
|
||||
}
|
||||
|
||||
def trigger_docs_pr():
|
||||
return {
|
||||
"event": [
|
||||
"pull_request",
|
||||
],
|
||||
"repo": [
|
||||
"grafana/grafana",
|
||||
],
|
||||
"paths": docs_paths,
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
"""
|
||||
This module returns the pipeline used for publishing Docker images and its steps.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"compile_build_cmd",
|
||||
"download_grabpl_step",
|
||||
"fetch_images_step",
|
||||
"identify_runner_step",
|
||||
"publish_images_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
)
|
||||
|
||||
def publish_image_public_step():
|
||||
"""Returns a step which publishes images
|
||||
|
||||
Returns:
|
||||
A drone step which publishes Docker images for a public release.
|
||||
"""
|
||||
command = """
|
||||
bash -c '
|
||||
IMAGE_TAG=$(echo "$${TAG}" | sed -e "s/+/-/g")
|
||||
debug=
|
||||
if [[ -n $${DRY_RUN} ]]; then debug=echo; fi
|
||||
docker login -u $${DOCKER_USER} -p $${DOCKER_PASSWORD}
|
||||
|
||||
# Push the grafana-image-tags images
|
||||
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-amd64
|
||||
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-arm64
|
||||
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
|
||||
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64
|
||||
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64
|
||||
$$debug docker push grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
|
||||
|
||||
# Create the grafana manifests
|
||||
$$debug docker manifest create grafana/grafana:$${IMAGE_TAG} \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-amd64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-arm64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
|
||||
|
||||
$$debug docker manifest create grafana/grafana:$${IMAGE_TAG}-ubuntu \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
|
||||
|
||||
# Push the grafana manifests
|
||||
$$debug docker manifest push grafana/grafana:$${IMAGE_TAG}
|
||||
$$debug docker manifest push grafana/grafana:$${IMAGE_TAG}-ubuntu
|
||||
|
||||
# if LATEST is set, then also create & push latest
|
||||
if [[ -n $${LATEST} ]]; then
|
||||
$$debug docker manifest create grafana/grafana:latest \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-amd64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-arm64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-armv7
|
||||
$$debug docker manifest create grafana/grafana:latest-ubuntu \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-amd64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-arm64 \
|
||||
grafana/grafana-image-tags:$${IMAGE_TAG}-ubuntu-armv7
|
||||
|
||||
$$debug docker manifest push grafana/grafana:latest
|
||||
$$debug docker manifest push grafana/grafana:latest-ubuntu
|
||||
|
||||
fi'"""
|
||||
return {
|
||||
"environment": {
|
||||
"DOCKER_USER": from_secret("docker_username"),
|
||||
"DOCKER_PASSWORD": from_secret("docker_password"),
|
||||
},
|
||||
"name": "publish-images-grafana",
|
||||
"image": images["docker"],
|
||||
"depends_on": ["fetch-images"],
|
||||
"commands": [
|
||||
"apk add bash",
|
||||
command,
|
||||
],
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
|
||||
}
|
||||
|
||||
def publish_image_pipelines_public():
|
||||
"""Generates the pipeline used for publising public Docker images.
|
||||
|
||||
Returns:
|
||||
Drone pipeline
|
||||
"""
|
||||
return [
|
||||
pipeline(
|
||||
name = "publish-docker-public",
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": ["public"],
|
||||
},
|
||||
steps = [
|
||||
identify_runner_step(),
|
||||
download_grabpl_step(),
|
||||
compile_build_cmd(),
|
||||
fetch_images_step(),
|
||||
publish_image_public_step(),
|
||||
publish_images_step("release", "grafana-oss"),
|
||||
],
|
||||
environment = {"EDITION": "oss"},
|
||||
),
|
||||
pipeline(
|
||||
name = "manually-publish-docker-public",
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": ["publish-docker-public"],
|
||||
},
|
||||
steps = [
|
||||
identify_runner_step(),
|
||||
download_grabpl_step(),
|
||||
compile_build_cmd(),
|
||||
fetch_images_step(),
|
||||
publish_image_public_step(),
|
||||
],
|
||||
environment = {"EDITION": "oss"},
|
||||
),
|
||||
]
|
||||
@@ -1,46 +0,0 @@
|
||||
"""
|
||||
This module returns the pipeline used for triggering a downstream pipeline for Grafana Enterprise.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"enterprise_downstream_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
trigger = {
|
||||
"event": [
|
||||
"push",
|
||||
],
|
||||
"branch": "main",
|
||||
"paths": {
|
||||
"exclude": [
|
||||
"*.md",
|
||||
"docs/**",
|
||||
"latest.json",
|
||||
],
|
||||
},
|
||||
"repo": [
|
||||
"grafana/grafana",
|
||||
],
|
||||
}
|
||||
|
||||
def enterprise_downstream_pipeline():
|
||||
environment = {"EDITION": "oss"}
|
||||
steps = [
|
||||
enterprise_downstream_step(ver_mode = "main"),
|
||||
]
|
||||
deps = [
|
||||
"main-build-e2e-publish",
|
||||
]
|
||||
return pipeline(
|
||||
name = "main-trigger-downstream",
|
||||
trigger = trigger,
|
||||
services = [],
|
||||
steps = steps,
|
||||
depends_on = deps,
|
||||
environment = environment,
|
||||
)
|
||||
@@ -1,29 +0,0 @@
|
||||
"""
|
||||
This module returns the pipeline used for verifying Drone configuration.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"compile_build_cmd",
|
||||
"identify_runner_step",
|
||||
"lint_drone_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
def verify_drone(trigger, ver_mode):
|
||||
environment = {"EDITION": "oss"}
|
||||
steps = [
|
||||
identify_runner_step(),
|
||||
compile_build_cmd(),
|
||||
lint_drone_step(),
|
||||
]
|
||||
return pipeline(
|
||||
name = "{}-verify-drone".format(ver_mode),
|
||||
trigger = trigger,
|
||||
services = [],
|
||||
steps = steps,
|
||||
environment = environment,
|
||||
)
|
||||
@@ -1,27 +0,0 @@
|
||||
"""
|
||||
This module returns a Drone pipeline that verifies all Starlark files are linted.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"identify_runner_step",
|
||||
"lint_starlark_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
def verify_starlark(trigger, ver_mode):
|
||||
environment = {"EDITION": "oss"}
|
||||
steps = [
|
||||
identify_runner_step(),
|
||||
lint_starlark_step(),
|
||||
]
|
||||
return pipeline(
|
||||
name = "{}-verify-starlark".format(ver_mode),
|
||||
trigger = trigger,
|
||||
services = [],
|
||||
steps = steps,
|
||||
environment = environment,
|
||||
)
|
||||
@@ -1,382 +0,0 @@
|
||||
"""
|
||||
'rgm' pipelines are pipelines that use dagger (located in 'pkg/build/daggerbuild')
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/dagger.star",
|
||||
"with_dagger_install",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/events/release.star",
|
||||
"verify_release_pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/github.star",
|
||||
"github_app_generate_token_step",
|
||||
"github_app_pipeline_volumes",
|
||||
"github_app_step_volumes",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
"with_deps",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/variables.star",
|
||||
"dagger_version",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
"npm_token",
|
||||
"rgm_cdn_destination",
|
||||
"rgm_dagger_token",
|
||||
"rgm_destination",
|
||||
"rgm_downloads_destination",
|
||||
"rgm_gcp_key_base64",
|
||||
"rgm_storybook_destination",
|
||||
)
|
||||
|
||||
docs_paths = {
|
||||
"exclude": [
|
||||
"*.md",
|
||||
"docs/**",
|
||||
"packages/**/*.md",
|
||||
"latest.json",
|
||||
],
|
||||
}
|
||||
|
||||
tag_trigger = {
|
||||
"event": {
|
||||
"exclude": [
|
||||
"promote",
|
||||
],
|
||||
},
|
||||
"ref": {
|
||||
"include": [
|
||||
"refs/tags/v*",
|
||||
],
|
||||
"exclude": [
|
||||
"refs/tags/*-cloud*",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
main_trigger = {
|
||||
"event": [
|
||||
"push",
|
||||
],
|
||||
"branch": "main",
|
||||
"paths": docs_paths,
|
||||
"repo": [
|
||||
"grafana/grafana",
|
||||
],
|
||||
}
|
||||
|
||||
nightly_trigger = {
|
||||
"event": {
|
||||
"include": [
|
||||
"cron",
|
||||
],
|
||||
},
|
||||
"cron": {
|
||||
"include": [
|
||||
"nightly-release",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
version_branch_trigger = {"ref": ["refs/heads/v[0-9]*"]}
|
||||
|
||||
def rgm_env_secrets(env):
|
||||
"""Adds the rgm secret ENV variables to the given env arg
|
||||
|
||||
Args:
|
||||
env: A map of environment varables. This function will adds the necessary secrets to it (and potentially overwrite them).
|
||||
Returns:
|
||||
Drone step.
|
||||
"""
|
||||
env["DESTINATION"] = from_secret(rgm_destination)
|
||||
env["STORYBOOK_DESTINATION"] = from_secret(rgm_storybook_destination)
|
||||
env["CDN_DESTINATION"] = from_secret(rgm_cdn_destination)
|
||||
env["DOWNLOADS_DESTINATION"] = from_secret(rgm_downloads_destination)
|
||||
|
||||
env["GCP_KEY_BASE64"] = from_secret(rgm_gcp_key_base64)
|
||||
env["_EXPERIMENTAL_DAGGER_CLOUD_TOKEN"] = from_secret(rgm_dagger_token)
|
||||
env["GPG_PRIVATE_KEY"] = from_secret("packages_gpg_private_key")
|
||||
env["GPG_PUBLIC_KEY"] = from_secret("packages_gpg_public_key")
|
||||
env["GPG_PASSPHRASE"] = from_secret("packages_gpg_passphrase")
|
||||
env["DOCKER_USERNAME"] = from_secret("docker_username")
|
||||
env["DOCKER_PASSWORD"] = from_secret("docker_password")
|
||||
env["NPM_TOKEN"] = from_secret(npm_token)
|
||||
env["GCOM_API_KEY"] = from_secret("grafana_api_key")
|
||||
return env
|
||||
|
||||
def rgm_run(name, script):
|
||||
"""Returns a pipeline that does a full build & package of Grafana.
|
||||
|
||||
Args:
|
||||
name: The name of the pipeline step.
|
||||
script: The script in the container to run.
|
||||
Returns:
|
||||
Drone step.
|
||||
"""
|
||||
env = {
|
||||
"ALPINE_BASE": images["alpine"],
|
||||
"UBUNTU_BASE": images["ubuntu"],
|
||||
}
|
||||
rgm_run_step = {
|
||||
"name": name,
|
||||
"image": images["go"],
|
||||
"pull": "always",
|
||||
"commands": with_dagger_install([
|
||||
"export GRAFANA_DIR=$$(pwd)",
|
||||
"export GITHUB_TOKEN=$(cat /github-app/token)",
|
||||
"./pkg/build/daggerbuild/scripts/{}".format(script),
|
||||
], dagger_version),
|
||||
"environment": rgm_env_secrets(env),
|
||||
# The docker socket is a requirement for running dagger programs
|
||||
# In the future we should find a way to use dagger without mounting the docker socket.
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}] + github_app_step_volumes(),
|
||||
}
|
||||
|
||||
return [
|
||||
rgm_run_step,
|
||||
]
|
||||
|
||||
def rgm_copy(src, dst):
|
||||
"""Copies file from/to GCS.
|
||||
|
||||
Args:
|
||||
src: source of the files.
|
||||
dst: destination of the files.
|
||||
|
||||
Returns:
|
||||
Drone step.
|
||||
"""
|
||||
commands = [
|
||||
"printenv GCP_KEY_BASE64 | base64 -d > /tmp/key.json",
|
||||
"gcloud auth activate-service-account --key-file=/tmp/key.json",
|
||||
"gcloud storage cp -r {} {}".format(src, dst),
|
||||
]
|
||||
|
||||
return {
|
||||
"name": "rgm-copy",
|
||||
"image": "google/cloud-sdk:alpine",
|
||||
"commands": commands,
|
||||
"environment": rgm_env_secrets({}),
|
||||
}
|
||||
|
||||
def rgm_publish_packages(bucket = "grafana-packages"):
|
||||
"""Publish deb and rpm packages.
|
||||
|
||||
Args:
|
||||
bucket: target bucket to publish the packages.
|
||||
|
||||
Returns:
|
||||
Drone steps.
|
||||
"""
|
||||
steps = []
|
||||
for package_manager in ["deb", "rpm"]:
|
||||
steps.append({
|
||||
"name": "publish-{}".format(package_manager),
|
||||
# See https://github.com/grafana/deployment_tools/blob/master/docker/package-publish/README.md for docs on that image
|
||||
"image": images["package_publish"],
|
||||
"privileged": True,
|
||||
"settings": {
|
||||
"access_key_id": from_secret("packages_access_key_id"),
|
||||
"secret_access_key": from_secret("packages_secret_access_key"),
|
||||
"service_account_json": from_secret("packages_service_account"),
|
||||
"target_bucket": bucket,
|
||||
"gpg_passphrase": from_secret("packages_gpg_passphrase"),
|
||||
"gpg_public_key": from_secret("packages_gpg_public_key"),
|
||||
"gpg_private_key": from_secret("packages_gpg_private_key"),
|
||||
"package_path": "file:///drone/src/dist/*.{}".format(package_manager),
|
||||
},
|
||||
})
|
||||
|
||||
return steps
|
||||
|
||||
def rgm_main():
|
||||
# Runs a package / build process (with some distros) when commits are merged to main
|
||||
return pipeline(
|
||||
name = "rgm-main-prerelease",
|
||||
trigger = main_trigger,
|
||||
steps = rgm_run("rgm-build", "drone_build_main.sh"),
|
||||
)
|
||||
|
||||
def rgm_tag():
|
||||
# Runs a package / build process (with all distros) when a tag is made
|
||||
return pipeline(
|
||||
name = "rgm-tag-prerelease",
|
||||
trigger = tag_trigger,
|
||||
steps = rgm_run("rgm-build", "drone_build_tag_grafana.sh"),
|
||||
)
|
||||
|
||||
def rgm_version_branch():
|
||||
# Runs a package / build proces (with all distros) when a commit lands on a version branch
|
||||
return pipeline(
|
||||
name = "rgm-version-branch-prerelease",
|
||||
trigger = version_branch_trigger,
|
||||
steps = rgm_run("rgm-build", "drone_build_tag_grafana.sh"),
|
||||
)
|
||||
|
||||
def rgm_nightly_build():
|
||||
"""Nightly build pipeline.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
src = "$${DRONE_WORKSPACE}/dist/*"
|
||||
dst = "$${DESTINATION}/$${DRONE_BUILD_EVENT}"
|
||||
copy_step = rgm_copy(src, dst)
|
||||
if not dst.startswith("gs://"):
|
||||
copy_step["commands"].insert(0, "mkdir -p {}".format(dst))
|
||||
|
||||
copy_steps = with_deps([copy_step], ["rgm-build"])
|
||||
|
||||
return pipeline(
|
||||
name = "rgm-nightly-build",
|
||||
trigger = nightly_trigger,
|
||||
steps = rgm_run("rgm-build", "drone_build_nightly_grafana.sh") + copy_steps,
|
||||
)
|
||||
|
||||
def rgm_nightly_publish():
|
||||
"""Nightly publish pipeline.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
src = "$${DESTINATION}/$${DRONE_BUILD_EVENT}/*_$${DRONE_BUILD_NUMBER}_*"
|
||||
dst = "$${DRONE_WORKSPACE}/dist"
|
||||
|
||||
publish_steps = with_deps(rgm_run("rgm-publish", "drone_publish_nightly_grafana.sh"), ["rgm-copy"])
|
||||
package_steps = with_deps(rgm_publish_packages(), ["rgm-publish"])
|
||||
copy_step = rgm_copy(src, dst)
|
||||
if not dst.startswith("gs://"):
|
||||
copy_step["commands"].insert(0, "mkdir -p {}".format(dst))
|
||||
return pipeline(
|
||||
name = "rgm-nightly-publish",
|
||||
trigger = nightly_trigger,
|
||||
steps = [copy_step] + publish_steps + package_steps,
|
||||
depends_on = ["rgm-nightly-build"],
|
||||
)
|
||||
|
||||
def rgm_nightly_pipeline():
|
||||
return [
|
||||
rgm_nightly_build(),
|
||||
rgm_nightly_publish(),
|
||||
]
|
||||
|
||||
def rgm_tag_pipeline():
|
||||
build = rgm_tag()
|
||||
|
||||
return [
|
||||
build,
|
||||
verify_release_pipeline(
|
||||
trigger = tag_trigger,
|
||||
name = "rgm-tag-verify-prerelease-assets",
|
||||
bucket = "grafana-prerelease",
|
||||
depends_on = [
|
||||
build["name"],
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
def rgm_version_branch_pipeline():
|
||||
return [
|
||||
rgm_version_branch(),
|
||||
verify_release_pipeline(
|
||||
trigger = version_branch_trigger,
|
||||
name = "rgm-prerelease-verify-prerelease-assets",
|
||||
bucket = "grafana-prerelease",
|
||||
depends_on = [
|
||||
"rgm-version-branch-prerelease",
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
def rgm_main_pipeline():
|
||||
return [
|
||||
rgm_main(),
|
||||
]
|
||||
|
||||
def rgm_promotion_pipeline():
|
||||
"""Promotion build pipeline.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
promotion_trigger = {
|
||||
"event": ["promote"],
|
||||
"target": "upload-packages",
|
||||
}
|
||||
|
||||
env = {
|
||||
"ALPINE_BASE": images["alpine"],
|
||||
"UBUNTU_BASE": images["ubuntu"],
|
||||
}
|
||||
|
||||
# Expected promotion args:
|
||||
# * GRAFANA_REF = commit hash, branch name, or tag name
|
||||
# * ENTERPRISE_REF = commit hash, branch name, or tag name. If not building an enterprise artifact, then this can be
|
||||
# left empty.
|
||||
# * ARTIFACTS = comma delimited list of artifacts (ex: "targz:grafana:linux/amd64,rpm:grafana:linux/amd64")
|
||||
# * VERSION = version string of Grafana that is being built (ex: v10.0.0)
|
||||
# * UPLOAD_TO = Google Cloud Storage URL to upload the built artifacts to. (ex: gs://some-bucket/path)
|
||||
build_step = {
|
||||
"name": "rgm-build",
|
||||
"image": images["go"],
|
||||
"pull": "always",
|
||||
"commands": with_dagger_install([
|
||||
"export GITHUB_TOKEN=$(cat /github-app/token)",
|
||||
"dagger run --silent go run ./pkg/build/cmd artifacts " +
|
||||
"-a $${ARTIFACTS} " +
|
||||
"--grafana-ref=$${GRAFANA_REF} " +
|
||||
"--enterprise-ref=$${ENTERPRISE_REF} " +
|
||||
"--grafana-repo=$${GRAFANA_REPO} " +
|
||||
"--build-id=$${DRONE_BUILD_NUMBER} " +
|
||||
"--version=$${VERSION}",
|
||||
], dagger_version),
|
||||
"environment": rgm_env_secrets(env),
|
||||
# The docker socket is a requirement for running dagger programs
|
||||
# In the future we should find a way to use dagger without mounting the docker socket.
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}] + github_app_step_volumes(),
|
||||
}
|
||||
|
||||
generate_token_step = github_app_generate_token_step()
|
||||
publish_step = rgm_copy("dist/*", "$${UPLOAD_TO}")
|
||||
build_step["depends_on"] = [
|
||||
generate_token_step["name"],
|
||||
]
|
||||
|
||||
publish_step["depends_on"] = [
|
||||
build_step["name"],
|
||||
]
|
||||
|
||||
steps = [
|
||||
generate_token_step,
|
||||
build_step,
|
||||
publish_step,
|
||||
]
|
||||
|
||||
return [
|
||||
pipeline(
|
||||
name = "rgm-promotion",
|
||||
trigger = promotion_trigger,
|
||||
steps = steps,
|
||||
volumes = github_app_step_volumes() + github_app_pipeline_volumes(),
|
||||
),
|
||||
]
|
||||
|
||||
def rgm():
|
||||
return (
|
||||
rgm_main_pipeline() +
|
||||
rgm_tag_pipeline() +
|
||||
rgm_version_branch_pipeline() +
|
||||
rgm_promotion_pipeline()
|
||||
)
|
||||
@@ -1,42 +0,0 @@
|
||||
"""
|
||||
This module is used to interface with the GitHub App to extract temporary installation tokens.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
"github_app_app_id",
|
||||
"github_app_app_installation_id",
|
||||
"github_app_private_key",
|
||||
)
|
||||
|
||||
def github_app_step_volumes():
|
||||
return [
|
||||
{"name": "github-app", "path": "/github-app"},
|
||||
]
|
||||
|
||||
def github_app_pipeline_volumes():
|
||||
return [
|
||||
{"name": "github-app", "temp": {}},
|
||||
]
|
||||
|
||||
def github_app_generate_token_step():
|
||||
return {
|
||||
"name": "github-app-generate-token",
|
||||
"image": images["github_app_secret_writer"],
|
||||
"environment": {
|
||||
"GITHUB_APP_ID": from_secret(github_app_app_id),
|
||||
"GITHUB_APP_INSTALLATION_ID": from_secret(github_app_app_installation_id),
|
||||
"GITHUB_APP_PRIVATE_KEY": from_secret(github_app_private_key),
|
||||
},
|
||||
"commands": [
|
||||
"echo $(/usr/bin/github-app-external-token) > /github-app/token",
|
||||
],
|
||||
"volumes": github_app_step_volumes(),
|
||||
# forks or those without access would cause it to fail, but we can safely ignore it since there'll be no token.
|
||||
"failure": "ignore",
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +0,0 @@
|
||||
"""
|
||||
Individual steps that use 'grafana-build' to replace existing individual steps.
|
||||
These aren't used in releases.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/dagger.star",
|
||||
"with_dagger_install",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/variables.star",
|
||||
"dagger_version",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
"rgm_dagger_token",
|
||||
)
|
||||
|
||||
def artifacts_cmd(artifacts = []):
|
||||
cmd = "go run ./pkg/build/cmd artifacts "
|
||||
|
||||
for artifact in artifacts:
|
||||
cmd += "-a {} ".format(artifact)
|
||||
|
||||
return cmd
|
||||
|
||||
# rgm_artifacts_step will create artifacts using the '/src/build artifacts' command.
|
||||
def rgm_artifacts_step(
|
||||
name = "rgm-package",
|
||||
artifacts = ["targz:grafana:linux/amd64", "targz:grafana:linux/arm64"],
|
||||
file = "packages.txt",
|
||||
depends_on = ["yarn-install"],
|
||||
tag_format = "{{ .version }}-{{ .arch }}",
|
||||
ubuntu_tag_format = "{{ .version }}-ubuntu-{{ .arch }}",
|
||||
verify = "false"):
|
||||
cmd = artifacts_cmd(artifacts = artifacts)
|
||||
|
||||
return {
|
||||
"name": name,
|
||||
"image": images["go"],
|
||||
"pull": "always",
|
||||
"depends_on": depends_on,
|
||||
"environment": {
|
||||
"_EXPERIMENTAL_DAGGER_CLOUD_TOKEN": from_secret(rgm_dagger_token),
|
||||
},
|
||||
"commands": with_dagger_install([
|
||||
"docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --version",
|
||||
"docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --uninstall 'qemu-*'",
|
||||
"docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --install all",
|
||||
cmd +
|
||||
"--yarn-cache=$$YARN_CACHE_FOLDER " +
|
||||
"--build-id=$$DRONE_BUILD_NUMBER " +
|
||||
"--ubuntu-base=ubuntu-base " +
|
||||
"--alpine-base=alpine-base " +
|
||||
"--tag-format='{}' ".format(tag_format) +
|
||||
"--ubuntu-tag-format='{}' ".format(ubuntu_tag_format) +
|
||||
"--verify='{}' ".format(verify) +
|
||||
"--grafana-dir=$$PWD > {}".format(file),
|
||||
"find ./dist -name '*docker*.tar.gz' -type f | xargs -n1 docker load -i",
|
||||
], dagger_version),
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
|
||||
}
|
||||
|
||||
# rgm_build_backend will create compile the grafana backend for various platforms.
|
||||
def rgm_build_backend_step(artifacts = ["backend:grafana:linux/amd64", "backend:grafana:linux/arm64"]):
|
||||
return rgm_artifacts_step(name = "rgm-build-backend", artifacts = artifacts, depends_on = [])
|
||||
|
||||
def rgm_build_docker_step(depends_on = ["yarn-install"], file = "docker.txt", tag_format = "{{ .version }}-{{ .arch }}", ubuntu_tag_format = "{{ .version }}-ubuntu-{{ .arch }}"):
|
||||
return {
|
||||
"name": "rgm-build-docker",
|
||||
"image": images["go"],
|
||||
"pull": "always",
|
||||
"environment": {
|
||||
"_EXPERIMENTAL_DAGGER_CLOUD_TOKEN": from_secret(rgm_dagger_token),
|
||||
},
|
||||
"commands": with_dagger_install([
|
||||
"docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --version",
|
||||
"docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --uninstall 'qemu-*'",
|
||||
"docker run --privileged --rm tonistiigi/binfmt:qemu-v7.0.0-28 --install all",
|
||||
"go run ./pkg/build/cmd artifacts " +
|
||||
"-a docker:grafana:linux/amd64 " +
|
||||
"-a docker:grafana:linux/amd64:ubuntu " +
|
||||
"-a docker:grafana:linux/arm64 " +
|
||||
"-a docker:grafana:linux/arm64:ubuntu " +
|
||||
"-a docker:grafana:linux/arm/v7 " +
|
||||
"-a docker:grafana:linux/arm/v7:ubuntu " +
|
||||
"--yarn-cache=$$YARN_CACHE_FOLDER " +
|
||||
"--build-id=$$DRONE_BUILD_NUMBER " +
|
||||
"--ubuntu-base=ubuntu-base " +
|
||||
"--alpine-base=alpine-base " +
|
||||
"--tag-format='{}' ".format(tag_format) +
|
||||
"--grafana-dir=$$PWD " +
|
||||
"--ubuntu-tag-format='{}' > {}".format(ubuntu_tag_format, file),
|
||||
"find ./dist -name '*docker*.tar.gz' -type f | xargs -n1 docker load -i",
|
||||
], dagger_version),
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
|
||||
"depends_on": depends_on,
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
"""
|
||||
This module contains all the docker images that are used to build test and publish Grafana.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/variables.star",
|
||||
"golang_version",
|
||||
"nodejs_version",
|
||||
)
|
||||
|
||||
images = {
|
||||
"docker": "docker:27-cli",
|
||||
"git": "alpine/git:2.40.1",
|
||||
"go": "golang:{}-alpine".format(golang_version),
|
||||
"node": "node:{}-alpine".format(nodejs_version),
|
||||
"node_deb": "node:{}-bookworm".format(nodejs_version[:2]),
|
||||
"cloudsdk": "google/cloud-sdk:431.0.0",
|
||||
"publish": "grafana/grafana-ci-deploy:1.3.3",
|
||||
"alpine": "alpine:3.21.3",
|
||||
"ubuntu": "ubuntu:22.04",
|
||||
"curl": "byrnedo/alpine-curl:0.1.8",
|
||||
"plugins_slack": "plugins/slack",
|
||||
"package_publish": "us.gcr.io/kubernetes-dev/package-publish:latest",
|
||||
"drone_downstream": "grafana/drone-downstream",
|
||||
"docker_puppeteer": "grafana/docker-puppeteer:1.1.0",
|
||||
"docs": "grafana/docs-base:latest",
|
||||
"cypress": "cypress/included:14.3.2",
|
||||
"dockerize": "jwilder/dockerize:0.6.1",
|
||||
"github_app_secret_writer": "us-docker.pkg.dev/grafanalabs-global/docker-deployment-tools-prod/github-app-secret-writer:2024-11-05-v11688112090.1-83920c59",
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
"""
|
||||
This module contains utility functions for generating Drone pipelines.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"slack_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"gar_pull_secret",
|
||||
"gcr_pull_secret",
|
||||
)
|
||||
|
||||
failure_template = "Build {{build.number}} failed for commit: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 8 }}>: {{build.link}}\nBranch: <https://github.com/{{ repo.owner }}/{{ repo.name }}/commits/{{ build.branch }}|{{ build.branch }}>\nAuthor: {{build.author}}"
|
||||
|
||||
def pipeline(
|
||||
name,
|
||||
trigger,
|
||||
steps,
|
||||
services = [],
|
||||
platform = "linux",
|
||||
depends_on = [],
|
||||
environment = None,
|
||||
volumes = []):
|
||||
"""Generate a Drone Docker pipeline with commonly used values.
|
||||
|
||||
In addition to the parameters provided, it configures:
|
||||
- the use of an image pull secret
|
||||
- a retry count for cloning
|
||||
- a volume 'docker' that can be used to access the Docker socket
|
||||
|
||||
Args:
|
||||
name: controls the pipeline name.
|
||||
trigger: a Drone trigger for the pipeline.
|
||||
steps: the Drone steps for the pipeline.
|
||||
services: auxiliary services used during the pipeline.
|
||||
Defaults to [].
|
||||
platform: abstracts platform specific configuration primarily for different Drone behavior on Windows.
|
||||
Defaults to 'linux'.
|
||||
depends_on: list of pipelines that must have succeeded before this pipeline can start.
|
||||
Defaults to [].
|
||||
environment: environment variables passed through to pipeline steps.
|
||||
Defaults to None.
|
||||
volumes: additional volumes available to be mounted by pipeline steps.
|
||||
Defaults to [].
|
||||
|
||||
Returns:
|
||||
Drone pipeline
|
||||
"""
|
||||
if platform != "windows":
|
||||
platform_conf = {
|
||||
"platform": {"os": "linux", "arch": "amd64"},
|
||||
# A shared cache is used on the host
|
||||
# To avoid issues with parallel builds, we run this repo on single build agents
|
||||
"node": {"type": "no-parallel"},
|
||||
}
|
||||
else:
|
||||
platform_conf = {
|
||||
"platform": {
|
||||
"os": "windows",
|
||||
"arch": "amd64",
|
||||
"version": "1809",
|
||||
},
|
||||
}
|
||||
|
||||
docker_mount_path = "/var/run/docker.sock"
|
||||
if platform == "windows":
|
||||
docker_mount_path = "//./pipe/docker_engine/"
|
||||
|
||||
pipeline = {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": name,
|
||||
"trigger": trigger,
|
||||
"services": services,
|
||||
"steps": steps,
|
||||
"clone": {
|
||||
"retries": 3,
|
||||
},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "docker",
|
||||
"host": {
|
||||
"path": docker_mount_path,
|
||||
},
|
||||
},
|
||||
],
|
||||
"depends_on": depends_on,
|
||||
"image_pull_secrets": [gcr_pull_secret, gar_pull_secret],
|
||||
}
|
||||
if environment:
|
||||
pipeline.update(
|
||||
{
|
||||
"environment": environment,
|
||||
},
|
||||
)
|
||||
|
||||
pipeline["volumes"].extend(volumes)
|
||||
pipeline.update(platform_conf)
|
||||
|
||||
return pipeline
|
||||
|
||||
def notify_pipeline(
|
||||
name,
|
||||
slack_channel,
|
||||
trigger,
|
||||
depends_on = [],
|
||||
template = None,
|
||||
secret = None):
|
||||
trigger = dict(trigger)
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "amd64",
|
||||
},
|
||||
"name": name,
|
||||
"trigger": trigger,
|
||||
"steps": [
|
||||
slack_step(slack_channel, template, secret),
|
||||
],
|
||||
"clone": {
|
||||
"retries": 3,
|
||||
},
|
||||
"depends_on": depends_on,
|
||||
}
|
||||
|
||||
# TODO: this overrides any existing dependencies because we're following the existing logic
|
||||
# it should append to any existing dependencies
|
||||
def with_deps(steps, deps = []):
|
||||
for step in steps:
|
||||
step["depends_on"] = deps
|
||||
return steps
|
||||
|
||||
def ignore_failure(steps):
|
||||
for step in steps:
|
||||
step["failure"] = "ignore"
|
||||
return steps
|
||||
@@ -1,10 +0,0 @@
|
||||
"""
|
||||
global variables
|
||||
"""
|
||||
|
||||
grabpl_version = "v3.1.2"
|
||||
golang_version = "1.24.6"
|
||||
|
||||
# nodejs_version should match what's in ".nvmrc", but without the v prefix.
|
||||
nodejs_version = "22.16.0"
|
||||
dagger_version = "v0.18.8"
|
||||
@@ -1,166 +0,0 @@
|
||||
"""
|
||||
This module returns functions for generating Drone secrets fetched from Vault.
|
||||
"""
|
||||
gcr_pull_secret = "gcr"
|
||||
gar_pull_secret = "gar"
|
||||
drone_token = "drone_token"
|
||||
prerelease_bucket = "prerelease_bucket"
|
||||
gcp_upload_artifacts_key = "gcp_upload_artifacts_key"
|
||||
gcp_grafanauploads = "gcp_grafanauploads"
|
||||
gcp_grafanauploads_base64 = "gcp_grafanauploads_base64"
|
||||
gcp_download_build_container_assets_key = "gcp_download_build_container_assets_key"
|
||||
|
||||
azure_sp_app_id = "azure_sp_app_id"
|
||||
azure_sp_app_pw = "azure_sp_app_pw"
|
||||
azure_tenant = "azure_tenant"
|
||||
|
||||
github_app_app_id = "github-app-app-id"
|
||||
github_app_app_installation_id = "github-app-installation-id"
|
||||
github_app_private_key = "github-app-private-key"
|
||||
|
||||
rgm_gcp_key_base64 = "gcp_key_base64"
|
||||
rgm_destination = "destination"
|
||||
rgm_storybook_destination = "rgm_storybook_destination"
|
||||
rgm_cdn_destination = "rgm_cdn_destination"
|
||||
rgm_downloads_destination = "rgm_downloads_destination"
|
||||
rgm_dagger_token = "dagger_token"
|
||||
|
||||
docker_username = "docker_username"
|
||||
docker_password = "docker_password"
|
||||
|
||||
npm_token = "npm_token"
|
||||
|
||||
def from_secret(secret):
|
||||
return {"from_secret": secret}
|
||||
|
||||
def vault_secret(name, path, key):
|
||||
return {
|
||||
"kind": "secret",
|
||||
"name": name,
|
||||
"get": {
|
||||
"path": path,
|
||||
"name": key,
|
||||
},
|
||||
}
|
||||
|
||||
def secrets():
|
||||
return [
|
||||
vault_secret(github_app_app_id, "ci/data/repo/grafana/grafana/github-app", "app-id"),
|
||||
vault_secret(github_app_app_installation_id, "ci/data/repo/grafana/grafana/github-app", "app-installation-id"),
|
||||
vault_secret(github_app_private_key, "ci/data/repo/grafana/grafana/github-app", "private-key"),
|
||||
vault_secret(gcp_grafanauploads, "infra/data/ci/grafana-release-eng/grafanauploads", "credentials.json"),
|
||||
vault_secret(gcp_grafanauploads_base64, "infra/data/ci/grafana-release-eng/grafanauploads", "credentials_base64"),
|
||||
vault_secret("grafana_api_key", "infra/data/ci/grafana-release-eng/grafanacom", "api_key"),
|
||||
vault_secret(gcr_pull_secret, "secret/data/common/gcr", ".dockerconfigjson"),
|
||||
vault_secret(gar_pull_secret, "secret/data/common/gar", ".dockerconfigjson"),
|
||||
vault_secret(drone_token, "infra/data/ci/drone", "machine-user-token"),
|
||||
vault_secret(prerelease_bucket, "infra/data/ci/grafana/prerelease", "bucket"),
|
||||
vault_secret(docker_username, "ci/data/common/dockerhub", "username"),
|
||||
vault_secret(docker_password, "ci/data/common/dockerhub", "password"),
|
||||
vault_secret(
|
||||
gcp_upload_artifacts_key,
|
||||
"infra/data/ci/grafana/releng/artifacts-uploader-service-account",
|
||||
"credentials.json",
|
||||
),
|
||||
vault_secret(
|
||||
gcp_download_build_container_assets_key,
|
||||
"infra/data/ci/grafana/assets-downloader-build-container-service-account",
|
||||
"credentials.json",
|
||||
),
|
||||
vault_secret(
|
||||
azure_sp_app_id,
|
||||
"infra/data/ci/datasources/cpp-azure-resourcemanager-credentials",
|
||||
"application_id",
|
||||
),
|
||||
vault_secret(
|
||||
azure_sp_app_pw,
|
||||
"infra/data/ci/datasources/cpp-azure-resourcemanager-credentials",
|
||||
"application_secret",
|
||||
),
|
||||
vault_secret(
|
||||
azure_tenant,
|
||||
"infra/data/ci/datasources/cpp-azure-resourcemanager-credentials",
|
||||
"tenant_id",
|
||||
),
|
||||
vault_secret(
|
||||
npm_token,
|
||||
"infra/data/ci/grafana-release-eng/npm",
|
||||
"token",
|
||||
),
|
||||
# Package publishing
|
||||
vault_secret(
|
||||
"packages_gpg_public_key",
|
||||
"infra/data/ci/packages-publish/gpg",
|
||||
"public-key-b64",
|
||||
),
|
||||
vault_secret(
|
||||
"packages_gpg_private_key",
|
||||
"infra/data/ci/packages-publish/gpg",
|
||||
"private-key-b64",
|
||||
),
|
||||
vault_secret(
|
||||
"packages_gpg_passphrase",
|
||||
"infra/data/ci/packages-publish/gpg",
|
||||
"passphrase",
|
||||
),
|
||||
vault_secret(
|
||||
"packages_service_account",
|
||||
"infra/data/ci/packages-publish/service-account",
|
||||
"credentials.json",
|
||||
),
|
||||
vault_secret(
|
||||
"packages_access_key_id",
|
||||
"infra/data/ci/packages-publish/bucket-credentials",
|
||||
"AccessID",
|
||||
),
|
||||
vault_secret(
|
||||
"packages_secret_access_key",
|
||||
"infra/data/ci/packages-publish/bucket-credentials",
|
||||
"Secret",
|
||||
),
|
||||
vault_secret(
|
||||
"static_asset_editions",
|
||||
"infra/data/ci/grafana-release-eng/artifact-publishing",
|
||||
"static_asset_editions",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_gcp_key_base64,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
"gcp_service_account_prod_base64",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_destination,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
"destination_prod",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_storybook_destination,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
"storybook_destination",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_cdn_destination,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
"cdn_destination",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_downloads_destination,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
"downloads_destination",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_dagger_token,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
"dagger_token",
|
||||
),
|
||||
vault_secret(
|
||||
"delivery-bot-app-private-key",
|
||||
"ci/data/repo/grafana/grafana/delivery-bot-app",
|
||||
"PRIVATE_KEY",
|
||||
),
|
||||
vault_secret(
|
||||
"gcr_credentials",
|
||||
"secret/data/common/gcr",
|
||||
"service-account",
|
||||
),
|
||||
]
|
||||
@@ -1,51 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
version=${1:-$TAG}
|
||||
|
||||
# Construct the URL based on the provided version and edition
|
||||
if [ "$EDITION" = "enterprise" ]; then
|
||||
url="https://grafana.com/api/downloads/grafana-enterprise/versions/$version"
|
||||
else
|
||||
url="https://grafana.com/api/downloads/grafana/versions/$version"
|
||||
fi
|
||||
|
||||
# Make a request to the GCOM API to retrieve the artifacts for the specified version. Exit if the request fails.
|
||||
if ! artifacts=$(curl "$url"); then
|
||||
echo "Failed to retrieve artifact URLs from Grafana.com API. Please check the API key, authentication, edition, and version."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use Node.js to parse the JSON response and extract the download URLs
|
||||
url_string=$(node -e "
|
||||
const artifacts = JSON.parse(JSON.stringify($artifacts));
|
||||
const downloadUrls = artifacts.packages.map((package) => package.links.find((link) => link.rel === 'download').href);
|
||||
console.log(downloadUrls.join(' '));
|
||||
")
|
||||
|
||||
# Convert the url_string to a Bash array
|
||||
read -r -a urls <<< "$url_string"
|
||||
|
||||
# If empty, no artifact URLs were found for the specified version. Exit with an error.
|
||||
if [ ${#urls[@]} -eq 0 ]; then
|
||||
echo "No artifact URLs found for version $version. Please check the provided version."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Iterate over the URLs and check the status code of each. If any URL does not return a 200 status code, add it to the failed_urls string.
|
||||
failed_urls=""
|
||||
for url in "${urls[@]}"; do
|
||||
status_code=$(curl -L -s -o /dev/null -w "%{http_code}" "$url")
|
||||
if [ "$status_code" -ne 200 ]; then
|
||||
failed_urls+="$url\n"
|
||||
fi
|
||||
done
|
||||
|
||||
# If any URLs failed, print them and exit with an error.
|
||||
if [ -n "$failed_urls" ]; then
|
||||
echo "The following URLs did not return a 200 status code:"
|
||||
echo "$failed_urls"
|
||||
exit 1
|
||||
else
|
||||
echo "All URLs returned a 200 status code. Download links are valid for version $version."
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user