diff --git a/.drone.yml b/.drone.yml index 08df14dd6d5..7b860298c21 100644 --- a/.drone.yml +++ b/.drone.yml @@ -100,6 +100,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -205,6 +206,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -460,6 +462,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -788,6 +791,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -882,6 +886,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -1303,6 +1308,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -1567,6 +1573,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -1864,6 +1871,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -1996,6 +2004,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -2575,13 +2584,13 @@ steps: image: grafana/build-container:1.5.7 name: lint-frontend - commands: - - ./bin/grabpl test-backend --edition enterprise + - go test -short -covermode=atomic -timeout=30m ./pkg/... depends_on: - wire-install image: grafana/build-container:1.5.7 name: test-backend - commands: - - ./bin/grabpl integration-tests --edition enterprise + - go test -run Integration -covermode=atomic -timeout=30m ./pkg/... depends_on: - wire-install image: grafana/build-container:1.5.7 @@ -2603,17 +2612,11 @@ steps: image: grafana/build-container:1.5.7 name: lint-backend-enterprise2 - commands: - - ./bin/grabpl test-backend --edition enterprise2 + - go test -tags=pro -covermode=atomic -timeout=30m ./pkg/... depends_on: - wire-install image: grafana/build-container:1.5.7 name: test-backend-enterprise2 -- commands: - - ./bin/grabpl integration-tests --edition enterprise2 - depends_on: - - wire-install - image: grafana/build-container:1.5.7 - name: test-backend-integration-enterprise2 trigger: event: exclude: @@ -2704,15 +2707,32 @@ steps: from_secret: github_token image: grafana/build-container:1.5.7 name: init-enterprise +- commands: + - '# It is required that code generated from Thema/CUE be committed and in sync + with its inputs.' + - '# The following command will fail if running code generators produces any diff + in output.' + - CODEGEN_VERIFY=1 make gen-cue + depends_on: + - init-enterprise + image: grafana/build-container:1.5.7 + name: verify-gen-cue +- commands: + - make gen-go + depends_on: + - verify-gen-cue + image: grafana/build-container:1.5.7 + name: wire-install - commands: - apt-get update - apt-get install -yq postgresql-client - dockerize -wait tcp://postgres:5432 -timeout 120s - psql -p 5432 -h postgres -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql - go clean -testcache - - ./bin/grabpl integration-tests --database postgres + - go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic + -timeout=30m {}' depends_on: - - init-enterprise + - wire-install environment: GRAFANA_TEST_DB: postgres PGPASSWORD: grafanatest @@ -2726,9 +2746,10 @@ steps: - cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h mysql -P 3306 -u root -prootpass - go clean -testcache - - ./bin/grabpl integration-tests --database mysql + - go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic + -timeout=30m {}' depends_on: - - init-enterprise + - wire-install environment: GRAFANA_TEST_DB: mysql MYSQL_HOST: mysql @@ -2738,7 +2759,7 @@ steps: - dockerize -wait tcp://redis:6379/0 -timeout 120s - ./bin/grabpl integration-tests depends_on: - - init-enterprise + - wire-install environment: REDIS_URL: redis://redis:6379/0 image: grafana/build-container:1.5.7 @@ -2747,7 +2768,7 @@ steps: - dockerize -wait tcp://memcached:11211 -timeout 120s - ./bin/grabpl integration-tests depends_on: - - init-enterprise + - wire-install environment: MEMCACHED_HOSTS: memcached:11211 image: grafana/build-container:1.5.7 @@ -3395,6 +3416,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -3662,6 +3684,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -3788,6 +3811,7 @@ steps: - '# The following command will fail if running code generators produces any diff in output.' - CODEGEN_VERIFY=1 make gen-cue + depends_on: [] image: grafana/build-container:1.5.7 name: verify-gen-cue - commands: @@ -4345,13 +4369,13 @@ steps: image: grafana/build-container:1.5.7 name: lint-frontend - commands: - - ./bin/grabpl test-backend --edition enterprise + - go test -short -covermode=atomic -timeout=30m ./pkg/... depends_on: - wire-install image: grafana/build-container:1.5.7 name: test-backend - commands: - - ./bin/grabpl integration-tests --edition enterprise + - go test -run Integration -covermode=atomic -timeout=30m ./pkg/... depends_on: - wire-install image: grafana/build-container:1.5.7 @@ -4373,17 +4397,11 @@ steps: image: grafana/build-container:1.5.7 name: lint-backend-enterprise2 - commands: - - ./bin/grabpl test-backend --edition enterprise2 + - go test -tags=pro -covermode=atomic -timeout=30m ./pkg/... depends_on: - wire-install image: grafana/build-container:1.5.7 name: test-backend-enterprise2 -- commands: - - ./bin/grabpl integration-tests --edition enterprise2 - depends_on: - - wire-install - image: grafana/build-container:1.5.7 - name: test-backend-integration-enterprise2 trigger: ref: - refs/heads/v[0-9]* @@ -4465,15 +4483,32 @@ steps: environment: {} image: grafana/build-container:1.5.7 name: init-enterprise +- commands: + - '# It is required that code generated from Thema/CUE be committed and in sync + with its inputs.' + - '# The following command will fail if running code generators produces any diff + in output.' + - CODEGEN_VERIFY=1 make gen-cue + depends_on: + - init-enterprise + image: grafana/build-container:1.5.7 + name: verify-gen-cue +- commands: + - make gen-go + depends_on: + - verify-gen-cue + image: grafana/build-container:1.5.7 + name: wire-install - commands: - apt-get update - apt-get install -yq postgresql-client - dockerize -wait tcp://postgres:5432 -timeout 120s - psql -p 5432 -h postgres -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql - go clean -testcache - - ./bin/grabpl integration-tests --database postgres + - go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic + -timeout=30m {}' depends_on: - - init-enterprise + - wire-install environment: GRAFANA_TEST_DB: postgres PGPASSWORD: grafanatest @@ -4487,9 +4522,10 @@ steps: - cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h mysql -P 3306 -u root -prootpass - go clean -testcache - - ./bin/grabpl integration-tests --database mysql + - go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic + -timeout=30m {}' depends_on: - - init-enterprise + - wire-install environment: GRAFANA_TEST_DB: mysql MYSQL_HOST: mysql @@ -4499,7 +4535,7 @@ steps: - dockerize -wait tcp://redis:6379/0 -timeout 120s - ./bin/grabpl integration-tests depends_on: - - init-enterprise + - wire-install environment: REDIS_URL: redis://redis:6379/0 image: grafana/build-container:1.5.7 @@ -4508,7 +4544,7 @@ steps: - dockerize -wait tcp://memcached:11211 -timeout 120s - ./bin/grabpl integration-tests depends_on: - - init-enterprise + - wire-install environment: MEMCACHED_HOSTS: memcached:11211 image: grafana/build-container:1.5.7 @@ -4747,6 +4783,6 @@ kind: secret name: gcp_upload_artifacts_key --- kind: signature -hmac: 32e54be4bd96844f07ea81b7ac46b37aa10f755074526353afb3420323e0f2f4 +hmac: c9b6fd34c919d871a153c3d82bfe8d62f126f1c672bd14636147cdeafe827c10 ... diff --git a/scripts/drone/pipelines/main.star b/scripts/drone/pipelines/main.star index ffb1c3b9603..0e24f52383b 100644 --- a/scripts/drone/pipelines/main.star +++ b/scripts/drone/pipelines/main.star @@ -93,7 +93,7 @@ def main_test_backend(): identify_runner_step(), download_grabpl_step(), gen_version_step(ver_mode), - verify_gen_cue_step(), + verify_gen_cue_step(edition="oss"), wire_install_step(), ] test_steps = [ @@ -114,7 +114,7 @@ def get_steps(edition): identify_runner_step(), download_grabpl_step(), gen_version_step(ver_mode), - verify_gen_cue_step(), + verify_gen_cue_step(edition="oss"), wire_install_step(), yarn_install_step(), ] @@ -220,7 +220,7 @@ def main_pipelines(edition): volumes=volumes, ), pipeline( name='main-integration-tests', edition=edition, trigger=trigger, services=services, - steps=[download_grabpl_step(), identify_runner_step(), verify_gen_cue_step(), wire_install_step(), ] + integration_test_steps, + steps=[download_grabpl_step(), identify_runner_step(), verify_gen_cue_step(edition="oss"), wire_install_step(), ] + integration_test_steps, volumes=volumes, ), pipeline( name='main-windows', edition=edition, trigger=dict(trigger, repo=['grafana/grafana']), diff --git a/scripts/drone/pipelines/pr.star b/scripts/drone/pipelines/pr.star index 9a8cb1fa0aa..357e3190ac4 100644 --- a/scripts/drone/pipelines/pr.star +++ b/scripts/drone/pipelines/pr.star @@ -91,7 +91,7 @@ def pr_test_backend(): identify_runner_step(), download_grabpl_step(), gen_version_step(ver_mode), - verify_gen_cue_step(), + verify_gen_cue_step(edition="oss"), wire_install_step(), ] test_steps = [ @@ -115,7 +115,7 @@ def pr_pipelines(edition): identify_runner_step(), download_grabpl_step(), gen_version_step(ver_mode), - verify_gen_cue_step(), + verify_gen_cue_step(edition="oss"), wire_install_step(), yarn_install_step(), ] @@ -153,7 +153,7 @@ def pr_pipelines(edition): name='pr-build-e2e', edition=edition, trigger=trigger, services=[], steps=init_steps + build_steps, ), pipeline( name='pr-integration-tests', edition=edition, trigger=trigger, services=services, - steps=[download_grabpl_step(), identify_runner_step(), verify_gen_cue_step(), wire_install_step(), ] + integration_test_steps, + steps=[download_grabpl_step(), identify_runner_step(), verify_gen_cue_step(edition="oss"), wire_install_step(), ] + integration_test_steps, volumes=volumes, ), docs_pipelines(edition, ver_mode, trigger_docs()) ] diff --git a/scripts/drone/pipelines/release.star b/scripts/drone/pipelines/release.star index 0813debed28..8094c8f0ab6 100644 --- a/scripts/drone/pipelines/release.star +++ b/scripts/drone/pipelines/release.star @@ -158,7 +158,7 @@ def get_steps(edition, ver_mode): identify_runner_step(), download_grabpl_step(), gen_version_step(ver_mode), - verify_gen_cue_step(), + verify_gen_cue_step(edition), wire_install_step(), yarn_install_step(), ] @@ -192,7 +192,6 @@ def get_steps(edition, ver_mode): test_steps.extend([ lint_backend_step(edition=edition2), test_backend_step(edition=edition2), - test_backend_integration_step(edition=edition2), ]) build_steps.extend([ build_backend_step(edition=edition2, ver_mode=ver_mode, variants=['linux-amd64']), @@ -272,7 +271,7 @@ def get_oss_pipelines(trigger, ver_mode): ), pipeline( name='{}-oss-integration-tests'.format(ver_mode), edition=edition, trigger=trigger, services=services, - steps=[download_grabpl_step(), identify_runner_step(), verify_gen_cue_step(), wire_install_step(), ] + integration_test_steps, + steps=[download_grabpl_step(), identify_runner_step(), verify_gen_cue_step(edition), wire_install_step(), ] + integration_test_steps, volumes=volumes, ) ]) @@ -304,13 +303,10 @@ def get_enterprise_pipelines(trigger, ver_mode): clone_enterprise_step(ver_mode), init_enterprise_step(ver_mode) ] - for step in [wire_install_step(), yarn_install_step(), gen_version_step(ver_mode), verify_gen_cue_step()]: + for step in [wire_install_step(), yarn_install_step(), gen_version_step(ver_mode), verify_gen_cue_step(edition)]: step.update(deps_on_clone_enterprise_step) init_steps.extend([step]) - for step in integration_test_steps: - step.update(deps_on_clone_enterprise_step) - windows_pipeline = pipeline( name='{}-enterprise-windows'.format(ver_mode), edition=edition, trigger=trigger, steps=[identify_runner_step('windows')] + windows_package_steps, @@ -334,7 +330,7 @@ def get_enterprise_pipelines(trigger, ver_mode): ), pipeline( name='{}-enterprise-integration-tests'.format(ver_mode), edition=edition, trigger=trigger, services=services, - steps=[download_grabpl_step(), identify_runner_step(), clone_enterprise_step(ver_mode), init_enterprise_step(ver_mode),] + integration_test_steps + [redis_integration_tests_step(), memcached_integration_tests_step()], + steps=[download_grabpl_step(), identify_runner_step(), clone_enterprise_step(ver_mode), init_enterprise_step(ver_mode), verify_gen_cue_step(edition), wire_install_step()] + integration_test_steps + [redis_integration_tests_step(), memcached_integration_tests_step()], volumes=volumes, ), ]) diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index b473b9a7103..abfd8bfdffb 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -502,7 +502,18 @@ def build_plugins_step(edition, sign=False): def test_backend_step(edition): - if edition == 'oss': + if edition == 'enterprise2': + return { + 'name': 'test-backend' + enterprise2_suffix(edition), + 'image': build_image, + 'depends_on': [ + 'wire-install', + ], + 'commands': [ + 'go test -tags=pro -covermode=atomic -timeout=30m ./pkg/...', + ], + } + else: return { 'name': 'test-backend' + enterprise2_suffix(edition), 'image': build_image, @@ -513,41 +524,20 @@ def test_backend_step(edition): 'go test -short -covermode=atomic -timeout=30m ./pkg/...', ], } - else: - return { - 'name': 'test-backend' + enterprise2_suffix(edition), - 'image': build_image, - 'depends_on': [ - 'wire-install', - ], - 'commands': [ - './bin/grabpl test-backend --edition {}'.format(edition), - ], - } + + def test_backend_integration_step(edition): - if edition == 'oss': - return { - 'name': 'test-backend-integration', - 'image': build_image, - 'depends_on': [ - 'wire-install', - ], - 'commands': [ - 'go test -run Integration -covermode=atomic -timeout=30m ./pkg/...', - ], - } - else: - return { - 'name': 'test-backend-integration' + enterprise2_suffix(edition), - 'image': build_image, - 'depends_on': [ - 'wire-install', - ], - 'commands': [ - './bin/grabpl integration-tests --edition {}'.format(edition), - ], - } + return { + 'name': 'test-backend-integration', + 'image': build_image, + 'depends_on': [ + 'wire-install', + ], + 'commands': [ + 'go test -run Integration -covermode=atomic -timeout=30m ./pkg/...', + ], + } @@ -869,7 +859,6 @@ def publish_images_step(edition, ver_mode, mode, docker_repo, trigger=None): def postgres_integration_tests_step(edition, ver_mode): - deps = [] cmds = [ 'apt-get update', 'apt-get install -yq postgresql-client', @@ -878,17 +867,12 @@ def postgres_integration_tests_step(edition, ver_mode): 'devenv/docker/blocks/postgres_tests/setup.sql', # Make sure that we don't use cached results for another database 'go clean -testcache', + "go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic -timeout=30m {}'", ] - if edition == 'oss': - deps.extend(['wire-install']) - cmds.extend(["go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic -timeout=30m {}'"]) - else: - deps.extend(['grabpl']) - cmds.extend(['./bin/grabpl integration-tests --database postgres']) return { 'name': 'postgres-integration-tests', 'image': build_image, - 'depends_on': deps, + 'depends_on': ['wire-install'], 'environment': { 'PGPASSWORD': 'grafanatest', 'GRAFANA_TEST_DB': 'postgres', @@ -899,7 +883,6 @@ def postgres_integration_tests_step(edition, ver_mode): def mysql_integration_tests_step(edition, ver_mode): - deps = [] cmds = [ 'apt-get update', 'apt-get install -yq default-mysql-client', @@ -907,17 +890,12 @@ def mysql_integration_tests_step(edition, ver_mode): 'cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h mysql -P 3306 -u root -prootpass', # Make sure that we don't use cached results for another database 'go clean -testcache', + "go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic -timeout=30m {}'", ] - if edition == 'oss': - deps.extend(['wire-install']) - cmds.extend(["go list './pkg/...' | xargs -I {} sh -c 'go test -run Integration -covermode=atomic -timeout=30m {}'"]) - else: - deps.extend(['grabpl']) - cmds.extend(['./bin/grabpl integration-tests --database mysql']) return { 'name': 'mysql-integration-tests', 'image': build_image, - 'depends_on': deps, + 'depends_on': ['wire-install'], 'environment': { 'GRAFANA_TEST_DB': 'mysql', 'MYSQL_HOST': 'mysql', @@ -930,7 +908,7 @@ def redis_integration_tests_step(): return { 'name': 'redis-integration-tests', 'image': build_image, - 'depends_on': ['init-enterprise'], + 'depends_on': ['wire-install'], 'environment': { 'REDIS_URL': 'redis://redis:6379/0', }, @@ -945,7 +923,7 @@ def memcached_integration_tests_step(): return { 'name': 'memcached-integration-tests', 'image': build_image, - 'depends_on': ['init-enterprise'], + 'depends_on': ['wire-install'], 'environment': { 'MEMCACHED_HOSTS': 'memcached:11211', }, @@ -1170,10 +1148,14 @@ def get_windows_steps(edition, ver_mode): return steps -def verify_gen_cue_step(): +def verify_gen_cue_step(edition): + deps = [] + if edition == "enterprise": + deps.extend(['init-enterprise']) return { 'name': 'verify-gen-cue', 'image': build_image, + 'depends_on': deps, 'commands': [ '# It is required that code generated from Thema/CUE be committed and in sync with its inputs.', '# The following command will fail if running code generators produces any diff in output.', diff --git a/scripts/go/bin/revive b/scripts/go/bin/revive new file mode 100755 index 00000000000..ad50cdff926 Binary files /dev/null and b/scripts/go/bin/revive differ