neetob 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +10 -0
- data/.env +1 -0
- data/.rubocop.yml +596 -0
- data/.ruby-version +1 -0
- data/.semaphore/semaphore.yml +31 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +249 -0
- data/LICENSE.txt +21 -0
- data/README.md +381 -0
- data/Rakefile +16 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/github_access.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_apps.rb +35 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/neeto_commons.rb +16 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/runner.rb +35 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/skippable.rb +19 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_bin.rb +32 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_formatters.rb +35 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_husky.rb +33 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_misc.rb +36 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons/sync_test_support.rb +38 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/sync_neeto_commons.rb +36 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/auto_update_prs_with_latest_master_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/base.rb +72 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/bundler_version_verifier.rb +53 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/circleci_config_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_gemfile_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/common_initializers_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_config_verifier.rb +46 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/cypress_plugins_index_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/docker_file_dev_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/environment_config_verifier.rb +38 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb +38 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gems_verifier_base.rb +34 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gitignore_file_verifier.rb +39 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/jsconfig_verifier.rb +100 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_auth_gems_verifier.rb +20 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb +42 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_gems_version_verifier.rb +24 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/newrelic_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/node_version_verifier.rb +63 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb +62 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/package_json_verifier.rb +39 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/roles_verifier.rb +22 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/ruby_version_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/semaphoreci_config_verifier.rb +162 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sidekiq_queues_verifier.rb +34 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/simplecov_config_verifier.rb +28 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sitemap_config_verifier.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/slugignore_file_verifier.rb +25 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/bin_files_verifier.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/formatter_files_verifier.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/husky_files_verifier.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/misc_files_verifier.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier/test_support_files_verifier.rb +28 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/sync_neeto_commons_verifier.rb +31 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpack_configuration_verifier.rb +44 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/webpacker_config_verifier.rb +29 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers_list.rb +61 -0
- data/Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/version.rb +5 -0
- data/data/branch-protection-rules.json +25 -0
- data/data/config-vars-audit.json +18 -0
- data/data/config-vars-list.json +1 -0
- data/data/config-vars-upsert.json +3 -0
- data/data/github-labels.json +192 -0
- data/env.sample +1 -0
- data/exe/neetob +25 -0
- data/install.sh +21 -0
- data/lib/neetob/cli/base.rb +85 -0
- data/lib/neetob/cli/fetchorupdate_repos/execute.rb +53 -0
- data/lib/neetob/cli/github/auth.rb +134 -0
- data/lib/neetob/cli/github/base.rb +35 -0
- data/lib/neetob/cli/github/commands.rb +50 -0
- data/lib/neetob/cli/github/issues/commands.rb +51 -0
- data/lib/neetob/cli/github/issues/create.rb +42 -0
- data/lib/neetob/cli/github/issues/list.rb +94 -0
- data/lib/neetob/cli/github/labels/commands.rb +62 -0
- data/lib/neetob/cli/github/labels/delete.rb +44 -0
- data/lib/neetob/cli/github/labels/delete_all.rb +48 -0
- data/lib/neetob/cli/github/labels/list.rb +36 -0
- data/lib/neetob/cli/github/labels/show.rb +37 -0
- data/lib/neetob/cli/github/labels/update.rb +40 -0
- data/lib/neetob/cli/github/labels/upsert.rb +62 -0
- data/lib/neetob/cli/github/login.rb +16 -0
- data/lib/neetob/cli/github/make_pr/base.rb +72 -0
- data/lib/neetob/cli/github/make_pr/commands.rb +37 -0
- data/lib/neetob/cli/github/make_pr/compliance_fix.rb +49 -0
- data/lib/neetob/cli/github/make_pr/script.rb +55 -0
- data/lib/neetob/cli/github/protect_branch.rb +46 -0
- data/lib/neetob/cli/github/search.rb +38 -0
- data/lib/neetob/cli/heroku/access/add.rb +38 -0
- data/lib/neetob/cli/heroku/access/commands.rb +41 -0
- data/lib/neetob/cli/heroku/access/list.rb +36 -0
- data/lib/neetob/cli/heroku/access/remove.rb +38 -0
- data/lib/neetob/cli/heroku/commands.rb +28 -0
- data/lib/neetob/cli/heroku/config_vars/audit.rb +64 -0
- data/lib/neetob/cli/heroku/config_vars/base.rb +19 -0
- data/lib/neetob/cli/heroku/config_vars/commands.rb +49 -0
- data/lib/neetob/cli/heroku/config_vars/list.rb +56 -0
- data/lib/neetob/cli/heroku/config_vars/remove.rb +39 -0
- data/lib/neetob/cli/heroku/config_vars/upsert.rb +80 -0
- data/lib/neetob/cli/heroku/execute.rb +37 -0
- data/lib/neetob/cli/local/commands.rb +19 -0
- data/lib/neetob/cli/local/ls.rb +29 -0
- data/lib/neetob/cli/sub_command_base.rb +17 -0
- data/lib/neetob/cli/ui.rb +41 -0
- data/lib/neetob/cli/users/audit.rb +121 -0
- data/lib/neetob/cli/users/commands.rb +28 -0
- data/lib/neetob/cli/users/commits.rb +125 -0
- data/lib/neetob/cli.rb +40 -0
- data/lib/neetob/exception_handler.rb +58 -0
- data/lib/neetob/utils.rb +16 -0
- data/lib/neetob/version.rb +5 -0
- data/lib/neetob.rb +10 -0
- data/overcommit.yml +43 -0
- data/scripts/delete_unused_assets.rb +67 -0
- metadata +235 -0
|
@@ -0,0 +1,42 @@
|
|
|
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
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1,162 @@
|
|
|
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
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NeetoCompliance
|
|
4
|
+
class SlugignoreFileVerifier < Base
|
|
5
|
+
def local_copy
|
|
6
|
+
".slugignore"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def commons_copy
|
|
10
|
+
NeetoCompliance::NeetoCommons.path.join local_copy
|
|
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
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "yaml"
|
|
6
|
+
|
|
7
|
+
require "neeto_compliance/sync_neeto_commons"
|
|
8
|
+
|
|
9
|
+
module NeetoCompliance
|
|
10
|
+
class SyncNeetoCommonsVerifier < Base
|
|
11
|
+
class BinFilesVerifier
|
|
12
|
+
def process
|
|
13
|
+
non_complied_bin_files = find_non_complied_bin_files
|
|
14
|
+
|
|
15
|
+
return false if non_complied_bin_files.any?
|
|
16
|
+
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def find_non_complied_bin_files
|
|
23
|
+
NeetoCompliance::SyncNeetoCommons::SyncBin.BIN_FILES.select do |file|
|
|
24
|
+
!system("cat #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} | diff #{file} - 1> /dev/null")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "yaml"
|
|
6
|
+
|
|
7
|
+
require "neeto_compliance/sync_neeto_commons"
|
|
8
|
+
|
|
9
|
+
module NeetoCompliance
|
|
10
|
+
class SyncNeetoCommonsVerifier < Base
|
|
11
|
+
class FormatterFilesVerifier
|
|
12
|
+
def process
|
|
13
|
+
non_complied_formatter_files = find_non_complied_formatter_files
|
|
14
|
+
|
|
15
|
+
return false if non_complied_formatter_files.any?
|
|
16
|
+
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def find_non_complied_formatter_files
|
|
23
|
+
NeetoCompliance::SyncNeetoCommons::SyncFormatters.CONFIG_FILES.select do |file|
|
|
24
|
+
!system("cat #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} | diff #{file} - 1> /dev/null")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "yaml"
|
|
6
|
+
|
|
7
|
+
require "neeto_compliance/sync_neeto_commons"
|
|
8
|
+
|
|
9
|
+
module NeetoCompliance
|
|
10
|
+
class SyncNeetoCommonsVerifier < Base
|
|
11
|
+
class HuskyFilesVerifier
|
|
12
|
+
def process
|
|
13
|
+
non_complied_husky_files = find_non_complied_husky_files
|
|
14
|
+
|
|
15
|
+
return false if non_complied_husky_files.any?
|
|
16
|
+
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def find_non_complied_husky_files
|
|
23
|
+
NeetoCompliance::SyncNeetoCommons::SyncHusky.HUSKY_FILES.select do |file|
|
|
24
|
+
!system("cat #{NeetoCompliance::SyncNeetoCommons.neeto_commons_url}#{file} | diff #{file} - 1> /dev/null")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|