neetob 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +4 -5
  5. data/CHANGELOG.md +21 -0
  6. data/Gemfile +10 -0
  7. data/Gemfile.lock +15 -1
  8. data/README.md +197 -118
  9. data/bookmarks.md +30 -0
  10. data/data/branch-protection-rules.json +1 -1
  11. data/data/github-labels.json +54 -29
  12. data/images/commit-message-update.png +0 -0
  13. data/lib/neetob/cli/base.rb +22 -10
  14. data/lib/neetob/cli/fetchorupdate_repos/execute.rb +5 -3
  15. data/lib/neetob/cli/github/auth.rb +3 -3
  16. data/lib/neetob/cli/github/base.rb +7 -0
  17. data/lib/neetob/cli/github/commands.rb +6 -2
  18. data/lib/neetob/cli/github/labels/commands.rb +18 -10
  19. data/lib/neetob/cli/github/labels/delete.rb +5 -3
  20. data/lib/neetob/cli/github/labels/delete_all.rb +5 -3
  21. data/lib/neetob/cli/github/labels/list.rb +5 -3
  22. data/lib/neetob/cli/github/labels/show.rb +5 -3
  23. data/lib/neetob/cli/github/labels/update.rb +16 -4
  24. data/lib/neetob/cli/github/labels/upsert.rb +43 -7
  25. data/lib/neetob/cli/github/make_pr/base.rb +2 -1
  26. data/lib/neetob/cli/github/make_pr/commands.rb +4 -1
  27. data/lib/neetob/cli/github/make_pr/compliance_fix.rb +6 -1
  28. data/lib/neetob/cli/github/make_pr/script.rb +4 -3
  29. data/lib/neetob/cli/github/protect_branch.rb +5 -3
  30. data/lib/neetob/cli/heroku/config_vars/upsert.rb +6 -2
  31. data/lib/neetob/cli/heroku/execute.rb +2 -2
  32. data/lib/neetob/cli/ui.rb +1 -1
  33. data/lib/neetob/cli/users/commands.rb +3 -1
  34. data/lib/neetob/cli/users/commits.rb +71 -22
  35. data/lib/neetob/cli.rb +3 -1
  36. data/lib/neetob/exception_handler.rb +3 -1
  37. data/lib/neetob/version.rb +1 -1
  38. data/neetob.gemspec +1 -1
  39. metadata +8 -57
  40. data/LICENSE.txt +0 -21
  41. data/env.sample +0 -1
  42. data/neeto_compliance/lib/neeto_compliance/github_access.rb +0 -29
  43. data/neeto_compliance/lib/neeto_compliance/neeto_apps.rb +0 -35
  44. data/neeto_compliance/lib/neeto_compliance/neeto_commons.rb +0 -16
  45. data/neeto_compliance/lib/neeto_compliance/runner.rb +0 -35
  46. data/neeto_compliance/lib/neeto_compliance/skippable.rb +0 -19
  47. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_bin.rb +0 -32
  48. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_formatters.rb +0 -35
  49. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_husky.rb +0 -33
  50. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_misc.rb +0 -36
  51. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_test_support.rb +0 -38
  52. data/neeto_compliance/lib/neeto_compliance/sync_neeto_commons.rb +0 -36
  53. data/neeto_compliance/lib/neeto_compliance/verifiers/auto_update_prs_with_latest_master_verifier.rb +0 -25
  54. data/neeto_compliance/lib/neeto_compliance/verifiers/base.rb +0 -72
  55. data/neeto_compliance/lib/neeto_compliance/verifiers/bundler_version_verifier.rb +0 -53
  56. data/neeto_compliance/lib/neeto_compliance/verifiers/circleci_config_verifier.rb +0 -25
  57. data/neeto_compliance/lib/neeto_compliance/verifiers/common_gemfile_verifier.rb +0 -25
  58. data/neeto_compliance/lib/neeto_compliance/verifiers/common_initializers_verifier.rb +0 -25
  59. data/neeto_compliance/lib/neeto_compliance/verifiers/cypress_config_verifier.rb +0 -46
  60. data/neeto_compliance/lib/neeto_compliance/verifiers/cypress_plugins_index_verifier.rb +0 -25
  61. data/neeto_compliance/lib/neeto_compliance/verifiers/docker_file_dev_verifier.rb +0 -25
  62. data/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb +0 -38
  63. data/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb +0 -38
  64. data/neeto_compliance/lib/neeto_compliance/verifiers/gems_verifier_base.rb +0 -34
  65. data/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb +0 -39
  66. data/neeto_compliance/lib/neeto_compliance/verifiers/jsconfig_verifier.rb +0 -100
  67. data/neeto_compliance/lib/neeto_compliance/verifiers/neeto_auth_gems_verifier.rb +0 -20
  68. data/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb +0 -42
  69. data/neeto_compliance/lib/neeto_compliance/verifiers/neeto_gems_version_verifier.rb +0 -24
  70. data/neeto_compliance/lib/neeto_compliance/verifiers/newrelic_verifier.rb +0 -25
  71. data/neeto_compliance/lib/neeto_compliance/verifiers/node_version_verifier.rb +0 -63
  72. data/neeto_compliance/lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb +0 -62
  73. data/neeto_compliance/lib/neeto_compliance/verifiers/package_json_verifier.rb +0 -39
  74. data/neeto_compliance/lib/neeto_compliance/verifiers/roles_verifier.rb +0 -22
  75. data/neeto_compliance/lib/neeto_compliance/verifiers/ruby_version_verifier.rb +0 -25
  76. data/neeto_compliance/lib/neeto_compliance/verifiers/semaphoreci_config_verifier.rb +0 -162
  77. data/neeto_compliance/lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb +0 -34
  78. data/neeto_compliance/lib/neeto_compliance/verifiers/simplecov_config_verifier.rb +0 -28
  79. data/neeto_compliance/lib/neeto_compliance/verifiers/sitemap_config_verifier.rb +0 -29
  80. data/neeto_compliance/lib/neeto_compliance/verifiers/slugignore_file_verifier.rb +0 -25
  81. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/bin_files_verifier.rb +0 -29
  82. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/formatter_files_verifier.rb +0 -29
  83. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/husky_files_verifier.rb +0 -29
  84. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/misc_files_verifier.rb +0 -29
  85. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/test_support_files_verifier.rb +0 -28
  86. data/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier.rb +0 -31
  87. data/neeto_compliance/lib/neeto_compliance/verifiers/webpack_configuration_verifier.rb +0 -44
  88. data/neeto_compliance/lib/neeto_compliance/verifiers/webpacker_config_verifier.rb +0 -29
  89. data/neeto_compliance/lib/neeto_compliance/verifiers_list.rb +0 -61
  90. data/neeto_compliance/lib/neeto_compliance/version.rb +0 -5
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hashdiff"
4
-
5
- module NeetoCompliance
6
- class JsconfigVerifier < Base
7
- attr_accessor :diff
8
-
9
- def initialize
10
- @diff = []
11
- end
12
-
13
- def local_copy
14
- "app/javascript/jsconfig.json"
15
- end
16
-
17
- def commons_copy
18
- NeetoCompliance::NeetoCommons.path.join "common_files", "app", "javascript", "jsconfig.json"
19
- end
20
-
21
- def local_jsconfig_data
22
- @_local_jsconfig_data ||= JSON.parse(File.read(local_copy))
23
- end
24
-
25
- def required_jsconfig_data
26
- @_required_jsconfig_data ||= JSON.parse(File.read(commons_copy))
27
- end
28
-
29
- def verify_command
30
- self.diff = Hashdiff.best_diff(required_jsconfig_data, local_jsconfig_data)
31
- removed_symbol = "\-"
32
- modified_symbol = "\~"
33
- symbol_index = 0
34
- self.diff.any? { |p| /#{removed_symbol}|#{modified_symbol}/.match?(p[symbol_index]) }
35
- end
36
-
37
- def local_file_exists?
38
- File.file?(local_copy)
39
- end
40
-
41
- def valid?
42
- return false unless local_file_exists?
43
-
44
- is_modified_or_removed = verify_command
45
- !is_modified_or_removed
46
- end
47
-
48
- def autofix_command
49
- "cp #{commons_copy} #{local_copy}"
50
- end
51
-
52
- def upstream_copy
53
- "https://github.com/bigbinary/neeto-commons-backend/blob/stable/lib/neeto-commons-backend/common_files/app/javascript/jsconfig.json"
54
- end
55
-
56
- def autofix_suggestion
57
- base_message = %{
58
- Your jsconfig.json content doesn't match with the expected neeto-commons content.
59
-
60
- The following is the recommended jsconfig.json content in neeto ecosystem:
61
- 1) View #{upstream_copy}
62
- 2) Or open #{commons_copy}
63
-
64
- To fix, start by fully replacing app/javascript/jsconfig.json
65
- of your app with above mentioned content, by running the following:
66
- #{autofix_command.yellow}
67
- }
68
-
69
- # The following is an example diff:
70
- # [["-", "compilerOptions.moduleResolution", "NodeNext"],
71
- # ["~", "compilerOptions.module", "ESNext", "ESNex"],
72
- # ["+", "compilerOptions.paths.neetou", ["../../node_modules/@bigbinary/neetoui/**"]],
73
- # For the above diff, we only need to get the newly added items marked by "+"
74
- # and also check whether it's a "path" that has been added.
75
- capture_addition_into_paths_key = "(?=.*\+)(?=.*compilerOptions.paths)"
76
- new_paths = self.diff.select { |p| p.join =~ /#{capture_addition_into_paths_key}.*/ }
77
- if new_paths.empty?
78
- return base_message
79
- end
80
-
81
- custom_paths = Hash.new
82
- new_paths.each do |path|
83
- k = path[1].split(".").last
84
- v = path[2]
85
- custom_paths[k] = v
86
- end
87
-
88
- message = %{
89
- #{base_message}
90
- ==================================================
91
- It seems that you've also added some custom paths in your jsconfig. You can cherry pick and
92
- append the custom paths to app/javascript/jsconfig.json, if need be, after running above mentioned copy command.
93
- Refer the comments in #{upstream_copy}
94
- to see how to add custom paths.
95
- The following are the custom paths that we have detected in your app/javascript/jsconfig.json:
96
- #{JSON.pretty_generate(custom_paths).yellow}
97
- }
98
- end
99
- end
100
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class NeetoAuthGemsVerifier < GemsVerifierBase
5
- def gems
6
- [
7
- { name: "neeto-commons-backend", repo: "bigbinary/neeto-commons-backend" },
8
- { name: "neeto-compliance", repo: "bigbinary/neeto-compliance" },
9
- { name: "neeto-area51-engine", repo: "bigbinary/neeto-area51-engine" },
10
- { name: "neeto-team-members-engine", repo: "bigbinary/neeto-team-members-engine" },
11
- { name: "neeto-org-incineration-engine", repo: "bigbinary/neeto-org-incineration-engine" },
12
- # { name: "neeto-emails", repo: "bigbinary/neeto-emails" },
13
- { name: "neeto-email-prefixer", repo: "bigbinary/neeto-email-prefixer" },
14
- { name: "neeto-mail-interceptor", repo: "bigbinary/neeto-mail-interceptor" },
15
- { name: "neeto-filters-engine", repo: "bigbinary/neeto-filters-engine" },
16
- { name: "neeto-custom-domains-engine", repo: "bigbinary/neeto-custom-domains-engine" },
17
- ]
18
- end
19
- end
20
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class NeetoCommonsSyncVerifier < Base
5
- def webpack_config_files
6
- @_webpack_config_files ||= {
7
- "config/webpack/development.js" => NeetoCompliance::NeetoCommons.path.join("webpack/development.js"),
8
- "config/webpack/production.js" => NeetoCompliance::NeetoCommons.path.join("webpack/production.js"),
9
- "config/webpack/staging.js" => NeetoCompliance::NeetoCommons.path.join("webpack/staging.js"),
10
- "config/webpack/test.js" => NeetoCompliance::NeetoCommons.path.join("webpack/test.js")
11
- }
12
- end
13
-
14
- def auto_correct!
15
- @autofix_commands.each do |command|
16
- puts command
17
- system(command)
18
- end
19
- end
20
-
21
- def autofix_suggestion
22
- @autofix_commands.join("\n").yellow
23
- end
24
-
25
- def valid?
26
- @autofix_commands = []
27
-
28
- webpack_config_files.each_pair do |local_file, common_file|
29
- unless same_file?(local_file, common_file)
30
- @autofix_commands << "cp #{common_file.to_s} #{local_file}"
31
- end
32
- end
33
-
34
- @autofix_commands.length == 0
35
- end
36
-
37
- def same_file?(local_file, common_file)
38
- File.exist?(local_file) &&
39
- `diff #{local_file} #{common_file.to_s}`.empty?
40
- end
41
- end
42
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class NeetoGemsVerifier < GemsVerifierBase
5
- def gems
6
- [
7
- { name: "neeto-commons-backend", repo: "bigbinary/neeto-commons-backend" },
8
- { name: "neeto-compliance", repo: "bigbinary/neeto-compliance" },
9
- { name: "neeto-area51-engine", repo: "bigbinary/neeto-area51-engine" },
10
- { name: "neeto-sso", repo: "bigbinary/neeto-sso" },
11
- { name: "neeto-team-members-engine", repo: "bigbinary/neeto-team-members-engine" },
12
- { name: "neeto-org-incineration-engine", repo: "bigbinary/neeto-org-incineration-engine" },
13
- # { name: "neeto-emails", repo: "bigbinary/neeto-emails" },
14
- { name: "neeto-email-prefixer", repo: "bigbinary/neeto-email-prefixer" },
15
- { name: "neeto-mail-interceptor", repo: "bigbinary/neeto-mail-interceptor" },
16
- { name: "neeto-payments-engine", repo: "bigbinary/neeto-payments-engine" },
17
- { name: "neeto-notifications-engine", repo: "bigbinary/neeto-notifications-engine" },
18
- { name: "neeto-tags-engine", repo: "bigbinary/neeto-tags-engine" },
19
- { name: "neeto-filters-engine", repo: "bigbinary/neeto-filters-engine" },
20
- { name: "neeto-custom-domains-engine", repo: "bigbinary/neeto-custom-domains-engine" },
21
- ]
22
- end
23
- end
24
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class NewrelicVerifier < Base
5
- def local_copy
6
- "config/newrelic.yml"
7
- end
8
-
9
- def commons_copy
10
- NeetoCompliance::NeetoCommons.path.join "common_files/newrelic.yml"
11
- end
12
-
13
- def verify_command
14
- "diff -N #{commons_copy} #{local_copy}"
15
- end
16
-
17
- def valid?
18
- `#{verify_command}`.empty?
19
- end
20
-
21
- def autofix_command
22
- "cp #{commons_copy} #{local_copy}"
23
- end
24
- end
25
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class NodeVersionVerifier < Base
5
- def node_version
6
- JSON.parse(open(common_packages_latest_file).read)["engines"]["node"]
7
- end
8
-
9
- def package_json_engines
10
- JSON.parse(open("package.json").read)["engines"]
11
- end
12
-
13
- def auto_correct!
14
- end
15
-
16
- def autofix_suggestion
17
- @errors.join("\n").yellow
18
- end
19
-
20
- def valid?
21
- @errors = []
22
- unless updated_nvmrc_file?
23
- @errors << "Update node version in .nvmrc to #{node_version}"
24
- end
25
-
26
- unless updated_node_version_file?
27
- @errors << "Update node version in .node-version to #{node_version}"
28
- end
29
-
30
- unless check_node_step_added_to_semahore_config?
31
- @errors << "Add node version to your semaphore.yml as shown below:
32
- global_job_config:
33
- prologue:
34
- commands:
35
- - checkout
36
- - sem-version ruby 3.0.1
37
- - sem-version node #{node_version}
38
- - sem-service start postgres 12.4
39
- \n "
40
- end
41
-
42
- @errors.length == 0
43
- end
44
-
45
- def updated_node_version_file?
46
- node_version == File.open(".node-version").read.chomp
47
- end
48
-
49
- def updated_nvmrc_file?
50
- node_version == File.open(".nvmrc").read.chomp
51
- end
52
-
53
- def check_node_step_added_to_semahore_config?
54
- semaphore_config = YAML.load(File.open(".semaphore/semaphore.yml").read, aliases: true)
55
- semaphore_command = "sem-version node #{node_version}"
56
- semaphore_config["global_job_config"]["prologue"]["commands"].include?(semaphore_command)
57
- end
58
-
59
- def common_packages_latest_file
60
- NeetoCompliance::NeetoCommons.path.join "common_files/package-common.json"
61
- end
62
- end
63
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
-
5
- module NeetoCompliance
6
- class PackageDependenciesVersionVerifier < Base
7
- def valid?
8
- @common_package_json = load_json_file(common_packages_latest_file)
9
- @project_package_json = load_json_file("package.json")
10
-
11
- @incorrect_dependencies = {
12
- dependencies: find_incorrect_dependencies(:dependencies),
13
- devDependencies: find_incorrect_dependencies(:devDependencies)
14
- }
15
- @incorrect_dependencies[:misplacedDependencies] = find_misplaced_dependencies
16
- @incorrect_dependencies.keys.all? { |key| @incorrect_dependencies[key].empty? }
17
- end
18
-
19
- def auto_correct!
20
- end
21
-
22
- def autofix_command
23
- command = ""
24
- command += "yarn remove #{@incorrect_dependencies[:misplacedDependencies]
25
- .join(" ")}\n" unless @incorrect_dependencies[:misplacedDependencies].empty?
26
- command += "yarn add #{@incorrect_dependencies[:dependencies]
27
- .join(" ")}\n" unless @incorrect_dependencies[:dependencies].empty?
28
- command += "yarn add -D #{@incorrect_dependencies[:devDependencies]
29
- .join(" ")}\n" unless @incorrect_dependencies[:devDependencies].empty?
30
- command
31
- end
32
-
33
- private
34
-
35
- def common_packages_latest_file
36
- NeetoCompliance::NeetoCommons.path.join "common_files/package-common.json"
37
- end
38
-
39
- def find_misplaced_dependencies
40
- project_dependencies = @project_package_json[:dependencies]
41
- @common_package_json[:devDependencies].inject([]) do |result, (package_name, latest_version)|
42
- next result unless project_dependencies.key?(package_name)
43
-
44
- @incorrect_dependencies[:devDependencies] |= ["\"#{package_name}@#{latest_version}\""]
45
- result.push("#{package_name}")
46
- end
47
- end
48
-
49
- def find_incorrect_dependencies(key)
50
- project_dependencies = @project_package_json[key]
51
- @common_package_json[key].inject([]) do |result, (package_name, latest_version)|
52
- next result if project_dependencies[package_name] == latest_version
53
-
54
- result.push("\"#{package_name}@#{latest_version}\"")
55
- end
56
- end
57
-
58
- def load_json_file(url)
59
- JSON.parse(open(url).read, symbolize_names: true)
60
- end
61
- end
62
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
-
5
- KEYS_TO_CHECK = %w[engines lint-staged].freeze
6
-
7
- module NeetoCompliance
8
- class PackageJsonVerifier < Base
9
- def valid?
10
- @common_lint_staged = JSON.parse(open(common_packages_latest_file).read)
11
- project_lint_staged = JSON.parse(open("package.json").read)
12
-
13
- @results = KEYS_TO_CHECK.map { |key| @common_lint_staged[key].to_json === project_lint_staged[key].to_json }
14
- @results.all?
15
- end
16
-
17
- def auto_correct!
18
- end
19
-
20
- def autofix_command
21
- return "" if @results.all?
22
-
23
- command = ""
24
- KEYS_TO_CHECK.each_with_index do |key, index|
25
- next if @results[index]
26
-
27
- command += "Replace the value of \"#{key}\" in package.json with:\n\n#{JSON.pretty_generate(@common_lint_staged[key])}\n\n"
28
- end
29
-
30
- command
31
- end
32
-
33
- private
34
-
35
- def common_packages_latest_file
36
- NeetoCompliance::NeetoCommons.path.join "common_files/package-common.json"
37
- end
38
- end
39
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- # To verify if the `roles.yml` file exist in the host application.
5
- class RolesVerifier < Base
6
- def local_copy
7
- "config/roles.yml"
8
- end
9
-
10
- def commons_copy
11
- NeetoCompliance::NeetoCommons.path.join "common_files/roles.yml"
12
- end
13
-
14
- def valid?
15
- File.exist?(local_copy)
16
- end
17
-
18
- def autofix_command
19
- "cp #{commons_copy} #{local_copy}"
20
- end
21
- end
22
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class RubyVersionVerifier < Base
5
- def local_copy
6
- ".ruby-version"
7
- end
8
-
9
- def commons_copy
10
- NeetoCompliance::NeetoCommons.path.join "common_files/.ruby-version"
11
- end
12
-
13
- def verify_command
14
- "diff -N #{commons_copy} #{local_copy}"
15
- end
16
-
17
- def valid?
18
- `#{verify_command}`.empty?
19
- end
20
-
21
- def autofix_command
22
- "cp #{commons_copy} #{local_copy}"
23
- end
24
- end
25
- end
@@ -1,162 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class SemaphoreciConfigVerifier < Base
5
- def local_copy
6
- ".semaphore/semaphore.yml"
7
- end
8
-
9
- def auto_correct!
10
- end
11
-
12
- def semaphore_config
13
- @_semaphore_config ||= YAML.load(File.open(local_copy).read, aliases: true)
14
- end
15
-
16
- def my_container_setup_commands
17
- semaphore_config["global_job_config"]["prologue"]["commands"]
18
- end
19
-
20
- def my_jobs_config
21
- semaphore_config["blocks"].map { |block| block["task"]["jobs"] }
22
- end
23
-
24
- def my_env_vars_config
25
- semaphore_config["global_job_config"]["env_vars"]
26
- end
27
-
28
- def my_after_pipeline_jobs
29
- semaphore_config["after_pipeline"]["task"]
30
- end
31
-
32
- def my_machine_type
33
- semaphore_config["agent"]["machine"]["type"]
34
- end
35
-
36
- def machine_type
37
- "e1-standard-2"
38
- end
39
-
40
- def container_setup_commands
41
- [
42
- "checkout",
43
- "sem-version ruby 3.1.2",
44
- "sem-version node 18.12",
45
- "sem-service start postgres 13",
46
- "sem-service start redis",
47
- "bundle config path 'vendor/bundle'",
48
- "cp config/database.yml.ci config/database.yml",
49
- "bundle install --jobs 1",
50
- ]
51
- end
52
-
53
- def jobs_config
54
- [
55
- [
56
- {
57
- "name" => "Checks",
58
- "commands" =>
59
- [
60
- "bundle exec ruby-audit check",
61
- "bundle exec rubocop",
62
- "bundle exec erblint --lint-all --format compact",
63
- "curl -s -L \"https://raw.githubusercontent.com/bigbinary/wheel/main/.semaphore/commands/run_eslint_on_modified_files.sh\" | bash",
64
- "bundle exec neeto-audit",
65
- "bundle exec rake db:create db:schema:load --trace",
66
- "bundle exec rake incinerator:check_for_missing_models",
67
- "bundle exec rails test",
68
- "bundle exec rake simplecov_coverage:publish",
69
- "test-results publish ./test/reports",
70
- "bundle exec rake setup"
71
- ]
72
- }
73
- ]
74
- ]
75
- end
76
-
77
- def env_vars_config
78
- [
79
- {
80
- "name" => "TZ",
81
- "value" => "UTC"
82
- },
83
- {
84
- "name" => "RAILS_ENV",
85
- "value" => "test"
86
- },
87
- {
88
- "name" => "RACK_ENV",
89
- "value" => "test"
90
- }
91
- ]
92
- end
93
-
94
- def after_pipeline_jobs
95
- {
96
- "jobs" => [
97
- {
98
- "name" => "Publish Results",
99
- "commands" => ["test-results gen-pipeline-report"]
100
- }
101
- ]
102
- }
103
- end
104
-
105
- def standard_semaphore_config_file
106
- NeetoCompliance::NeetoCommons.path.join "common_files/semaphore/semaphore.yml"
107
- end
108
-
109
- def semaphore_config_valid?
110
- @semaphore_errors = []
111
- @no_errors = true
112
-
113
- begin
114
- container_setup_commands.each do |cmd|
115
- unless my_container_setup_commands.include?(cmd)
116
- @semaphore_errors << "Missing: \"#{cmd}\" in global_job_config"
117
- @no_errors = false
118
- end
119
- end
120
-
121
- unless jobs_config == my_jobs_config
122
- @semaphore_errors << "Blocks configuration should be same as in #{standard_semaphore_config_file}"
123
- @no_errors = false
124
- end
125
-
126
- unless env_vars_config == my_env_vars_config
127
- @semaphore_errors << "Env vars configuration should be same as in #{standard_semaphore_config_file}"
128
- @no_errors = false
129
- end
130
-
131
- unless after_pipeline_jobs == my_after_pipeline_jobs
132
- @semaphore_errors << "after_pipeline jobs configuration should be same as in #{standard_semaphore_config_file}"
133
- @no_errors = false
134
- end
135
-
136
- unless machine_type == my_machine_type
137
- @semaphore_errors << "Machine type should be #{machine_type}"
138
- @no_errors = false
139
- end
140
-
141
- rescue => e
142
- p e
143
- return false
144
- end
145
-
146
- @no_errors
147
- end
148
-
149
- def autofix_suggestion
150
- @error.yellow
151
- end
152
-
153
- def valid?
154
- unless semaphore_config_valid?
155
- @error = %{SemaphoreCI configuration (.semaphore/semaphore.yml) is incomplete/incorrect. \n#{@semaphore_errors.join("\n")} \n}
156
- return false
157
- end
158
-
159
- true
160
- end
161
- end
162
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class SidekiqQueuesVerifier < Base
5
- def local_copy
6
- "config/sidekiq.yml"
7
- end
8
-
9
- def queues
10
- @_queues ||= ["active_storage_analysis", "active_storage_purge"]
11
- end
12
-
13
- def valid?
14
- @errors = []
15
-
16
- sidekiq_yml = YAML.load(File.open(local_copy), aliases: true)
17
-
18
- queues.map do |queue|
19
- unless sidekiq_yml["queues"].include?(queue)
20
- @errors << "Add #{queue} to queues in #{local_copy}"
21
- end
22
- end
23
-
24
- @errors.length == 0
25
- end
26
-
27
- def autofix_suggestion
28
- @errors.join("\n").yellow
29
- end
30
-
31
- def auto_correct!
32
- end
33
- end
34
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class SimplecovConfigVerifier < Base
5
- def test_helper
6
- "test/test_helper.rb"
7
- end
8
-
9
- def valid?
10
- @errors = []
11
-
12
- check_file = Set.new(File.readlines(test_helper).collect(&:chomp))
13
-
14
- if check_file.include?("NeetoCommonsBackend.simplecov_config")
15
- @errors << "Remove NeetoCommons.simplecov_config from #{test_helper}"
16
- end
17
-
18
- @errors.length == 0
19
- end
20
-
21
- def autofix_suggestion
22
- @errors.join("\n").yellow
23
- end
24
-
25
- def auto_correct!
26
- end
27
- end
28
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NeetoCompliance
4
- class SitemapConfigVerifier < Base
5
- def local_copy
6
- "public/sitemap.xml"
7
- end
8
-
9
- def commons_copy
10
- NeetoCompliance::NeetoCommons.path.join "common_files", "sitemap.xml"
11
- end
12
-
13
- def verify_command
14
- "diff -N #{commons_copy} #{local_copy}"
15
- end
16
-
17
- def valid?
18
- `#{verify_command}`.empty?
19
- end
20
-
21
- def autofix_command
22
- "cp #{commons_copy} #{local_copy}"
23
- end
24
-
25
- def apps_exception_list
26
- ["neeto-kb-web.git"]
27
- end
28
- end
29
- end