[v9.4.x] CI: Update RGM steps to use the artifacts command (#77474)

CI: Update RGM steps to use the artifacts command (#77470)

* update rgm steps to use artifacts subcmd

* format-drone

* make drone

(cherry picked from commit 8a5d4c4c6e)
This commit is contained in:
Kevin Minehart
2023-10-31 15:40:17 -07:00
committed by GitHub
parent 5730aa95bb
commit 2972ee8a22
5 changed files with 98 additions and 70 deletions
+59 -45
View File
@@ -17,7 +17,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
@@ -67,7 +67,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
@@ -117,7 +117,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -217,7 +217,7 @@ steps:
name: clone-enterprise
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -291,7 +291,7 @@ steps:
name: clone-enterprise
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -375,7 +375,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
@@ -461,7 +461,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- mkdir -p bin
@@ -532,9 +532,9 @@ steps:
token:
from_secret: drone_token
- commands:
- /src/grafana-build package --distro=linux/amd64,linux/arm64 --go-version=1.20.10
--yarn-cache=$$YARN_CACHE_FOLDER --build-id=$$DRONE_BUILD_NUMBER --grafana-dir=$$PWD
> packages.txt
- /src/grafana-build artifacts -a targz:grafana:linux/amd64 -a targz:grafana:linux/arm64
--go-version=1.20.10 --yarn-cache=$$YARN_CACHE_FOLDER --build-id=$$DRONE_BUILD_NUMBER
--grafana-dir=$$PWD > packages.txt
depends_on:
- yarn-install
image: grafana/grafana-build:main
@@ -555,7 +555,7 @@ steps:
GF_APP_MODE: development
GF_SERVER_HTTP_PORT: "3001"
GF_SERVER_ROUTER_LOGGING: "1"
image: alpine:3.18.3
image: alpine:3.18.4
name: grafana-server
- commands:
- ./bin/build e2e-tests --port 3001 --suite dashboards-suite
@@ -675,13 +675,15 @@ steps:
name: test-a11y-frontend
- commands:
- docker run --privileged --rm tonistiigi/binfmt --install all
- /src/grafana-build docker $(cat packages.txt | grep tar.gz | grep -v docker |
grep -v sha256 | awk '{print "--package=" $0}') --ubuntu-base=ubuntu:22.04 --alpine-base=alpine:3.18.3
--tag-format='{{ .version_base }}-{{ .buildID }}-{{ .arch }}' --ubuntu-tag-format='{{
.version_base }}-{{ .buildID }}-ubuntu-{{ .arch }}' > docker.txt
- /src/grafana-build artifacts -a docker:grafana:linux/amd64 -a docker:grafana:linux/amd64:ubuntu
-a docker:grafana:linux/arm64 -a docker:grafana:linux/arm64:ubuntu --yarn-cache=$$YARN_CACHE_FOLDER
--build-id=$$DRONE_BUILD_NUMBER --ubuntu-base=ubuntu:22.04 --alpine-base=alpine:3.18.4
--tag-format='{{ .version_base }}-{{ .buildID }}-{{ .arch }}' --grafana-dir=$$PWD
--ubuntu-tag-format='{{ .version_base }}-{{ .buildID }}-ubuntu-{{ .arch }}' >
docker.txt
- find ./dist -name '*docker*.tar.gz' -type f | xargs -n1 docker load -i
depends_on:
- rgm-package
- yarn-install
image: grafana/grafana-build:main
name: rgm-build-docker
pull: always
@@ -820,7 +822,7 @@ steps:
name: compile-build-cmd
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -1006,7 +1008,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -1299,7 +1301,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -1373,7 +1375,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -1430,7 +1432,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -1482,7 +1484,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -1561,7 +1563,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
@@ -1626,7 +1628,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- mkdir -p bin
@@ -1696,11 +1698,11 @@ steps:
image: node:18.12.0-alpine
name: build-frontend-packages
- commands:
- /src/grafana-build package --distro=linux/amd64,linux/arm64 --go-version=1.20.10
--yarn-cache=$$YARN_CACHE_FOLDER --build-id=$$DRONE_BUILD_NUMBER --grafana-dir=$$PWD
> packages.txt
- /src/grafana-build artifacts -a targz:grafana:linux/amd64 -a targz:grafana:linux/arm64
--go-version=1.20.10 --yarn-cache=$$YARN_CACHE_FOLDER --build-id=$$DRONE_BUILD_NUMBER
--grafana-dir=$$PWD > packages.txt
depends_on:
- yarn-install
- update-package-json-version
image: grafana/grafana-build:main
name: rgm-package
pull: always
@@ -1719,7 +1721,7 @@ steps:
GF_APP_MODE: development
GF_SERVER_HTTP_PORT: "3001"
GF_SERVER_ROUTER_LOGGING: "1"
image: alpine:3.18.3
image: alpine:3.18.4
name: grafana-server
- commands:
- ./bin/build e2e-tests --port 3001 --suite dashboards-suite
@@ -1875,13 +1877,15 @@ steps:
- grafana/grafana
- commands:
- docker run --privileged --rm tonistiigi/binfmt --install all
- /src/grafana-build docker $(cat packages.txt | grep tar.gz | grep -v docker |
grep -v sha256 | awk '{print "--package=" $0}') --ubuntu-base=ubuntu:22.04 --alpine-base=alpine:3.18.3
--tag-format='{{ .version_base }}-{{ .buildID }}-{{ .arch }}' --ubuntu-tag-format='{{
.version_base }}-{{ .buildID }}-ubuntu-{{ .arch }}' > docker.txt
- /src/grafana-build artifacts -a docker:grafana:linux/amd64 -a docker:grafana:linux/amd64:ubuntu
-a docker:grafana:linux/arm64 -a docker:grafana:linux/arm64:ubuntu --yarn-cache=$$YARN_CACHE_FOLDER
--build-id=$$DRONE_BUILD_NUMBER --ubuntu-base=ubuntu:22.04 --alpine-base=alpine:3.18.4
--tag-format='{{ .version_base }}-{{ .buildID }}-{{ .arch }}' --grafana-dir=$$PWD
--ubuntu-tag-format='{{ .version_base }}-{{ .buildID }}-ubuntu-{{ .arch }}' >
docker.txt
- find ./dist -name '*docker*.tar.gz' -type f | xargs -n1 docker load -i
depends_on:
- rgm-package
- yarn-install
image: grafana/grafana-build:main
name: rgm-build-docker
pull: always
@@ -2082,7 +2086,7 @@ steps:
name: compile-build-cmd
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -2395,7 +2399,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- mkdir -p bin
@@ -2727,6 +2731,7 @@ steps:
environment:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN:
from_secret: dagger_token
ALPINE_BASE: alpine:3.18.4
CDN_DESTINATION:
from_secret: rgm_cdn_destination
DESTINATION:
@@ -2754,6 +2759,7 @@ steps:
from_secret: npm_token
STORYBOOK_DESTINATION:
from_secret: rgm_storybook_destination
UBUNTU_BASE: ubuntu:22.04
image: grafana/grafana-build:main
name: rgm-build
pull: always
@@ -2840,7 +2846,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -2895,7 +2901,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -2976,6 +2982,7 @@ steps:
environment:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN:
from_secret: dagger_token
ALPINE_BASE: alpine:3.18.4
CDN_DESTINATION:
from_secret: rgm_cdn_destination
DESTINATION:
@@ -3003,6 +3010,7 @@ steps:
from_secret: npm_token
STORYBOOK_DESTINATION:
from_secret: rgm_storybook_destination
UBUNTU_BASE: ubuntu:22.04
image: grafana/grafana-build:main
name: rgm-build
pull: always
@@ -3154,6 +3162,7 @@ steps:
environment:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN:
from_secret: dagger_token
ALPINE_BASE: alpine:3.18.4
CDN_DESTINATION:
from_secret: rgm_cdn_destination
DESTINATION:
@@ -3181,6 +3190,7 @@ steps:
from_secret: npm_token
STORYBOOK_DESTINATION:
from_secret: rgm_storybook_destination
UBUNTU_BASE: ubuntu:22.04
image: grafana/grafana-build:main
name: rgm-build
pull: always
@@ -3252,7 +3262,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- yarn install --immutable
@@ -3305,7 +3315,7 @@ services: []
steps:
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -3384,6 +3394,7 @@ steps:
environment:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN:
from_secret: dagger_token
ALPINE_BASE: alpine:3.18.4
CDN_DESTINATION:
from_secret: rgm_cdn_destination
DESTINATION:
@@ -3411,6 +3422,7 @@ steps:
from_secret: npm_token
STORYBOOK_DESTINATION:
from_secret: rgm_storybook_destination
UBUNTU_BASE: ubuntu:22.04
image: grafana/grafana-build:main
name: rgm-build
pull: always
@@ -3528,6 +3540,7 @@ steps:
environment:
_EXPERIMENTAL_DAGGER_CLOUD_TOKEN:
from_secret: dagger_token
ALPINE_BASE: alpine:3.18.4
CDN_DESTINATION:
from_secret: rgm_cdn_destination
DESTINATION:
@@ -3555,6 +3568,7 @@ steps:
from_secret: npm_token
STORYBOOK_DESTINATION:
from_secret: rgm_storybook_destination
UBUNTU_BASE: ubuntu:22.04
image: grafana/grafana-build:main
name: rgm-publish
pull: always
@@ -3735,7 +3749,7 @@ steps:
name: grabpl
- commands:
- echo $DRONE_RUNNER_NAME
image: alpine:3.18.3
image: alpine:3.18.4
name: identify-runner
- commands:
- '# It is required that code generated from Thema/CUE be committed and in sync
@@ -3957,7 +3971,7 @@ steps:
- commands:
- if [ -z "${BUILD_CONTAINER_VERSION}" ]; then echo Missing BUILD_CONTAINER_VERSION;
false; fi
image: alpine:3.18.3
image: alpine:3.18.4
name: validate-version
- commands:
- printenv GCP_KEY > /tmp/key.json
@@ -4281,7 +4295,7 @@ steps:
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM node:18.12.0-alpine
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM google/cloud-sdk:431.0.0
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/grafana-ci-deploy:1.3.3
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM alpine:3.18.3
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM alpine:3.18.4
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM ubuntu:22.04
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM byrnedo/alpine-curl:0.1.8
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM plugins/slack
@@ -4315,7 +4329,7 @@ steps:
- trivy --exit-code 1 --severity HIGH,CRITICAL node:18.12.0-alpine
- trivy --exit-code 1 --severity HIGH,CRITICAL google/cloud-sdk:431.0.0
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/grafana-ci-deploy:1.3.3
- trivy --exit-code 1 --severity HIGH,CRITICAL alpine:3.18.3
- trivy --exit-code 1 --severity HIGH,CRITICAL alpine:3.18.4
- trivy --exit-code 1 --severity HIGH,CRITICAL ubuntu:22.04
- trivy --exit-code 1 --severity HIGH,CRITICAL byrnedo/alpine-curl:0.1.8
- trivy --exit-code 1 --severity HIGH,CRITICAL plugins/slack
@@ -4559,6 +4573,6 @@ kind: secret
name: gcr_credentials
---
kind: signature
hmac: aca8af17bf23f40ebc7015377f8ec559d0ab2280be959d74aa076aca67975550
hmac: b62d31b05e01279b55e4d29aeb12248dd8f7b399d72a72ff827e3d5d2c4869b0
...
+10 -4
View File
@@ -28,8 +28,8 @@ load(
)
load(
"scripts/drone/steps/rgm.star",
"rgm_artifacts_step",
"rgm_build_docker_step",
"rgm_package_step",
)
load(
"scripts/drone/utils/images.star",
@@ -70,17 +70,25 @@ def build_e2e(trigger, ver_mode):
[
build_frontend_package_step(),
enterprise_downstream_step(ver_mode = ver_mode),
rgm_artifacts_step(artifacts = ["targz:grafana:linux/amd64", "targz:grafana:linux/arm64"], file = "packages.txt"),
],
)
else:
build_steps.extend([
update_package_json_version(),
build_frontend_package_step(depends_on = ["update-package-json-version"]),
rgm_artifacts_step(
artifacts = [
"targz:grafana:linux/amd64",
"targz:grafana:linux/arm64",
],
depends_on = ["update-package-json-version"],
file = "packages.txt",
),
])
build_steps.extend(
[
rgm_package_step(distros = "linux/amd64,linux/arm64", file = "packages.txt"),
grafana_server_step(),
e2e_tests_step("dashboards-suite"),
e2e_tests_step("smoke-tests-suite"),
@@ -103,7 +111,6 @@ def build_e2e(trigger, ver_mode):
store_storybook_step(trigger = trigger_oss, ver_mode = ver_mode),
frontend_metrics_step(trigger = trigger_oss),
rgm_build_docker_step(
"packages.txt",
images["ubuntu"],
images["alpine"],
tag_format = "{{ .version_base }}-{{ .buildID }}-{{ .arch }}",
@@ -134,7 +141,6 @@ def build_e2e(trigger, ver_mode):
build_steps.extend(
[
rgm_build_docker_step(
"packages.txt",
images["ubuntu"],
images["alpine"],
tag_format = "{{ .version_base }}-{{ .buildID }}-{{ .arch }}",
+2
View File
@@ -137,6 +137,8 @@ def rgm_run(name, script):
"""
env = {
"GO_VERSION": golang_version,
"ALPINE_BASE": images["alpine"],
"UBUNTU_BASE": images["ubuntu"],
}
rgm_run_step = {
"name": name,
+26 -20
View File
@@ -8,15 +8,25 @@ load(
"golang_version",
)
# rgm_package_step will create a tar.gz for use in e2e tests or other PR testing related activities..
def rgm_package_step(distros = "linux/amd64,linux/arm64", file = "packages.txt"):
def artifacts_cmd(artifacts = []):
cmd = "/src/grafana-build 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"]):
cmd = artifacts_cmd(artifacts = artifacts)
return {
"name": "rgm-package",
"name": name,
"image": "grafana/grafana-build:main",
"pull": "always",
"depends_on": ["yarn-install"],
"depends_on": depends_on,
"commands": [
"/src/grafana-build package --distro={} ".format(distros) +
cmd +
"--go-version={} ".format(golang_version) +
"--yarn-cache=$$YARN_CACHE_FOLDER " +
"--build-id=$$DRONE_BUILD_NUMBER " +
@@ -28,31 +38,27 @@ def rgm_package_step(distros = "linux/amd64,linux/arm64", file = "packages.txt")
# rgm_build_backend will create compile the grafana backend for various platforms. It's preferred to use
# 'rgm_package_step' if you creating a "usable" artifact. This should really only be used to verify that the code is
# compilable.
def rgm_build_backend_step(distros = "linux/amd64,linux/arm64"):
return {
"name": "rgm-package",
"image": "grafana/grafana-build:main",
"pull": "always",
"commands": [
"/src/grafana-build build " +
"--go-version={} ".format(golang_version) +
"--distro={} --grafana-dir=$$PWD".format(distros),
],
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
}
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(packages, ubuntu, alpine, depends_on = ["rgm-package"], file = "docker.txt", tag_format = "{{ .version }}-{{ .arch }}", ubuntu_tag_format = "{{ .version }}-ubuntu-{{ .arch }}"):
def rgm_build_docker_step(ubuntu, alpine, depends_on = ["yarn-install"], file = "docker.txt", tag_format = "{{ .version }}-{{ .arch }}", ubuntu_tag_format = "{{ .version }}-ubuntu-{{ .arch }}"):
return {
"name": "rgm-build-docker",
"image": "grafana/grafana-build:main",
"pull": "always",
"commands": [
"docker run --privileged --rm tonistiigi/binfmt --install all",
"/src/grafana-build docker " +
"$(cat {} | grep tar.gz | grep -v docker | grep -v sha256 | awk '{{print \"--package=\" $0}}') ".format(packages) +
"/src/grafana-build artifacts " +
"-a docker:grafana:linux/amd64 " +
"-a docker:grafana:linux/amd64:ubuntu " +
"-a docker:grafana:linux/arm64 " +
"-a docker:grafana:linux/arm64:ubuntu " +
"--yarn-cache=$$YARN_CACHE_FOLDER " +
"--build-id=$$DRONE_BUILD_NUMBER " +
"--ubuntu-base={} ".format(ubuntu) +
"--alpine-base={} ".format(alpine) +
"--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",
],
+1 -1
View File
@@ -14,7 +14,7 @@ images = {
"node": "node:{}-alpine".format(nodejs_version),
"cloudsdk": "google/cloud-sdk:431.0.0",
"publish": "grafana/grafana-ci-deploy:1.3.3",
"alpine": "alpine:3.18.3",
"alpine": "alpine:3.18.4",
"ubuntu": "ubuntu:22.04",
"curl": "byrnedo/alpine-curl:0.1.8",
"plugins_slack": "plugins/slack",