Commit 07897c7e by Arve Knudsen Committed by GitHub

Drone: Add version branch pipeline (#28490)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent de35d76f
load('scripts/pr.star', 'pr_pipelines')
load('scripts/master.star', 'master_pipelines')
load('scripts/release.star', 'release_pipelines', 'test_release_pipelines')
load('scripts/version.star', 'version_branch_pipelines')
def main(ctx):
edition = 'oss'
return pr_pipelines(edition=edition) + master_pipelines(edition=edition) + release_pipelines() + \
test_release_pipelines()
test_release_pipelines() + version_branch_pipelines()
......@@ -118,17 +118,17 @@ def init_steps(edition, platform, ver_mode, is_downstream=False, install_deps=Tr
'yarn install --frozen-lockfile --no-progress',
])
if edition == 'enterprise':
source_commit = ''
if ver_mode == 'release':
committish = '${DRONE_TAG}'
source_commit = ' ${DRONE_TAG}'
elif ver_mode == 'test-release':
committish = 'master'
source_commit = ''
elif ver_mode == 'version-branch':
committish = '${DRONE_BRANCH}'
else:
if is_downstream:
source_commit = ' $${SOURCE_COMMIT}'
else:
source_commit = ''
committish = '${DRONE_COMMIT}'
steps = [
identify_runner_step,
......@@ -523,7 +523,7 @@ def package_step(edition, ver_mode, variants=None, is_downstream=False):
variants_str = ' --variants {}'.format(','.join(variants))
else:
variants_str = ''
if ver_mode in ('master', 'release', 'test-release',):
if ver_mode in ('master', 'release', 'test-release', 'version-branch'):
sign_args = ' --sign'
env = {
'GRAFANA_API_KEY': {
......@@ -856,7 +856,9 @@ def get_windows_steps(edition, ver_mode, is_downstream=False):
'commands': init_cmds,
},
]
if (ver_mode == 'master' and (edition != 'enterprise' or is_downstream)) or ver_mode in ('release', 'test-release'):
if (ver_mode == 'master' and (edition != 'enterprise' or is_downstream)) or ver_mode in (
'release', 'test-release', 'version-branch',
):
bucket_part = ''
bucket = 'grafana-downloads'
if ver_mode == 'release':
......@@ -883,10 +885,15 @@ def get_windows_steps(edition, ver_mode, is_downstream=False):
'rm gcpkey.json',
'cp C:\\App\\nssm-2.24.zip .',
'.\\grabpl.exe windows-installer --edition {}{} {}'.format(edition, bucket_part, ver_part),
'$$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0]',
'gsutil cp $$fname gs://{}/{}/{}/'.format(bucket, edition, dir),
'gsutil cp "$$fname.sha256" gs://{}/{}/{}/'.format(bucket, edition, dir),
]
if (ver_mode == 'master' and (edition != 'enterprise' or is_downstream)) or ver_mode in (
'release', 'test-release',
):
installer_commands.extend([
'$$fname = ((Get-Childitem grafana*.msi -name) -split "`n")[0]',
'gsutil cp $$fname gs://{}/{}/{}/'.format(bucket, edition, dir),
'gsutil cp "$$fname.sha256" gs://{}/{}/{}/'.format(bucket, edition, dir),
])
steps.append({
'name': 'build-windows-installer',
'image': wix_image,
......@@ -906,6 +913,8 @@ def get_windows_steps(edition, ver_mode, is_downstream=False):
committish = '${DRONE_TAG}'
elif ver_mode == 'test-release':
committish = 'master'
elif ver_mode == 'version-branch':
committish = '$$env:DRONE_BRANCH'
else:
committish = '$$env:DRONE_COMMIT'
# For enterprise, we have to clone both OSS and enterprise and merge the latter into the former
......
load(
'scripts/lib.star',
'build_image',
'pipeline',
'lint_backend_step',
'codespell_step',
'shellcheck_step',
'test_backend_step',
'test_frontend_step',
'build_backend_step',
'build_frontend_step',
'build_plugins_step',
'package_step',
'e2e_tests_server_step',
'e2e_tests_step',
'build_storybook_step',
'copy_packages_for_docker_step',
'build_docker_images_step',
'postgres_integration_tests_step',
'mysql_integration_tests_step',
'get_windows_steps',
'benchmark_ldap_step',
'ldap_service',
'frontend_metrics_step',
'upload_packages_step',
'notify_pipeline',
'integration_test_services',
)
ver_mode = 'version-branch'
def get_steps(edition):
steps = [
lint_backend_step(edition),
codespell_step(),
shellcheck_step(),
test_backend_step(),
test_frontend_step(),
build_backend_step(edition=edition, ver_mode=ver_mode),
build_frontend_step(edition=edition, ver_mode=ver_mode),
build_plugins_step(edition=edition, sign=True),
package_step(edition=edition, ver_mode=ver_mode),
e2e_tests_server_step(),
e2e_tests_step(),
build_storybook_step(edition=edition, ver_mode=ver_mode),
copy_packages_for_docker_step(),
build_docker_images_step(edition=edition, ver_mode=ver_mode),
build_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True),
postgres_integration_tests_step(),
mysql_integration_tests_step(),
]
windows_steps = get_windows_steps(edition=edition, ver_mode=ver_mode)
return steps, windows_steps
def get_oss_pipelines(trigger):
services = integration_test_services()
steps, windows_steps = get_steps(edition='oss')
return [
pipeline(
name='oss-build-{}'.format(ver_mode), edition='oss', trigger=trigger, services=services, steps=steps,
ver_mode=ver_mode,
),
pipeline(
name='oss-windows-{}'.format(ver_mode), edition='oss', trigger=trigger, steps=windows_steps,
platform='windows', depends_on=['oss-build-{}'.format(ver_mode)], ver_mode=ver_mode,
),
]
def get_enterprise_pipelines(trigger):
services = integration_test_services()
steps, windows_steps = get_steps(edition='enterprise')
return [
pipeline(
name='enterprise-build-{}'.format(ver_mode), edition='enterprise', trigger=trigger, services=services,
steps=steps, ver_mode=ver_mode,
),
pipeline(
name='enterprise-windows-{}'.format(ver_mode), edition='enterprise', trigger=trigger, steps=windows_steps,
platform='windows', depends_on=['enterprise-build-{}'.format(ver_mode)], ver_mode=ver_mode,
),
]
def version_branch_pipelines():
services = integration_test_services()
trigger = {
'ref': ['refs/heads/v*',],
}
oss_pipelines = get_oss_pipelines(trigger=trigger)
enterprise_pipelines = get_enterprise_pipelines(trigger=trigger)
pipelines = oss_pipelines + enterprise_pipelines
pipelines.append(notify_pipeline(
name='notify-{}'.format(ver_mode), slack_channel='grafana-ci-notifications', trigger=trigger,
depends_on=[p['name'] for p in pipelines],
))
return pipelines
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment