cloud-platform-repository-checker 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b61c06a632987b8c366c692718d701b86639c4c60403f9a7174f7b9a31c6bb6
4
- data.tar.gz: c19876ffccb7e82476fb50ed4bd6bac97881d1c6fc4463a068d9c190b264394f
3
+ metadata.gz: 1e8cf546dab8f2551ca91e723bb23195baa4de9ca433c0b01f5cbd8d62405781
4
+ data.tar.gz: 36787f13af08b887b4289964411164f0a8a636346f25002ea7d84170e644c257
5
5
  SHA512:
6
- metadata.gz: 124e8fc55a5532b7f13c1bfaeaf2dc3b2d316b66474d481a772604d6766770bf992c1ad74a8bf19b115bd797bf5c8b7f1a864b2af8c6a4d92d9ad24c1ea714d1
7
- data.tar.gz: 64048556144bdb822d527c0a28b7e5464ec2eed5db1befbe243de1300276a1fc42a917af3ddd84998ffae274ecba2ac8bf28dfda18bdcdaa0b9afcb49ab7e8a2
6
+ metadata.gz: 2b04b7f8e2b4d75b273e19d65006a47fd65f5d8ef1c9e3d817c713fb716944686cd596b574deb54970dbda32cfe4387cad0097c525c9005ecaed8e8e12b80adb
7
+ data.tar.gz: 01a1858cacaba240aa9a1193b39072518a70c7108b148ab0e9de04dd673e0dfa447a0d353f571307235b64083aead7740afad030dafeccf8b044370825c7bf92
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Script to list repositories in the ministryofjustice organisation whose names
4
+ # match a regular expression, and output a JSON report of how well they
5
+ # do/don't comply with our team-wide standards for how github repositories
6
+ # should be configured.
7
+
8
+ require "json"
9
+ require "net/http"
10
+ require "uri"
11
+ require "octokit"
12
+
13
+ require_relative "../lib/github_graph_ql_client"
14
+ require_relative "../lib/repository_lister"
15
+ require_relative "../lib/repository_report"
16
+
17
+ ############################################################
18
+
19
+ params = {
20
+ organization: ENV.fetch("ORGANIZATION"),
21
+ regexp: Regexp.new(ENV.fetch("REGEXP")),
22
+ team: ENV.fetch("TEAM"),
23
+ github_token: ENV.fetch("GITHUB_TOKEN")
24
+ }
25
+
26
+ repo_name = ARGV.shift
27
+ pp RepositoryReport.new(params.merge(repo_name: repo_name)).fetch_repo_data
@@ -1,7 +1,7 @@
1
1
  class RepositoryReport < GithubGraphQlClient
2
2
  attr_reader :organization, :repo_name, :team
3
3
 
4
- MASTER = "master"
4
+ MAIN_BRANCHES = ["main", "master"] # We are changing to use "main" but many repos still use "master" as default branch
5
5
  ADMIN = "admin"
6
6
  PASS = "PASS"
7
7
  FAIL = "FAIL"
@@ -45,7 +45,7 @@ class RepositoryReport < GithubGraphQlClient
45
45
 
46
46
  def all_checks_result
47
47
  @all_checks_result ||= {
48
- has_master_branch_protection: has_master_branch_protection?,
48
+ has_main_branch_protection: has_main_branch_protection?,
49
49
  requires_approving_reviews: has_branch_protection_property?("requiresApprovingReviews"),
50
50
  requires_code_owner_reviews: has_branch_protection_property?("requiresCodeOwnerReviews"),
51
51
  administrators_require_review: has_branch_protection_property?("isAdminEnforced"),
@@ -113,11 +113,11 @@ class RepositoryReport < GithubGraphQlClient
113
113
  @rules ||= repo_data.dig("data", "repository", "branchProtectionRules", "edges")
114
114
  end
115
115
 
116
- def has_master_branch_protection?
116
+ def has_main_branch_protection?
117
117
  requiring_branch_protection_rules do |rules|
118
118
 
119
119
  rules
120
- .select { |edge| edge.dig("node", "pattern") == MASTER }
120
+ .select { |edge| MAIN_BRANCHES.include?(edge.dig("node", "pattern")) }
121
121
  .any?
122
122
  end
123
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud-platform-repository-checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Salgado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-26 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -27,6 +27,7 @@ dependencies:
27
27
  description:
28
28
  email: platforms@digital.justice.gov.uk
29
29
  executables:
30
+ - check.rb
30
31
  - cloud-platform-repository-checker
31
32
  extensions: []
32
33
  extra_rdoc_files:
@@ -36,6 +37,7 @@ files:
36
37
  - Gemfile.lock
37
38
  - LICENSE
38
39
  - README.md
40
+ - bin/check.rb
39
41
  - bin/cloud-platform-repository-checker
40
42
  - env.example
41
43
  - lib/github_graph_ql_client.rb