gitlab-dangerfiles 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- NO_SPECS_LABELS = [
4
- 'backstage', # To be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/222360.
5
- 'tooling',
6
- 'tooling::pipelines',
7
- 'tooling::workflow',
8
- 'documentation',
9
- 'QA'
10
- ].freeze
11
- NO_NEW_SPEC_MESSAGE = <<~MSG
12
- You've made some app changes, but didn't add any tests.
13
- That's OK as long as you're refactoring existing code,
14
- but please consider adding any of the %<labels>s labels.
15
- MSG
16
- EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE = <<~MSG
17
- You've made some EE-specific changes, but only made changes to FOSS tests.
18
- This could be a sign that you're testing an EE-specific behavior in a FOSS test.
19
-
20
- Please make sure the spec files pass in AS-IF-FOSS mode either:
21
-
22
- 1. Locally with `FOSS_ONLY=1 bin/rspec -- %<spec_files>s`.
23
- 1. In the MR pipeline by verifying that the `rspec foss-impact` job has passed.
24
- 1. In the MR pipelines by including `RUN AS-IF-FOSS` in the MR title (you can do it with the ``/title %<mr_title>s [RUN AS-IF-FOSS]`` quick action) and start a new MR pipeline.
25
-
26
- MSG
27
-
28
- has_app_changes = helper.all_changed_files.grep(%r{\A(app|lib|db/(geo/)?(post_)?migrate)/}).any?
29
- has_ee_app_changes = helper.all_changed_files.grep(%r{\Aee/(app|lib|db/(geo/)?(post_)?migrate)/}).any?
30
- spec_changes = helper.all_changed_files.grep(%r{\Aspec/})
31
- has_spec_changes = spec_changes.any?
32
- has_ee_spec_changes = helper.all_changed_files.grep(%r{\Aee/spec/}).any?
33
- new_specs_needed = (gitlab.mr_labels & NO_SPECS_LABELS).empty?
34
-
35
- if (has_app_changes || has_ee_app_changes) && !(has_spec_changes || has_ee_spec_changes) && new_specs_needed
36
- warn format(NO_NEW_SPEC_MESSAGE, labels: helper.labels_list(NO_SPECS_LABELS)), sticky: false
37
- end
38
-
39
- # The only changes outside `ee/` are in `spec/`
40
- if has_ee_app_changes && has_spec_changes && !(has_app_changes || has_ee_spec_changes)
41
- warn format(EE_CHANGE_WITH_FOSS_SPEC_CHANGE_MESSAGE, spec_files: spec_changes.join(" "), mr_title: gitlab.mr_json['title']), sticky: false
42
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- desc "Run local Danger rules"
4
- task :danger_local do
5
- require "gitlab/dangerfiles"
6
- require "popen/danger/popen"
7
-
8
- puts("#{Gitlab::Dangerfiles.local_warning_message}\n")
9
-
10
- # _status will _always_ be 0, regardless of failure or success :(
11
- output, _status = Gitlab::Dangerfiles::Popen.popen(%w{danger dry_run})
12
-
13
- if output.empty?
14
- puts(Gitlab::Dangerfiles.success_message)
15
- else
16
- puts(output)
17
- exit(1)
18
- end
19
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- TELEMETRY_CHANGED_FILES_MESSAGE = <<~MSG
4
- For the following files, a review from the [Data team and Telemetry team](https://gitlab.com/groups/gitlab-org/growth/telemetry/engineers/-/group_members?with_inherited_permissions=exclude) is recommended
5
- Please check the ~telemetry [guide](https://docs.gitlab.com/ee/development/telemetry/usage_ping.html) and reach out to @gitlab-org/growth/telemetry/engineers group for a review.
6
-
7
- %<changed_files>s
8
-
9
- MSG
10
-
11
- tracking_files = [
12
- 'lib/gitlab/tracking.rb',
13
- 'spec/lib/gitlab/tracking_spec.rb',
14
- 'app/helpers/tracking_helper.rb',
15
- 'spec/helpers/tracking_helper_spec.rb',
16
- 'app/assets/javascripts/tracking.js',
17
- 'spec/frontend/tracking_spec.js'
18
- ]
19
-
20
- usage_data_changed_files = git.modified_files.grep(%r{usage_data})
21
- snowplow_events_changed_files = git.modified_files & tracking_files
22
-
23
- changed_files = (usage_data_changed_files + snowplow_events_changed_files)
24
-
25
- if changed_files.any?
26
- warn format(TELEMETRY_CHANGED_FILES_MESSAGE, changed_files: helper.markdown_list(changed_files))
27
-
28
- telemetry_labels = ['telemetry']
29
- telemetry_labels << 'telemetry::review pending' unless helper.mr_has_labels?('telemetry::reviewed')
30
-
31
- markdown(helper.prepare_labels_for_mr(telemetry_labels))
32
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- common = 'app/assets/stylesheets/framework/common.scss'
4
- utilities = 'app/assets/stylesheets/utilities.scss'
5
-
6
- def get_css_files(files, common_filepath, utilities_filepath)
7
- files.select do |file|
8
- file.include?(common_filepath) ||
9
- file.include?(utilities_filepath)
10
- end
11
- end
12
-
13
- changed_util_files = get_css_files(helper.all_changed_files.to_a, common, utilities)
14
-
15
- unless changed_util_files.empty?
16
-
17
- markdown(<<~MARKDOWN)
18
- ## Changes to utility SCSS files
19
- MARKDOWN
20
-
21
- if changed_util_files.include?(common)
22
-
23
- markdown(<<~MARKDOWN)
24
- ### Addition to `#{common}`
25
-
26
- You have added a new rule to `#{common}`. Are you sure you need this rule?
27
-
28
- If it is a component class shared across items, could it be added to the component as a utility class or to the component's stylesheet? If not, you can ignore this warning.
29
-
30
- If it is a new utility class, is there another class that shares the same values in either this file or in `#{utilities}`? If not, please add it to `#{utilities}`, following the [Gitlab UI naming style](https://unpkg.com/browse/@gitlab/ui/src/scss/utilities.scss).
31
-
32
- MARKDOWN
33
-
34
- end
35
-
36
- if changed_util_files.include?(utilities)
37
- markdown(<<~MARKDOWN)
38
- ### Addition to `#{utilities}`
39
-
40
- You have added a new rule to `#{utilities}`. Are you sure you need this rule?
41
-
42
- If it is a component class shared across items, could it be added to the component as a utility class or to the component's stylesheet? If not, consider adding it to `#{common}`
43
-
44
- If it is a new utility class, is there another class that shares the same values in either this file or in `#{utilities}`? If not, please be sure this addition follows the [Gitlab UI naming style](https://unpkg.com/browse/@gitlab/ui/src/scss/utilities.scss) so it may be removed when these rules are included. See [Include gitlab-ui utility-class library](https://gitlab.com/gitlab-org/gitlab/issues/36857) for more about this project.
45
-
46
- MARKDOWN
47
- end
48
-
49
- warn "This merge request adds a new rule to #{common} or #{utilities}."
50
-
51
- end