[v11.0.x] CI: use linux to build msi installers (#95296)
CI: use linux to build msi installers (#95215)
* Build the MSI installers using Linux and wine
(cherry picked from commit 66c728d26b)
This commit is contained in:
@@ -35,10 +35,6 @@ load(
|
||||
"scripts/drone/pipelines/trigger_downstream.star",
|
||||
"enterprise_downstream_pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/pipelines/windows.star",
|
||||
"windows",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"failure_template",
|
||||
@@ -64,6 +60,8 @@ trigger = {
|
||||
}
|
||||
|
||||
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()),
|
||||
test_frontend(trigger, ver_mode),
|
||||
@@ -72,7 +70,6 @@ def main_pipelines():
|
||||
lint_backend_pipeline(trigger, ver_mode),
|
||||
build_e2e(trigger, ver_mode),
|
||||
integration_tests(trigger, prefix = ver_mode, ver_mode = ver_mode),
|
||||
windows(trigger, ver_mode = ver_mode),
|
||||
enterprise_downstream_pipeline(),
|
||||
notify_pipeline(
|
||||
name = "main-notify",
|
||||
@@ -83,7 +80,6 @@ def main_pipelines():
|
||||
"main-test-backend",
|
||||
"main-build-e2e-publish",
|
||||
"main-integration-tests",
|
||||
"main-windows",
|
||||
],
|
||||
template = failure_template,
|
||||
secret = "slack_webhook",
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
"""
|
||||
This module contains steps and pipelines relating to creating CI Docker images.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/windows_images.star",
|
||||
"windows_images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
)
|
||||
|
||||
def publish_ci_windows_test_image_pipeline():
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": ["ci-windows-test-image"],
|
||||
}
|
||||
pl = pipeline(
|
||||
name = "publish-ci-windows-test-image",
|
||||
trigger = trigger,
|
||||
platform = "windows",
|
||||
steps = [
|
||||
{
|
||||
"name": "clone",
|
||||
"image": windows_images["wix"],
|
||||
"environment": {
|
||||
"GITHUB_TOKEN": from_secret("github_token"),
|
||||
},
|
||||
"commands": [
|
||||
'git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-ci-sandbox.git" .',
|
||||
"git checkout -f $$env:DRONE_COMMIT",
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "build-and-publish",
|
||||
"image": windows_images["windows_server_core"],
|
||||
"environment": {
|
||||
"DOCKER_USERNAME": from_secret("docker_username"),
|
||||
"DOCKER_PASSWORD": from_secret("docker_password"),
|
||||
},
|
||||
"commands": [
|
||||
"cd scripts\\build\\ci-windows-test",
|
||||
"docker login -u $$env:DOCKER_USERNAME -p $$env:DOCKER_PASSWORD",
|
||||
"docker build -t grafana/grafana-ci-windows-test:$$env:TAG .",
|
||||
"docker push grafana/grafana-ci-windows-test:$$env:TAG",
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "docker",
|
||||
"path": "//./pipe/docker_engine/",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
pl["clone"] = {
|
||||
"disable": True,
|
||||
}
|
||||
|
||||
return [pl]
|
||||
@@ -1,85 +0,0 @@
|
||||
"""
|
||||
This module returns the pipeline used for building Grafana on Windows.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib_windows.star",
|
||||
"clone_step_windows",
|
||||
"get_windows_steps",
|
||||
"test_backend_step_windows",
|
||||
"wire_install_step_windows",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/windows_images.star",
|
||||
"windows_images",
|
||||
)
|
||||
|
||||
def windows_test_backend(trigger, edition, ver_mode):
|
||||
""" Generates a pipeline that runs backend tests on Windows
|
||||
|
||||
Args:
|
||||
trigger: a Drone trigger for the pipeline
|
||||
edition: controls whether enterprise code is included or not
|
||||
ver_mode: controls whether a pre-release or actual release pipeline is generated.
|
||||
Returns:
|
||||
A single pipeline running backend tests for Windows
|
||||
"""
|
||||
environment = {"EDITION": edition}
|
||||
steps = [
|
||||
clone_step_windows(),
|
||||
]
|
||||
|
||||
steps.extend([{
|
||||
"name": "windows-init",
|
||||
"image": windows_images["go"],
|
||||
"depends_on": ["clone"],
|
||||
"commands": [],
|
||||
}])
|
||||
|
||||
steps.extend([
|
||||
wire_install_step_windows(edition),
|
||||
test_backend_step_windows(),
|
||||
])
|
||||
pl = pipeline(
|
||||
name = "{}-test-backend-windows".format(ver_mode),
|
||||
trigger = trigger,
|
||||
steps = steps,
|
||||
depends_on = [],
|
||||
platform = "windows",
|
||||
environment = environment,
|
||||
)
|
||||
pl["clone"] = {
|
||||
"disable": True,
|
||||
}
|
||||
return pl
|
||||
|
||||
def windows(trigger, ver_mode):
|
||||
"""Generates the pipeline used for building Grafana on Windows.
|
||||
|
||||
Args:
|
||||
trigger: a Drone trigger for the pipeline.
|
||||
ver_mode: controls whether a pre-release or actual release pipeline is generated.
|
||||
Also indirectly controls which version of enterprise code is used.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
environment = {"EDITION": "oss"}
|
||||
|
||||
return pipeline(
|
||||
name = "main-windows",
|
||||
trigger = dict(trigger, repo = ["grafana/grafana"]),
|
||||
steps = get_windows_steps(ver_mode),
|
||||
depends_on = [
|
||||
"main-test-frontend",
|
||||
"main-test-backend",
|
||||
"main-build-e2e-publish",
|
||||
"main-integration-tests",
|
||||
],
|
||||
platform = "windows",
|
||||
environment = environment,
|
||||
)
|
||||
+14
-20
@@ -20,10 +20,6 @@ load(
|
||||
"scripts/drone/pipelines/whats_new_checker.star",
|
||||
"whats_new_checker_pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/lib_windows.star",
|
||||
"get_windows_steps",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
@@ -49,6 +45,10 @@ load(
|
||||
"rgm_github_token",
|
||||
"rgm_storybook_destination",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/windows.star",
|
||||
"windows_pipeline_release",
|
||||
)
|
||||
|
||||
docs_paths = {
|
||||
"exclude": [
|
||||
@@ -228,18 +228,6 @@ def rgm_tag():
|
||||
steps = rgm_run("rgm-build", "drone_build_tag_grafana.sh"),
|
||||
)
|
||||
|
||||
def rgm_tag_windows():
|
||||
return pipeline(
|
||||
name = "rgm-tag-prerelease-windows",
|
||||
trigger = tag_trigger,
|
||||
steps = get_windows_steps(
|
||||
ver_mode = "release",
|
||||
bucket = "grafana-prerelease",
|
||||
),
|
||||
depends_on = ["rgm-tag-prerelease"],
|
||||
platform = "windows",
|
||||
)
|
||||
|
||||
def rgm_version_branch():
|
||||
# Runs a package / build proces (with all distros) when a commit lands on a version branch
|
||||
return pipeline(
|
||||
@@ -299,17 +287,23 @@ def rgm_nightly_pipeline():
|
||||
]
|
||||
|
||||
def rgm_tag_pipeline():
|
||||
build = rgm_tag()
|
||||
|
||||
# the Windows step requires an uploaded .zip file to base its compilation on
|
||||
windows = windows_pipeline_release(trigger = tag_trigger, depends_on = [
|
||||
build["name"],
|
||||
])
|
||||
return [
|
||||
build,
|
||||
whats_new_checker_pipeline(tag_trigger),
|
||||
rgm_tag(),
|
||||
rgm_tag_windows(),
|
||||
windows,
|
||||
verify_release_pipeline(
|
||||
trigger = tag_trigger,
|
||||
name = "rgm-tag-verify-prerelease-assets",
|
||||
bucket = "grafana-prerelease",
|
||||
depends_on = [
|
||||
"rgm-tag-prerelease",
|
||||
"rgm-tag-prerelease-windows",
|
||||
windows["name"],
|
||||
build["name"],
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
@@ -36,4 +36,5 @@ images = {
|
||||
"shellcheck": "koalaman/shellcheck:stable",
|
||||
"playwright": "mcr.microsoft.com/playwright:v1.42.1-jammy",
|
||||
"rocky": "rockylinux:9",
|
||||
"wine": "scottyhardy/docker-wine:stable-9.0",
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
"""
|
||||
This module contains all the windows docker images that are used to build test and publish Grafana.
|
||||
All the windows images needed to be in a different file than the other images, since they cannot be scanned
|
||||
by trivy. Related issue: https://github.com/aquasecurity/trivy/issues/1392
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/variables.star",
|
||||
"golang_version",
|
||||
)
|
||||
|
||||
windows_images = {
|
||||
"1809": "mcr.microsoft.com/windows:1809",
|
||||
"wix": "grafana/ci-wix:0.1.1",
|
||||
"windows_server_core": "docker:windowsservercore-1809",
|
||||
"go": "golang:{}-windowsservercore-1809".format(golang_version),
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
global variables
|
||||
"""
|
||||
|
||||
grabpl_version = "v3.0.56"
|
||||
grabpl_version = "v3.1.1"
|
||||
golang_version = "1.22.7"
|
||||
|
||||
# nodejs_version should match what's in ".nvmrc", but without the v prefix.
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
"""
|
||||
This module is a library of Drone steps that exclusively run on windows machines.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"download_grabpl_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/images.star",
|
||||
"images",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/vault.star",
|
||||
"from_secret",
|
||||
"rgm_gcp_key_base64",
|
||||
)
|
||||
|
||||
def download_nssm_step():
|
||||
return {
|
||||
"name": "downlad-nssm",
|
||||
"image": images["curl"],
|
||||
"commands": [
|
||||
# We don't need to extract nssm-2.24 because the wix / build process extracts it. It just needs to be in
|
||||
# PWD and be named `nssm-2.24`.
|
||||
"curl -L0 https://nssm.cc/release/nssm-2.24.zip -o nssm-2.24.zip",
|
||||
],
|
||||
}
|
||||
|
||||
def download_wix_step():
|
||||
return {
|
||||
"name": "download-wix3",
|
||||
"image": images["curl"],
|
||||
"commands": [
|
||||
"mkdir wix3 && cd wix3",
|
||||
"curl -L0 https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip -o wix3.zip",
|
||||
"unzip wix3.zip",
|
||||
],
|
||||
}
|
||||
|
||||
def download_zip_step(target = ""):
|
||||
path = "{}/grafana-$${{DRONE_TAG:1}}.windows-amd64.zip".format(target)
|
||||
return {
|
||||
"name": "download-zip",
|
||||
"image": images["cloudsdk"],
|
||||
"commands": [
|
||||
"printenv GCP_KEY | base64 -d > /tmp/key.json",
|
||||
"gcloud auth activate-service-account --key-file=/tmp/key.json",
|
||||
"bash -c 'gcloud storage cp {} grafana.zip'".format(path),
|
||||
],
|
||||
"environment": {
|
||||
"GCP_KEY": from_secret(rgm_gcp_key_base64),
|
||||
},
|
||||
}
|
||||
|
||||
def windows_msi_pipeline(target = "", name = "", trigger = {}, depends_on = [], environment = {}):
|
||||
"""windows_msi_pipeline is a pipeline which creates an MSI from a .zip file.
|
||||
|
||||
Args:
|
||||
target: GCS path (with gs:// scheme) to the oflder containing the zip file
|
||||
name: Name of the pipeline, should be unique.
|
||||
trigger: The conditions which trigger the pipeline
|
||||
depends_on: dependencies (strings)
|
||||
environment: map of environment variables
|
||||
Returns:
|
||||
Drone step.
|
||||
"""
|
||||
nssm = download_nssm_step()
|
||||
wix = download_wix_step()
|
||||
grabpl = download_grabpl_step()
|
||||
zip = download_zip_step(target = target)
|
||||
build = build_msi_step(
|
||||
depends_on = [
|
||||
nssm["name"],
|
||||
wix["name"],
|
||||
grabpl["name"],
|
||||
zip["name"],
|
||||
],
|
||||
)
|
||||
upload = upload_msi_step(
|
||||
depends_on = [
|
||||
build["name"],
|
||||
],
|
||||
target = target,
|
||||
)
|
||||
|
||||
return pipeline(
|
||||
name = name,
|
||||
steps = [
|
||||
nssm,
|
||||
wix,
|
||||
zip,
|
||||
grabpl,
|
||||
build,
|
||||
upload,
|
||||
],
|
||||
trigger = trigger,
|
||||
depends_on = depends_on,
|
||||
environment = environment,
|
||||
)
|
||||
|
||||
def windows_pipeline_release(name = "prerelease-windows-msi", depends_on = [], trigger = {}, environment = {}):
|
||||
target = "gs://grafana-prerelease/artifacts/downloads/$${DRONE_TAG}/oss/release"
|
||||
return windows_msi_pipeline(name = name, target = target, depends_on = depends_on, trigger = trigger, environment = environment)
|
||||
|
||||
def windows_pipeline_main(depends_on = [], trigger = {}, environment = {}):
|
||||
target = "gs://grafana-downloads/oss/main"
|
||||
return windows_msi_pipeline(name = "main-windows-msi", target = target, depends_on = depends_on, trigger = trigger, environment = environment)
|
||||
|
||||
def upload_msi_step(depends_on = [], target = ""):
|
||||
return {
|
||||
"name": "upload-msi-installer",
|
||||
"image": images["cloudsdk"],
|
||||
"commands": [
|
||||
"printenv GCP_KEY | base64 -d > /tmp/key.json",
|
||||
"gcloud auth activate-service-account --key-file=/tmp/key.json",
|
||||
"bash -c 'gcloud storage cp *.msi {}'".format(target),
|
||||
"bash -c 'gcloud storage cp *.msi.sha256 {}'".format(target),
|
||||
],
|
||||
"depends_on": depends_on,
|
||||
"environment": {
|
||||
"GCP_KEY": from_secret(rgm_gcp_key_base64),
|
||||
},
|
||||
}
|
||||
|
||||
def build_msi_step(depends_on = []):
|
||||
return {
|
||||
"name": "build-msi",
|
||||
"image": images["wine"],
|
||||
"entrypoint": ["/bin/bash"],
|
||||
"commands": [
|
||||
"export WINEPATH=$(winepath ./wix3)",
|
||||
"./bin/grabpl windows-installer --target grafana.zip --edition oss",
|
||||
],
|
||||
"depends_on": depends_on,
|
||||
}
|
||||
|
||||
def windows_manual_pipeline():
|
||||
return windows_pipeline_release(
|
||||
name = "windows-pipeline-manual",
|
||||
trigger = {
|
||||
"event": ["promote"],
|
||||
"target": "build-msi",
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user