diff options
author | Nathan Friend <nathan@gitlab.com> | 2019-04-16 14:16:04 -0300 |
---|---|---|
committer | Nathan Friend <nathan@gitlab.com> | 2019-04-16 14:16:04 -0300 |
commit | df27723f5854fc579ebdaad973ef90db0322e974 (patch) | |
tree | 22331ac6d0832f589bb8fb1af76ff873fb9dfc52 | |
parent | 6fbfa0607662197817dec0698362271a7b432e6d (diff) | |
download | gitlab-ce-60475-add-ce-ee-vue-template-danger-check-temp.tar.gz |
7 files changed, 77 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f80f1656d6..0be98d8121f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,6 +54,7 @@ after_script: - date stages: + - danger - build - prepare - merge @@ -529,7 +530,7 @@ build-qa-image: danger-review: <<: *pull-cache image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger - stage: test + stage: danger dependencies: [] before_script: [] only: @@ -546,6 +547,7 @@ danger-review: - node --version - yarn install --frozen-lockfile --cache-folder .yarn-cache - danger --fail-on-errors=true + - exit 1 rspec-pg: <<: *rspec-metadata-pg diff --git a/Dangerfile b/Dangerfile index 3e8cb456003..9e3a08949b0 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,3 +1,4 @@ +# frozen_string_literal: true danger.import_plugin('danger/plugins/helper.rb') unless helper.release_automation? @@ -16,4 +17,5 @@ unless helper.release_automation? danger.import_dangerfile(path: 'danger/roulette') danger.import_dangerfile(path: 'danger/single_codebase') danger.import_dangerfile(path: 'danger/gitlab_ui_wg') + danger.import_dangerfile(path: 'danger/ce_ee_vue_templates') end diff --git a/app/assets/javascripts/vue_merge_request_widget/components/deployment.vue b/app/assets/javascripts/vue_merge_request_widget/components/deployment.vue index da0a9483f8e..f6c7f370605 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/deployment.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/deployment.vue @@ -118,6 +118,8 @@ export default { </script> <template> + <!-- testing --> + <div class="deploy-heading"> <div class="ci-widget media"> <div class="media-body"> diff --git a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue index 57c4dfbe3b7..12fa36834c7 100644 --- a/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue +++ b/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue @@ -301,6 +301,8 @@ export default { }; </script> <template> + <!-- testing --> + <div class="mr-state-widget prepend-top-default"> <mr-widget-header :mr="mr" /> <mr-widget-pipeline-container diff --git a/danger/ce_ee_vue_templates/Dangerfile b/danger/ce_ee_vue_templates/Dangerfile new file mode 100644 index 00000000000..f51b20e1c55 --- /dev/null +++ b/danger/ce_ee_vue_templates/Dangerfile @@ -0,0 +1,62 @@ +# frozen_string_literal: true +# rubocop:disable Gitlab/HTTParty +require 'cgi' + +def get_vue_files_with_ce_and_ee_versions(files) + files.select do |file| + if file.end_with?('.vue') + counterpoint_path = if file.start_with?('ee/') + file.sub('ee/', '') + else + "ee/#{file}" + end + + escaped_path = CGI.escape(counterpoint_path) + api_endpoint = "https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-ee/repository/files/#{escaped_path}?ref=master" + response = HTTParty.get(api_endpoint) + response.code != 404 + else + false + end + end +end + +vue_candidates = get_vue_files_with_ce_and_ee_versions(helper.all_changed_files) + +return if vue_candidates.empty? + +message 'This merge request includes changes to Vue files that have both CE and EE versions.' + +markdown(<<~MARKDOWN) + ## Vue `<template>` in CE and EE + + Some Vue files in CE have a counterpart in EE. + (For example, `path/to/file.vue` and `ee/path/to/file.vue`.) + + When run in the context of CE, the `<template>` of the CE Vue file is used. + When run in the context of EE, the `<template>` of the EE Vue file is used. + + It's easy to accidentally make a change to a CE `<template>` that _should_ + appear in both CE and EE without making the change in both places. + When this happens, the change only takes effect in CE. + + The following Vue files were changed as part of this merge request that + include both a CE and EE version of the file: + + * #{vue_candidates.map { |path| "`#{path}`" }.join("\n* ")} + + If you made a change to the `<template>` of any of these Vue files that + should be visible in both CE and EE, please ensure you have made your + change to both versions of the file. + + ### A better alternative + + An even _better_ alternative is to refactor this component to only use + a single template for both CE and EE. More info on this approach here: + https://docs.gitlab.com/ee/development/ee_features.html#template-tag + + ### This will all go away soon + + Thankfully, this soon won't be an issue as we are moving to a + single codebase: https://gitlab.com/groups/gitlab-org/-/epics/802 +MARKDOWN diff --git a/ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue b/ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue new file mode 100644 index 00000000000..865d3d349ba --- /dev/null +++ b/ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.vue @@ -0,0 +1,3 @@ +<script> +export default {}; +</script> diff --git a/ee/app/assets/javascripts/vue_merge_request_widget/testing.vue b/ee/app/assets/javascripts/vue_merge_request_widget/testing.vue new file mode 100644 index 00000000000..865d3d349ba --- /dev/null +++ b/ee/app/assets/javascripts/vue_merge_request_widget/testing.vue @@ -0,0 +1,3 @@ +<script> +export default {}; +</script> |