2020-10-07 07:22:15 -05:00
|
|
|
load(
|
2021-09-07 04:15:04 -05:00
|
|
|
'scripts/drone/steps/lib.star',
|
2021-11-17 03:25:55 -06:00
|
|
|
'download_grabpl_step',
|
|
|
|
'initialize_step',
|
2021-11-15 11:14:33 -06:00
|
|
|
'lint_drone_step',
|
2020-10-07 07:22:15 -05:00
|
|
|
'test_release_ver',
|
|
|
|
'build_image',
|
|
|
|
'publish_image',
|
|
|
|
'lint_backend_step',
|
2021-09-30 02:56:08 -05:00
|
|
|
'lint_frontend_step',
|
2020-10-07 07:22:15 -05:00
|
|
|
'codespell_step',
|
|
|
|
'shellcheck_step',
|
|
|
|
'test_backend_step',
|
2021-10-11 04:23:55 -05:00
|
|
|
'test_backend_integration_step',
|
2020-10-07 07:22:15 -05:00
|
|
|
'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',
|
2021-04-06 08:50:54 -05:00
|
|
|
'redis_integration_tests_step',
|
2021-04-07 08:06:10 -05:00
|
|
|
'memcached_integration_tests_step',
|
2020-10-07 07:22:15 -05:00
|
|
|
'get_windows_steps',
|
|
|
|
'benchmark_ldap_step',
|
|
|
|
'frontend_metrics_step',
|
|
|
|
'publish_storybook_step',
|
|
|
|
'upload_packages_step',
|
2020-12-23 08:42:20 -06:00
|
|
|
'publish_packages_step',
|
2021-09-07 02:21:49 -05:00
|
|
|
'upload_cdn_step',
|
2021-10-08 07:47:55 -05:00
|
|
|
'validate_scuemata_step',
|
|
|
|
'ensure_cuetsified_step'
|
2021-09-07 02:21:49 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
load(
|
2021-09-07 04:15:04 -05:00
|
|
|
'scripts/drone/services/services.star',
|
2021-09-07 02:21:49 -05:00
|
|
|
'integration_test_services',
|
|
|
|
'ldap_service',
|
|
|
|
)
|
|
|
|
|
|
|
|
load(
|
2021-09-07 04:15:04 -05:00
|
|
|
'scripts/drone/utils/utils.star',
|
2021-09-07 02:21:49 -05:00
|
|
|
'pipeline',
|
|
|
|
'notify_pipeline',
|
2020-10-07 07:22:15 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
def release_npm_packages_step(edition, ver_mode):
|
|
|
|
if edition == 'enterprise':
|
|
|
|
return None
|
|
|
|
|
|
|
|
if ver_mode == 'release':
|
2020-12-04 09:34:03 -06:00
|
|
|
commands = ['./scripts/build/release-packages.sh ${DRONE_TAG}']
|
|
|
|
else:
|
|
|
|
commands = []
|
2020-10-07 07:22:15 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
'name': 'release-npm-packages',
|
|
|
|
'image': build_image,
|
|
|
|
'depends_on': [
|
2020-11-24 08:13:23 -06:00
|
|
|
# Has to run after publish-storybook since this step cleans the files publish-storybook depends on
|
|
|
|
'publish-storybook',
|
2020-10-07 07:22:15 -05:00
|
|
|
],
|
|
|
|
'environment': {
|
|
|
|
'NPM_TOKEN': {
|
|
|
|
'from_secret': 'npm_token',
|
|
|
|
},
|
2021-01-27 08:13:08 -06:00
|
|
|
'GITHUB_PACKAGE_TOKEN': {
|
|
|
|
'from_secret': 'github_package_token',
|
|
|
|
},
|
2020-10-07 07:22:15 -05:00
|
|
|
},
|
|
|
|
'commands': commands,
|
|
|
|
}
|
|
|
|
|
2020-11-25 02:26:16 -06:00
|
|
|
def get_steps(edition, ver_mode):
|
|
|
|
should_publish = ver_mode in ('release', 'test-release',)
|
|
|
|
should_upload = should_publish or ver_mode in ('release-branch',)
|
2021-01-06 06:22:20 -06:00
|
|
|
include_enterprise2 = edition == 'enterprise'
|
2020-11-25 02:26:16 -06:00
|
|
|
|
2020-10-07 07:22:15 -05:00
|
|
|
steps = [
|
|
|
|
codespell_step(),
|
|
|
|
shellcheck_step(),
|
2021-05-04 08:05:39 -05:00
|
|
|
lint_backend_step(edition=edition),
|
2021-09-30 02:56:08 -05:00
|
|
|
lint_frontend_step(),
|
2021-10-11 04:23:55 -05:00
|
|
|
test_backend_step(edition=edition),
|
|
|
|
test_backend_integration_step(edition=edition),
|
2020-10-07 07:22:15 -05:00
|
|
|
test_frontend_step(),
|
2021-11-19 04:35:57 -06:00
|
|
|
postgres_integration_tests_step(edition=edition),
|
|
|
|
mysql_integration_tests_step(edition=edition),
|
2020-10-07 07:22:15 -05:00
|
|
|
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),
|
2021-09-07 02:21:49 -05:00
|
|
|
validate_scuemata_step(),
|
2021-10-08 07:47:55 -05:00
|
|
|
ensure_cuetsified_step(),
|
2021-01-06 06:22:20 -06:00
|
|
|
]
|
|
|
|
|
2021-11-19 04:35:57 -06:00
|
|
|
edition2 = 'enterprise2'
|
2021-01-06 06:22:20 -06:00
|
|
|
if include_enterprise2:
|
|
|
|
steps.extend([
|
2021-05-04 08:05:39 -05:00
|
|
|
lint_backend_step(edition=edition2),
|
2021-10-11 04:23:55 -05:00
|
|
|
test_backend_step(edition=edition2),
|
|
|
|
test_backend_integration_step(edition=edition2),
|
2021-01-06 06:22:20 -06:00
|
|
|
build_backend_step(edition=edition2, ver_mode=ver_mode, variants=['linux-x64']),
|
|
|
|
])
|
|
|
|
|
|
|
|
# Insert remaining steps
|
|
|
|
steps.extend([
|
2021-10-21 01:59:12 -05:00
|
|
|
package_step(edition=edition, ver_mode=ver_mode, include_enterprise2=include_enterprise2),
|
2020-12-23 08:42:20 -06:00
|
|
|
e2e_tests_server_step(edition=edition),
|
2021-02-18 02:16:49 -06:00
|
|
|
e2e_tests_step(edition=edition, tries=3),
|
2020-10-07 07:22:15 -05:00
|
|
|
copy_packages_for_docker_step(),
|
2020-11-25 02:26:16 -06:00
|
|
|
build_docker_images_step(edition=edition, ver_mode=ver_mode, publish=should_publish),
|
|
|
|
build_docker_images_step(edition=edition, ver_mode=ver_mode, ubuntu=True, publish=should_publish),
|
2021-01-06 06:22:20 -06:00
|
|
|
])
|
2021-02-10 01:58:41 -06:00
|
|
|
|
2021-10-14 09:02:45 -05:00
|
|
|
build_storybook = build_storybook_step(edition=edition, ver_mode=ver_mode)
|
|
|
|
if build_storybook:
|
|
|
|
steps.append(build_storybook)
|
|
|
|
|
2021-04-06 08:50:54 -05:00
|
|
|
if include_enterprise2:
|
2021-11-19 04:35:57 -06:00
|
|
|
steps.extend([redis_integration_tests_step(edition=edition2), memcached_integration_tests_step(edition=edition2)])
|
2021-04-06 08:50:54 -05:00
|
|
|
|
2020-11-25 02:26:16 -06:00
|
|
|
if should_upload:
|
2021-09-07 02:21:49 -05:00
|
|
|
steps.append(upload_cdn_step(edition=edition))
|
2020-11-25 02:26:16 -06:00
|
|
|
steps.append(upload_packages_step(edition=edition, ver_mode=ver_mode))
|
|
|
|
if should_publish:
|
2021-10-14 09:02:45 -05:00
|
|
|
publish_step = publish_storybook_step(edition=edition, ver_mode=ver_mode)
|
|
|
|
release_npm_step = release_npm_packages_step(edition=edition, ver_mode=ver_mode)
|
|
|
|
if publish_step:
|
|
|
|
steps.append(publish_step)
|
|
|
|
if release_npm_step:
|
|
|
|
steps.append(release_npm_step)
|
2020-10-07 07:22:15 -05:00
|
|
|
windows_steps = get_windows_steps(edition=edition, ver_mode=ver_mode)
|
|
|
|
|
2021-01-06 06:22:20 -06:00
|
|
|
if include_enterprise2:
|
|
|
|
edition2 = 'enterprise2'
|
2020-12-23 08:42:20 -06:00
|
|
|
steps.extend([
|
2021-10-21 01:59:12 -05:00
|
|
|
package_step(edition=edition2, ver_mode=ver_mode, include_enterprise2=include_enterprise2, variants=['linux-x64']),
|
2021-01-06 06:22:20 -06:00
|
|
|
e2e_tests_server_step(edition=edition2, port=3002),
|
2021-02-18 02:16:49 -06:00
|
|
|
e2e_tests_step(edition=edition2, port=3002, tries=3),
|
2021-09-07 02:21:49 -05:00
|
|
|
upload_cdn_step(edition=edition2),
|
2020-12-23 08:42:20 -06:00
|
|
|
])
|
|
|
|
if should_upload:
|
2021-10-14 09:02:45 -05:00
|
|
|
step = upload_packages_step(edition=edition2, ver_mode=ver_mode)
|
|
|
|
if step:
|
|
|
|
steps.append(step)
|
2020-12-23 08:42:20 -06:00
|
|
|
|
2020-10-07 07:22:15 -05:00
|
|
|
return steps, windows_steps
|
|
|
|
|
2020-11-25 02:26:16 -06:00
|
|
|
def get_oss_pipelines(trigger, ver_mode):
|
2021-11-17 03:25:55 -06:00
|
|
|
edition = 'oss'
|
|
|
|
services = integration_test_services(edition=edition)
|
|
|
|
steps, windows_steps = get_steps(edition=edition, ver_mode=ver_mode)
|
2020-10-07 07:22:15 -05:00
|
|
|
return [
|
|
|
|
pipeline(
|
2021-11-17 03:25:55 -06:00
|
|
|
name='oss-build-{}'.format(ver_mode), edition=edition, trigger=trigger, services=services,
|
|
|
|
steps=[download_grabpl_step()] + initialize_step(edition, platform='linux', ver_mode=ver_mode) + steps,
|
2020-10-07 07:22:15 -05:00
|
|
|
),
|
|
|
|
pipeline(
|
2021-11-17 03:25:55 -06:00
|
|
|
name='oss-windows-{}'.format(ver_mode), edition=edition, trigger=trigger,
|
|
|
|
steps=[download_grabpl_step()] + initialize_step(edition, platform='windows', ver_mode=ver_mode) + windows_steps,
|
|
|
|
platform='windows', depends_on=['oss-build-{}'.format(ver_mode)],
|
2020-10-07 07:22:15 -05:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2020-11-25 02:26:16 -06:00
|
|
|
def get_enterprise_pipelines(trigger, ver_mode):
|
2021-11-17 03:25:55 -06:00
|
|
|
edition = 'enterprise'
|
|
|
|
services = integration_test_services(edition=edition)
|
|
|
|
steps, windows_steps = get_steps(edition=edition, ver_mode=ver_mode)
|
2020-10-07 07:22:15 -05:00
|
|
|
return [
|
|
|
|
pipeline(
|
2021-11-17 03:25:55 -06:00
|
|
|
name='enterprise-build-{}'.format(ver_mode), edition=edition, trigger=trigger, services=services,
|
|
|
|
steps=[download_grabpl_step()] + initialize_step(edition, platform='linux', ver_mode=ver_mode) + steps,
|
2020-10-07 07:22:15 -05:00
|
|
|
),
|
|
|
|
pipeline(
|
2021-11-17 03:25:55 -06:00
|
|
|
name='enterprise-windows-{}'.format(ver_mode), edition=edition, trigger=trigger,
|
|
|
|
steps=[download_grabpl_step()] + initialize_step(edition, platform='windows', ver_mode=ver_mode) + windows_steps,
|
|
|
|
platform='windows', depends_on=['enterprise-build-{}'.format(ver_mode)],
|
2020-10-07 07:22:15 -05:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2020-10-26 03:47:51 -05:00
|
|
|
def release_pipelines(ver_mode='release', trigger=None):
|
2021-04-06 08:50:54 -05:00
|
|
|
# 'enterprise' edition services contain both OSS and enterprise services
|
|
|
|
services = integration_test_services(edition='enterprise')
|
2020-10-26 03:47:51 -05:00
|
|
|
if not trigger:
|
|
|
|
trigger = {
|
|
|
|
'ref': ['refs/tags/v*',],
|
|
|
|
}
|
|
|
|
|
2020-11-25 02:26:16 -06:00
|
|
|
should_publish = ver_mode in ('release', 'test-release',)
|
2020-10-07 07:22:15 -05:00
|
|
|
|
|
|
|
# The release pipelines include also enterprise ones, so both editions are built for a release.
|
|
|
|
# We could also solve this by triggering a downstream build for the enterprise repo, but by including enterprise
|
|
|
|
# in OSS release builds, we simplify the UX for the release engineer.
|
2020-11-25 02:26:16 -06:00
|
|
|
oss_pipelines = get_oss_pipelines(ver_mode=ver_mode, trigger=trigger)
|
|
|
|
enterprise_pipelines = get_enterprise_pipelines(ver_mode=ver_mode, trigger=trigger)
|
2020-10-26 03:47:51 -05:00
|
|
|
|
|
|
|
pipelines = oss_pipelines + enterprise_pipelines
|
2020-11-25 02:26:16 -06:00
|
|
|
if should_publish:
|
2021-11-17 03:25:55 -06:00
|
|
|
steps = [
|
|
|
|
publish_packages_step(edition='oss', ver_mode=ver_mode),
|
|
|
|
publish_packages_step(edition='enterprise', ver_mode=ver_mode),
|
|
|
|
]
|
2020-10-26 03:47:51 -05:00
|
|
|
publish_pipeline = pipeline(
|
2021-11-17 03:25:55 -06:00
|
|
|
name='publish-{}'.format(ver_mode), trigger=trigger, edition='oss',
|
|
|
|
steps=[download_grabpl_step()] + initialize_step(edition='oss', platform='linux', ver_mode=ver_mode, install_deps=False) + steps,
|
|
|
|
depends_on=[p['name'] for p in oss_pipelines + enterprise_pipelines],
|
2020-10-26 03:47:51 -05:00
|
|
|
)
|
|
|
|
pipelines.append(publish_pipeline)
|
2020-10-07 07:22:15 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def test_release_pipelines():
|
|
|
|
ver_mode = 'test-release'
|
|
|
|
|
2021-04-06 08:50:54 -05:00
|
|
|
services = integration_test_services(edition='enterprise')
|
2020-10-07 07:22:15 -05:00
|
|
|
trigger = {
|
|
|
|
'event': ['custom',],
|
|
|
|
}
|
|
|
|
|
2020-11-25 02:26:16 -06:00
|
|
|
oss_pipelines = get_oss_pipelines(ver_mode=ver_mode, trigger=trigger)
|
|
|
|
enterprise_pipelines = get_enterprise_pipelines(ver_mode=ver_mode, trigger=trigger)
|
2020-10-07 07:22:15 -05:00
|
|
|
|
|
|
|
publish_cmd = './bin/grabpl publish-packages --edition {{}} --dry-run {}'.format(test_release_ver)
|
|
|
|
|
2021-11-17 03:25:55 -06:00
|
|
|
steps = [
|
|
|
|
publish_packages_step(edition='oss', ver_mode=ver_mode),
|
|
|
|
publish_packages_step(edition='enterprise', ver_mode=ver_mode),
|
|
|
|
]
|
|
|
|
|
2020-10-07 07:22:15 -05:00
|
|
|
publish_pipeline = pipeline(
|
2021-11-17 03:25:55 -06:00
|
|
|
name='publish-{}'.format(ver_mode), trigger=trigger, edition='oss',
|
|
|
|
steps=[download_grabpl_step()] + initialize_step(edition='oss', platform='linux', ver_mode=ver_mode, install_deps=False) + steps,
|
|
|
|
depends_on=[p['name'] for p in oss_pipelines + enterprise_pipelines],
|
2020-10-07 07:22:15 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
pipelines = oss_pipelines + enterprise_pipelines + [publish_pipeline,]
|
|
|
|
|
|
|
|
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
|