mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CI: Replace enterprise check (#62359)
* Add steps in the pipeline for cloning enterprise when running PR tests. * Removed enterprise-check from the github action workflows, and removed it from the codeowners file.
This commit is contained in:
145
.drone.yml
145
.drone.yml
@@ -147,10 +147,31 @@ steps:
|
||||
- yarn-install
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: betterer-frontend
|
||||
- commands:
|
||||
- is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST"
|
||||
| jq .head.repo.fork)
|
||||
- if [ "$is_fork" != false ]; then return 1; fi
|
||||
- git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"
|
||||
../grafana-enterprise
|
||||
- cd ../grafana-enterprise
|
||||
- if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}";
|
||||
elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}";
|
||||
else git checkout main; fi
|
||||
- cd ../
|
||||
- ln -s src grafana
|
||||
- cd ./grafana-enterprise
|
||||
- ./build.sh
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: github_token
|
||||
failure: ignore
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: clone-enterprise
|
||||
- commands:
|
||||
- yarn run ci:test-frontend
|
||||
depends_on:
|
||||
- yarn-install
|
||||
- clone-enterprise
|
||||
environment:
|
||||
TEST_MAX_WORKERS: 50%
|
||||
image: grafana/build-container:v1.7.1
|
||||
@@ -189,6 +210,26 @@ platform:
|
||||
os: linux
|
||||
services: []
|
||||
steps:
|
||||
- commands:
|
||||
- is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST"
|
||||
| jq .head.repo.fork)
|
||||
- if [ "$is_fork" != false ]; then return 1; fi
|
||||
- git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"
|
||||
../grafana-enterprise
|
||||
- cd ../grafana-enterprise
|
||||
- if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}";
|
||||
elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}";
|
||||
else git checkout main; fi
|
||||
- cd ../
|
||||
- ln -s src grafana
|
||||
- cd ./grafana-enterprise
|
||||
- ./build.sh
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: github_token
|
||||
failure: ignore
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: clone-enterprise
|
||||
- commands:
|
||||
- echo $DRONE_RUNNER_NAME
|
||||
image: alpine:3.15.6
|
||||
@@ -205,6 +246,7 @@ steps:
|
||||
- yarn run typecheck
|
||||
depends_on:
|
||||
- yarn-install
|
||||
- clone-enterprise
|
||||
environment:
|
||||
TEST_MAX_WORKERS: 50%
|
||||
image: grafana/build-container:v1.7.1
|
||||
@@ -243,6 +285,26 @@ platform:
|
||||
os: linux
|
||||
services: []
|
||||
steps:
|
||||
- commands:
|
||||
- is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST"
|
||||
| jq .head.repo.fork)
|
||||
- if [ "$is_fork" != false ]; then return 1; fi
|
||||
- git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"
|
||||
../grafana-enterprise
|
||||
- cd ../grafana-enterprise
|
||||
- if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}";
|
||||
elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}";
|
||||
else git checkout main; fi
|
||||
- cd ../
|
||||
- ln -s src grafana
|
||||
- cd ./grafana-enterprise
|
||||
- ./build.sh
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: github_token
|
||||
failure: ignore
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: clone-enterprise
|
||||
- commands:
|
||||
- echo $DRONE_RUNNER_NAME
|
||||
image: alpine:3.15.6
|
||||
@@ -260,7 +322,8 @@ steps:
|
||||
- '# The following command will fail if running code generators produces any diff
|
||||
in output.'
|
||||
- CODEGEN_VERIFY=1 make gen-cue
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: verify-gen-cue
|
||||
- commands:
|
||||
@@ -268,7 +331,8 @@ steps:
|
||||
- '# The following command will fail if running code generators produces any diff
|
||||
in output.'
|
||||
- CODEGEN_VERIFY=1 make gen-jsonnet
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: verify-gen-jsonnet
|
||||
- commands:
|
||||
@@ -338,9 +402,30 @@ steps:
|
||||
CGO_ENABLED: 0
|
||||
image: golang:1.19.4
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST"
|
||||
| jq .head.repo.fork)
|
||||
- if [ "$is_fork" != false ]; then return 1; fi
|
||||
- git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"
|
||||
../grafana-enterprise
|
||||
- cd ../grafana-enterprise
|
||||
- if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}";
|
||||
elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}";
|
||||
else git checkout main; fi
|
||||
- cd ../
|
||||
- ln -s src grafana
|
||||
- cd ./grafana-enterprise
|
||||
- ./build.sh
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: github_token
|
||||
failure: ignore
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: clone-enterprise
|
||||
- commands:
|
||||
- make gen-go
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: wire-install
|
||||
- commands:
|
||||
@@ -727,6 +812,26 @@ services:
|
||||
- name: mysql
|
||||
path: /var/lib/mysql
|
||||
steps:
|
||||
- commands:
|
||||
- is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST"
|
||||
| jq .head.repo.fork)
|
||||
- if [ "$is_fork" != false ]; then return 1; fi
|
||||
- git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"
|
||||
../grafana-enterprise
|
||||
- cd ../grafana-enterprise
|
||||
- if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}";
|
||||
elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}";
|
||||
else git checkout main; fi
|
||||
- cd ../
|
||||
- ln -s src grafana
|
||||
- cd ./grafana-enterprise
|
||||
- ./build.sh
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: github_token
|
||||
failure: ignore
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: clone-enterprise
|
||||
- commands:
|
||||
- mkdir -p bin
|
||||
- curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v3.0.20/grabpl
|
||||
@@ -750,7 +855,8 @@ steps:
|
||||
- '# The following command will fail if running code generators produces any diff
|
||||
in output.'
|
||||
- CODEGEN_VERIFY=1 make gen-cue
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: verify-gen-cue
|
||||
- commands:
|
||||
@@ -758,7 +864,8 @@ steps:
|
||||
- '# The following command will fail if running code generators produces any diff
|
||||
in output.'
|
||||
- CODEGEN_VERIFY=1 make gen-jsonnet
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: verify-gen-jsonnet
|
||||
- commands:
|
||||
@@ -1717,6 +1824,26 @@ services:
|
||||
- name: mysql
|
||||
path: /var/lib/mysql
|
||||
steps:
|
||||
- commands:
|
||||
- is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST"
|
||||
| jq .head.repo.fork)
|
||||
- if [ "$is_fork" != false ]; then return 1; fi
|
||||
- git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"
|
||||
../grafana-enterprise
|
||||
- cd ../grafana-enterprise
|
||||
- if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}";
|
||||
elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}";
|
||||
else git checkout main; fi
|
||||
- cd ../
|
||||
- ln -s src grafana
|
||||
- cd ./grafana-enterprise
|
||||
- ./build.sh
|
||||
environment:
|
||||
GITHUB_TOKEN:
|
||||
from_secret: github_token
|
||||
failure: ignore
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: clone-enterprise
|
||||
- commands:
|
||||
- mkdir -p bin
|
||||
- curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v3.0.20/grabpl
|
||||
@@ -1740,7 +1867,8 @@ steps:
|
||||
- '# The following command will fail if running code generators produces any diff
|
||||
in output.'
|
||||
- CODEGEN_VERIFY=1 make gen-cue
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: verify-gen-cue
|
||||
- commands:
|
||||
@@ -1748,7 +1876,8 @@ steps:
|
||||
- '# The following command will fail if running code generators produces any diff
|
||||
in output.'
|
||||
- CODEGEN_VERIFY=1 make gen-jsonnet
|
||||
depends_on: []
|
||||
depends_on:
|
||||
- clone-enterprise
|
||||
image: grafana/build-container:v1.7.1
|
||||
name: verify-gen-jsonnet
|
||||
- commands:
|
||||
@@ -6516,6 +6645,6 @@ kind: secret
|
||||
name: aws_secret_access_key
|
||||
---
|
||||
kind: signature
|
||||
hmac: 34e5513fe0155e3ca6a7e0cf8b908cc67a0565c963ef3c55688bff2837392900
|
||||
hmac: a46e69b6221d00313d924e36021b8f956a6cfa18c23a6a063891b586075717b9
|
||||
|
||||
...
|
||||
|
||||
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -577,7 +577,6 @@ embed.go @grafana/grafana-as-code
|
||||
/.github/workflows/commands.yml @torkelo
|
||||
/.github/workflows/detect-breaking-changes-* @grafana/plugins-platform-frontend
|
||||
/.github/workflows/doc-validator.yml @grafana/docs-grafana
|
||||
/.github/workflows/enterprise-pr-check.yml @grafana/grafana-release-eng
|
||||
/.github/workflows/epic-add-to-platform-ux-parent-project.yml @meanmina
|
||||
/.github/workflows/github-release.yml @torkelo
|
||||
/.github/workflows/issue-labeled.yml @armandgrillet
|
||||
|
||||
26
.github/workflows/enterprise-pr-check.yml
vendored
26
.github/workflows/enterprise-pr-check.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: Enterprise PR check
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- 'v[0-9]+.[0-9]+.x'
|
||||
jobs:
|
||||
dispatch:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Actions
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: "grafana/grafana-github-actions"
|
||||
path: ./actions
|
||||
ref: main
|
||||
- name: Install Actions
|
||||
run: npm install --production --prefix ./actions
|
||||
- name: Repository Dispatch
|
||||
uses: ./actions/repository-dispatch
|
||||
with:
|
||||
token: ${{ secrets.GH_BOT_ACCESS_TOKEN }}
|
||||
repository: grafana/grafana-enterprise
|
||||
event_type: oss-pull-request
|
||||
client_payload:
|
||||
'{"source_sha": "${{ github.event.pull_request.head.sha }}", "source_branch": "${{ github.head_ref }}", "target_branch": "${{ github.base_ref }}", "pr_number": "${{ github.event.number }}"}'
|
||||
@@ -99,7 +99,7 @@ func BuildGrafanaBinary(ctx context.Context, name, version string, args BuildArg
|
||||
|
||||
descriptor := GrafanaDescriptor(opts)
|
||||
|
||||
log.Printf("Building %q for %s\nwith env: %v", binary, descriptor, opts.Env())
|
||||
log.Printf("Building %q for %s", binary, descriptor)
|
||||
|
||||
opts.LdFlags = append(args.LdFlags, GrafanaLDFlags(version, revision)...)
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ def oss_pipelines(ver_mode = ver_mode, trigger = release_trigger):
|
||||
Returns:
|
||||
List of Drone pipelines.
|
||||
"""
|
||||
|
||||
environment = {"EDITION": "oss"}
|
||||
|
||||
services = integration_test_services(edition = "oss")
|
||||
@@ -257,11 +258,11 @@ def enterprise_pipelines(ver_mode = ver_mode, trigger = release_trigger):
|
||||
List of Drone pipelines.
|
||||
"""
|
||||
if ver_mode == "release":
|
||||
committish = "${DRONE_TAG}"
|
||||
source = "${DRONE_TAG}"
|
||||
elif ver_mode == "release-branch":
|
||||
committish = "${DRONE_BRANCH}"
|
||||
source = "${DRONE_BRANCH}"
|
||||
else:
|
||||
committish = "${DRONE_COMMIT}"
|
||||
source = "${DRONE_COMMIT}"
|
||||
|
||||
environment = {"EDITION": "enterprise"}
|
||||
|
||||
@@ -271,7 +272,7 @@ def enterprise_pipelines(ver_mode = ver_mode, trigger = release_trigger):
|
||||
init_steps = [
|
||||
download_grabpl_step(),
|
||||
identify_runner_step(),
|
||||
clone_enterprise_step(committish = committish),
|
||||
clone_enterprise_step(source = source),
|
||||
init_enterprise_step(ver_mode),
|
||||
compile_build_cmd("enterprise"),
|
||||
] + with_deps(
|
||||
@@ -365,8 +366,8 @@ def enterprise_pipelines(ver_mode = ver_mode, trigger = release_trigger):
|
||||
environment = environment,
|
||||
volumes = volumes,
|
||||
),
|
||||
test_frontend_enterprise(trigger, ver_mode, committish = committish),
|
||||
test_backend_enterprise(trigger, ver_mode, committish = committish),
|
||||
test_frontend_enterprise(trigger, ver_mode, source = source),
|
||||
test_backend_enterprise(trigger, ver_mode, source = source),
|
||||
pipeline(
|
||||
name = "{}-enterprise-integration-tests".format(ver_mode),
|
||||
edition = "enterprise",
|
||||
@@ -375,7 +376,7 @@ def enterprise_pipelines(ver_mode = ver_mode, trigger = release_trigger):
|
||||
steps = [
|
||||
download_grabpl_step(),
|
||||
identify_runner_step(),
|
||||
clone_enterprise_step(committish = committish),
|
||||
clone_enterprise_step(source = source),
|
||||
init_enterprise_step(ver_mode),
|
||||
] +
|
||||
with_deps(
|
||||
@@ -419,11 +420,11 @@ def enterprise2_pipelines(prefix = "", ver_mode = ver_mode, trigger = release_tr
|
||||
List of Drone pipelines.
|
||||
"""
|
||||
if ver_mode == "release":
|
||||
committish = "${DRONE_TAG}"
|
||||
source = "${DRONE_TAG}"
|
||||
elif ver_mode == "release-branch":
|
||||
committish = "${DRONE_BRANCH}"
|
||||
source = "${DRONE_BRANCH}"
|
||||
else:
|
||||
committish = "${DRONE_COMMIT}"
|
||||
source = "${DRONE_COMMIT}"
|
||||
|
||||
environment = {
|
||||
"EDITION": "enterprise2",
|
||||
@@ -434,7 +435,7 @@ def enterprise2_pipelines(prefix = "", ver_mode = ver_mode, trigger = release_tr
|
||||
init_steps = [
|
||||
download_grabpl_step(),
|
||||
identify_runner_step(),
|
||||
clone_enterprise_step(committish = committish),
|
||||
clone_enterprise_step(source = source),
|
||||
init_enterprise_step(ver_mode),
|
||||
compile_build_cmd("enterprise"),
|
||||
] + with_deps(
|
||||
|
||||
@@ -39,7 +39,7 @@ load(
|
||||
|
||||
# @unused
|
||||
def build_e2e(trigger, ver_mode):
|
||||
"""Perform e2e building, testing, and publishing."
|
||||
"""Perform e2e building, testing, and publishing.
|
||||
|
||||
Args:
|
||||
trigger: controls which events can trigger the pipeline execution.
|
||||
@@ -48,6 +48,7 @@ def build_e2e(trigger, ver_mode):
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
|
||||
edition = "oss"
|
||||
environment = {"EDITION": edition}
|
||||
init_steps = [
|
||||
|
||||
@@ -6,6 +6,7 @@ load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"compile_build_cmd",
|
||||
"download_grabpl_step",
|
||||
"enterprise_setup_step",
|
||||
"identify_runner_step",
|
||||
"mysql_integration_tests_step",
|
||||
"postgres_integration_tests_step",
|
||||
@@ -23,12 +24,13 @@ load(
|
||||
"pipeline",
|
||||
)
|
||||
|
||||
def integration_tests(trigger, prefix):
|
||||
def integration_tests(trigger, prefix, ver_mode = "pr"):
|
||||
"""Generate a pipeline for integration tests.
|
||||
|
||||
Args:
|
||||
trigger: controls which events can trigger the pipeline execution.
|
||||
prefix: used in the naming of the pipeline.
|
||||
ver_mode: defines the event / origin of this build. In this function, if it is set to pr, then it will attempt to clone grafana-enterprise. Otherwise it has no effect.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
@@ -38,12 +40,26 @@ def integration_tests(trigger, prefix):
|
||||
services = integration_test_services(edition = "oss")
|
||||
volumes = integration_test_services_volumes()
|
||||
|
||||
init_steps = [
|
||||
init_steps = []
|
||||
|
||||
verify_step = verify_gen_cue_step()
|
||||
verify_jsonnet_step = verify_gen_jsonnet_step()
|
||||
|
||||
if ver_mode == "pr":
|
||||
# In pull requests, attempt to clone grafana enterprise.
|
||||
init_steps.append(enterprise_setup_step())
|
||||
|
||||
# Ensure that verif_gen_cue happens after we clone enterprise
|
||||
# At the time of writing this, very_gen_cue is depended on by the wire step which is what everything else depends on.
|
||||
verify_step["depends_on"].append("clone-enterprise")
|
||||
verify_jsonnet_step["depends_on"].append("clone-enterprise")
|
||||
|
||||
init_steps += [
|
||||
download_grabpl_step(),
|
||||
compile_build_cmd(),
|
||||
identify_runner_step(),
|
||||
verify_gen_cue_step(),
|
||||
verify_gen_jsonnet_step(),
|
||||
verify_step,
|
||||
verify_jsonnet_step,
|
||||
wire_install_step(),
|
||||
]
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ This module returns the pipeline used for linting backend code.
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"compile_build_cmd",
|
||||
"enterprise_setup_step",
|
||||
"identify_runner_step",
|
||||
"lint_backend_step",
|
||||
"lint_drone_step",
|
||||
@@ -33,9 +34,15 @@ def lint_backend_pipeline(trigger, ver_mode):
|
||||
init_steps = [
|
||||
identify_runner_step(),
|
||||
compile_build_cmd(),
|
||||
wire_step,
|
||||
]
|
||||
|
||||
if ver_mode == "pr":
|
||||
# In pull requests, attempt to clone grafana enterprise.
|
||||
init_steps.append(enterprise_setup_step())
|
||||
wire_step["depends_on"].append("clone-enterprise")
|
||||
|
||||
init_steps.append(wire_step)
|
||||
|
||||
test_steps = [
|
||||
lint_backend_step(),
|
||||
]
|
||||
|
||||
@@ -4,6 +4,7 @@ This module returns the pipeline used for linting frontend code.
|
||||
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"enterprise_setup_step",
|
||||
"identify_runner_step",
|
||||
"lint_frontend_step",
|
||||
"yarn_install_step",
|
||||
@@ -25,13 +26,22 @@ def lint_frontend_pipeline(trigger, ver_mode):
|
||||
"""
|
||||
environment = {"EDITION": "oss"}
|
||||
|
||||
init_steps = [
|
||||
init_steps = []
|
||||
lint_step = lint_frontend_step()
|
||||
|
||||
if ver_mode == "pr":
|
||||
# In pull requests, attempt to clone grafana enterprise.
|
||||
init_steps = [enterprise_setup_step()]
|
||||
# Ensure the lint step happens after the clone-enterprise step
|
||||
|
||||
lint_step["depends_on"].append("clone-enterprise")
|
||||
|
||||
init_steps += [
|
||||
identify_runner_step(),
|
||||
yarn_install_step(),
|
||||
]
|
||||
|
||||
test_steps = [
|
||||
lint_frontend_step(),
|
||||
lint_step,
|
||||
]
|
||||
|
||||
return pipeline(
|
||||
|
||||
@@ -2,16 +2,12 @@
|
||||
This module returns the pipeline used for testing backend code.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
"with_deps",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"clone_enterprise_step",
|
||||
"compile_build_cmd",
|
||||
"download_grabpl_step",
|
||||
"enterprise_setup_step",
|
||||
"identify_runner_step",
|
||||
"init_enterprise_step",
|
||||
"test_backend_integration_step",
|
||||
@@ -20,6 +16,11 @@ load(
|
||||
"verify_gen_jsonnet_step",
|
||||
"wire_install_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
"with_deps",
|
||||
)
|
||||
|
||||
def test_backend(trigger, ver_mode):
|
||||
"""Generates the pipeline used for testing OSS backend code.
|
||||
@@ -33,11 +34,25 @@ def test_backend(trigger, ver_mode):
|
||||
"""
|
||||
environment = {"EDITION": "oss"}
|
||||
|
||||
steps = [
|
||||
steps = []
|
||||
|
||||
verify_step = verify_gen_cue_step()
|
||||
verify_jsonnet_step = verify_gen_jsonnet_step()
|
||||
|
||||
if ver_mode == "pr":
|
||||
# In pull requests, attempt to clone grafana enterprise.
|
||||
steps.append(enterprise_setup_step())
|
||||
|
||||
# Ensure that verif_gen_cue happens after we clone enterprise
|
||||
# At the time of writing this, very_gen_cue is depended on by the wire step which is what everything else depends on.
|
||||
verify_step["depends_on"].append("clone-enterprise")
|
||||
verify_jsonnet_step["depends_on"].append("clone-enterprise")
|
||||
|
||||
steps += [
|
||||
identify_runner_step(),
|
||||
compile_build_cmd(edition = "oss"),
|
||||
verify_gen_cue_step(),
|
||||
verify_gen_jsonnet_step(),
|
||||
verify_step,
|
||||
verify_jsonnet_step,
|
||||
wire_install_step(),
|
||||
test_backend_step(),
|
||||
test_backend_integration_step(),
|
||||
@@ -55,13 +70,13 @@ def test_backend(trigger, ver_mode):
|
||||
environment = environment,
|
||||
)
|
||||
|
||||
def test_backend_enterprise(trigger, ver_mode, committish, edition = "enterprise"):
|
||||
def test_backend_enterprise(trigger, ver_mode, source, edition = "enterprise"):
|
||||
"""Generates the pipeline used for testing backend enterprise code.
|
||||
|
||||
Args:
|
||||
trigger: a Drone trigger for the pipeline.
|
||||
ver_mode: affects the pipeline name.
|
||||
committish: controls what revision of enterprise code to test with.
|
||||
source: controls what revision of enterprise code to test with. The source of the PR, usually.
|
||||
edition: affects the clone step in the pipeline and also affects the pipeline name.
|
||||
|
||||
Returns:
|
||||
@@ -71,7 +86,7 @@ def test_backend_enterprise(trigger, ver_mode, committish, edition = "enterprise
|
||||
|
||||
steps = (
|
||||
[
|
||||
clone_enterprise_step(committish),
|
||||
clone_enterprise_step(source),
|
||||
download_grabpl_step(),
|
||||
init_enterprise_step(ver_mode),
|
||||
identify_runner_step(),
|
||||
|
||||
@@ -2,21 +2,22 @@
|
||||
This module returns the pipeline used for testing backend code.
|
||||
"""
|
||||
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
"with_deps",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/steps/lib.star",
|
||||
"betterer_frontend_step",
|
||||
"clone_enterprise_step",
|
||||
"download_grabpl_step",
|
||||
"enterprise_setup_step",
|
||||
"identify_runner_step",
|
||||
"init_enterprise_step",
|
||||
"test_frontend_step",
|
||||
"yarn_install_step",
|
||||
)
|
||||
load(
|
||||
"scripts/drone/utils/utils.star",
|
||||
"pipeline",
|
||||
"with_deps",
|
||||
)
|
||||
|
||||
def test_frontend(trigger, ver_mode):
|
||||
"""Generates the pipeline used for testing frontend code.
|
||||
@@ -35,12 +36,24 @@ def test_frontend(trigger, ver_mode):
|
||||
download_grabpl_step(),
|
||||
yarn_install_step(),
|
||||
betterer_frontend_step(edition = "oss"),
|
||||
test_frontend_step(edition = "oss"),
|
||||
]
|
||||
|
||||
pipeline_name = "{}-test-frontend".format(ver_mode)
|
||||
|
||||
test_step = test_frontend_step(edition = "oss")
|
||||
|
||||
if ver_mode == "pr":
|
||||
# In pull requests, attempt to clone grafana enterprise.
|
||||
steps.append(enterprise_setup_step())
|
||||
|
||||
# Also, make the test step depend on 'clone-enterprise
|
||||
test_step["depends_on"].append("clone-enterprise")
|
||||
|
||||
steps.append(test_step)
|
||||
|
||||
pipeline_name = "{}-test-frontend".format(ver_mode)
|
||||
if ver_mode in ("release-branch", "release"):
|
||||
pipeline_name = "{}-{}-test-frontend".format(ver_mode, "oss")
|
||||
pipeline_name = "{}-oss-test-frontend".format(ver_mode)
|
||||
|
||||
return pipeline(
|
||||
name = pipeline_name,
|
||||
@@ -50,23 +63,22 @@ def test_frontend(trigger, ver_mode):
|
||||
environment = environment,
|
||||
)
|
||||
|
||||
def test_frontend_enterprise(trigger, ver_mode, committish, edition = "enterprise"):
|
||||
def test_frontend_enterprise(trigger, ver_mode, source, edition = "enterprise"):
|
||||
"""Generates the pipeline used for testing frontend enterprise code.
|
||||
|
||||
Args:
|
||||
trigger: a Drone trigger for the pipeline.
|
||||
ver_mode: affects the pipeline name.
|
||||
committish: controls what revision of enterprise code to test with.
|
||||
source: controls what revision of Grafana code to test with.
|
||||
edition: affects the clone step in the pipeline and also affects the pipeline name.
|
||||
|
||||
Returns:
|
||||
Drone pipeline.
|
||||
"""
|
||||
environment = {"EDITION": edition}
|
||||
|
||||
steps = (
|
||||
[
|
||||
clone_enterprise_step(committish),
|
||||
clone_enterprise_step(source),
|
||||
init_enterprise_step(ver_mode),
|
||||
identify_runner_step(),
|
||||
download_grabpl_step(),
|
||||
|
||||
@@ -75,16 +75,26 @@ def identify_runner_step(platform = "linux"):
|
||||
],
|
||||
}
|
||||
|
||||
def clone_enterprise_step(committish = "${DRONE_COMMIT}"):
|
||||
def enterprise_setup_step(source = "${DRONE_SOURCE_BRANCH}", canFail = True):
|
||||
step = clone_enterprise_step_pr(source = source, target = "${DRONE_TARGET_BRANCH}", canFail = canFail, location = "../grafana-enterprise")
|
||||
step["commands"] += [
|
||||
"cd ../",
|
||||
"ln -s src grafana",
|
||||
"cd ./grafana-enterprise",
|
||||
"./build.sh",
|
||||
]
|
||||
|
||||
return step
|
||||
|
||||
def clone_enterprise_step(source = "${DRONE_COMMIT}"):
|
||||
"""Clone the enterprise source into the ./grafana-enterprise directory.
|
||||
|
||||
Args:
|
||||
committish: controls which revision of grafana-enterprise is cloned.
|
||||
|
||||
source: controls which revision of grafana-enterprise is checked out, if it exists. The name 'source' derives from the 'source branch' of a pull request.
|
||||
Returns:
|
||||
Drone step.
|
||||
"""
|
||||
return {
|
||||
step = {
|
||||
"name": "clone-enterprise",
|
||||
"image": build_image,
|
||||
"environment": {
|
||||
@@ -93,10 +103,43 @@ def clone_enterprise_step(committish = "${DRONE_COMMIT}"):
|
||||
"commands": [
|
||||
'git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git"',
|
||||
"cd grafana-enterprise",
|
||||
"git checkout {}".format(committish),
|
||||
"git checkout {}".format(source),
|
||||
],
|
||||
}
|
||||
|
||||
return step
|
||||
|
||||
def clone_enterprise_step_pr(source = "${DRONE_COMMIT}", target = "main", canFail = False, location = "grafana-enterprise"):
|
||||
"""Clone the enterprise source into the ./grafana-enterprise directory.
|
||||
|
||||
Args:
|
||||
source: controls which revision of grafana-enterprise is checked out, if it exists. The name 'source' derives from the 'source branch' of a pull request.
|
||||
target: controls which revision of grafana-enterprise is checked out, if it 'source' does not exist. The name 'target' derives from the 'target branch' of a pull request. If this does not exist, then 'main' will be checked out.
|
||||
canFail: controls whether or not this step is allowed to fail. If it fails and this is true, then the pipeline will continue. canFail is used in pull request pipelines where enterprise may be cloned but may not clone in forks.
|
||||
location: the path where grafana-enterprise is cloned.
|
||||
Returns:
|
||||
Drone step.
|
||||
"""
|
||||
step = {
|
||||
"name": "clone-enterprise",
|
||||
"image": build_image,
|
||||
"environment": {
|
||||
"GITHUB_TOKEN": from_secret("github_token"),
|
||||
},
|
||||
"commands": [
|
||||
'is_fork=$(curl "https://$GITHUB_TOKEN@api.github.com/repos/grafana/grafana/pulls/$DRONE_PULL_REQUEST" | jq .head.repo.fork)',
|
||||
'if [ "$is_fork" != false ]; then return 1; fi', # Only clone if we're confident that 'fork' is 'false'. Fail if it's also empty.
|
||||
'git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git" ' + location,
|
||||
"cd {}".format(location),
|
||||
'if git checkout {0}; then echo "checked out {0}"; elif git checkout {1}; then echo "git checkout {1}"; else git checkout main; fi'.format(source, target),
|
||||
],
|
||||
}
|
||||
|
||||
if canFail:
|
||||
step["failure"] = "ignore"
|
||||
|
||||
return step
|
||||
|
||||
def init_enterprise_step(ver_mode):
|
||||
"""Adds the enterprise deployment configuration into the source directory.
|
||||
|
||||
@@ -1265,11 +1308,11 @@ def get_windows_steps(edition, ver_mode):
|
||||
|
||||
if edition in ("enterprise", "enterprise2"):
|
||||
if ver_mode == "release":
|
||||
committish = "${DRONE_TAG}"
|
||||
source = "${DRONE_TAG}"
|
||||
elif ver_mode == "release-branch":
|
||||
committish = "$$env:DRONE_BRANCH"
|
||||
source = "$$env:DRONE_BRANCH"
|
||||
else:
|
||||
committish = "$$env:DRONE_COMMIT"
|
||||
source = "$$env:DRONE_COMMIT"
|
||||
|
||||
# For enterprise, we have to clone both OSS and enterprise and merge the latter into the former
|
||||
download_grabpl_cmds = [
|
||||
@@ -1282,7 +1325,7 @@ def get_windows_steps(edition, ver_mode):
|
||||
clone_cmds = [
|
||||
'git clone "https://$$env:GITHUB_TOKEN@github.com/grafana/grafana-enterprise.git"',
|
||||
"cd grafana-enterprise",
|
||||
"git checkout {}".format(committish),
|
||||
"git checkout {}".format(source),
|
||||
]
|
||||
|
||||
init_cmds = [
|
||||
|
||||
Reference in New Issue
Block a user