github-pages-health-check 1.13.0 → 1.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dc7e8e6ff875a82f7b7a63fb1c0f36887c4fb04a227216b6bd73219a1e5433e
4
- data.tar.gz: 638976ceb500093ad1a9b1060eeced2206d7a7e368c0160efd6a63f9259de418
3
+ metadata.gz: 707b4cdba4aba9ac4eff72df8a4428f40b0d6f929570ad3c088b469f26d8e25d
4
+ data.tar.gz: df3af08fb19f7ca11da1100bbddbeb4c8418221f88aa1515e06b2a39baba2276
5
5
  SHA512:
6
- metadata.gz: 72c2a0f8c3762c6fba32e9ff160dad0539bd039afd67c5d1de37f16f8ce03c54ad396b03a5af3a76b3436c0d7898c579ec767fc10cfebf8054d90bbd2afb070f
7
- data.tar.gz: f18feaf2e003d54fd17d30d2585cd7840a2085e9174227bda7499aa5fdf3633d11b45a69b691836465e060570125703a8875a1eec4b2f73a181078ecb1f6ee4b
6
+ metadata.gz: bb30c4dcb64983947a346d6b92ce788d543f64dfdf200ed7e63a79b87e4133f025b57b2acce54d465575d8b3b80ab4b82a3566431f45ab56055c770764e4eb33
7
+ data.tar.gz: 64ace9fb8bc8bad17f3d3c0e5bbf682a3c5555a8b1e84e838136ae53caf848583e0dfefb54abef47527aa52ffaa71b165c33b1c0adfe11001caed318a8d0a74c
@@ -0,0 +1 @@
1
+ Gemfile.lock
@@ -0,0 +1,18 @@
1
+ on: push
2
+ name: cibuild on push
3
+ jobs:
4
+ build:
5
+ name: "GitHub Pages Health Check Tests"
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ ruby:
10
+ - 2.5
11
+ - 2.6
12
+ - 2.7
13
+ steps:
14
+ - uses: actions/checkout@master
15
+ - name: script/cibuild-docker
16
+ run: script/cibuild-docker
17
+ env:
18
+ RUBY_VERSION: ${{ matrix.ruby }}
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  AllCops:
20
- TargetRubyVersion: 2.2
20
+ TargetRubyVersion: 2.6
21
21
  Exclude:
22
22
  - 'bin/**/*'
23
23
  - 'script/**/*'
@@ -30,10 +30,6 @@ Layout/EndAlignment:
30
30
  Lint/UnreachableCode:
31
31
  Severity: error
32
32
 
33
- Style/StringLiterals:
34
- EnforcedStyle: double_quotes
35
- Severity: error
36
-
37
33
  Style/StringLiteralsInInterpolation:
38
34
  EnforcedStyle: double_quotes
39
35
 
@@ -41,10 +37,10 @@ Style/HashSyntax:
41
37
  EnforcedStyle: hash_rockets
42
38
  Severity: error
43
39
 
44
- Layout/AlignHash:
40
+ Layout/HashAlignment:
45
41
  SupportedLastArgumentHashStyles: always_ignore
46
42
 
47
- Layout/AlignParameters:
43
+ Layout/ParameterAlignment:
48
44
  Enabled: false # This is usually true, but we often want to roll back to
49
45
  # the start of a line.
50
46
 
@@ -55,12 +51,7 @@ Style/Attr:
55
51
  Style/ClassAndModuleChildren:
56
52
  Enabled: false # module X<\n>module Y is just as good as module X::Y.
57
53
 
58
- Style/PercentLiteralDelimiters:
59
- PreferredDelimiters:
60
- '%w': '{}'
61
- '%r': '{}'
62
-
63
- Metrics/LineLength:
54
+ Layout/LineLength:
64
55
  Max: 90
65
56
  Severity: warning
66
57
  Exclude:
@@ -99,13 +90,12 @@ Naming/FileName: #Rubocop doesn't like the Git*H*ub namespace
99
90
  Enabled: false
100
91
 
101
92
  Metrics/ParameterLists: { Max: 4 }
102
- Metrics/AbcSize: { Max: 20 }
103
93
 
104
- Layout/IndentHash: { EnforcedStyle: consistent }
94
+ Layout/FirstHashElementIndentation: { EnforcedStyle: consistent }
105
95
  Layout/MultilineMethodCallIndentation: { EnforcedStyle: indented }
106
96
  Layout/MultilineOperationIndentation: { EnforcedStyle: indented }
107
97
  Layout/FirstParameterIndentation: { EnforcedStyle: consistent }
108
- Layout/IndentArray: { EnforcedStyle: consistent }
98
+ Layout/FirstArrayElementIndentation: { EnforcedStyle: consistent }
109
99
  Layout/ExtraSpacing: { AllowForAlignment: true }
110
100
  Style/SignalException: { EnforcedStyle: only_raise }
111
101
  Style/StringLiterals: { EnforcedStyle: double_quotes }
@@ -155,3 +145,10 @@ Style/FrozenStringLiteralComment:
155
145
 
156
146
  Gemspec/RequiredRubyVersion:
157
147
  Enabled: false
148
+
149
+ Style/HashEachMethods:
150
+ Enabled: false
151
+ Style/HashTransformKeys:
152
+ Enabled: false
153
+ Style/HashTransformValues:
154
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.7.1
@@ -1,12 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
4
- - 2.3
5
- - 2.4
6
3
  - 2.5
4
+ - 2.6
5
+ - 2.7
7
6
 
8
7
  before_install:
9
- - gem install bundler
8
+ - gem update --system
10
9
 
11
10
  script: "script/cibuild"
12
11
 
@@ -0,0 +1,18 @@
1
+ ARG RUBY_VERSION
2
+ FROM ruby:$RUBY_VERSION-slim
3
+ RUN set -ex \
4
+ && gem update --system --silent --quiet \
5
+ && apt-get update -y \
6
+ && apt-get upgrade -y \
7
+ && apt-get install -y \
8
+ build-essential \
9
+ git \
10
+ libcurl4-openssl-dev \
11
+ && apt-get clean
12
+ WORKDIR /app/github-pages-health-check
13
+ COPY Gemfile .
14
+ COPY github-pages-health-check.gemspec .
15
+ COPY lib/github-pages-health-check/version.rb lib/github-pages-health-check/version.rb
16
+ RUN bundle install
17
+ COPY . .
18
+ ENTRYPOINT [ "/bin/bash" ]
data/Gemfile CHANGED
@@ -2,4 +2,13 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ group :development do
6
+ gem "dotenv", "~> 2.7"
7
+ gem "gem-release", "~> 2.1"
8
+ gem "pry", "~> 0.10"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rubocop", "~> 0.52"
11
+ gem "webmock", "~> 3.8"
12
+ end
13
+
5
14
  gemspec
@@ -1,14 +1,14 @@
1
+ 173.245.48.0/20
1
2
  103.21.244.0/22
2
3
  103.22.200.0/22
3
4
  103.31.4.0/22
4
- 104.16.0.0/12
5
- 108.162.192.0/18
6
- 131.0.72.0/22
7
5
  141.101.64.0/18
8
- 162.158.0.0/15
9
- 172.64.0.0/13
10
- 173.245.48.0/20
11
- 188.114.96.0/20
6
+ 108.162.192.0/18
12
7
  190.93.240.0/20
8
+ 188.114.96.0/20
13
9
  197.234.240.0/22
14
10
  198.41.128.0/17
11
+ 162.158.0.0/15
12
+ 104.16.0.0/12
13
+ 172.64.0.0/13
14
+ 131.0.72.0/22
@@ -4,13 +4,14 @@
4
4
  103.245.222.0/23
5
5
  103.245.224.0/24
6
6
  104.156.80.0/20
7
+ 146.75.0.0/16
7
8
  151.101.0.0/16
8
9
  157.52.64.0/18
10
+ 167.82.0.0/17
11
+ 167.82.128.0/20
12
+ 167.82.160.0/20
13
+ 167.82.224.0/20
9
14
  172.111.64.0/18
10
15
  185.31.16.0/22
11
16
  199.27.72.0/21
12
- 199.232.0.0/16
13
- 202.21.128.11/32
14
- 202.21.128.12/32
15
- 203.57.145.11/32
16
- 203.57.145.12/32
17
+ 199.232.0.0/16
@@ -19,13 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency("addressable", "~> 2.3")
20
20
  s.add_dependency("dnsruby", "~> 1.60")
21
21
  s.add_dependency("octokit", "~> 4.0")
22
- s.add_dependency("public_suffix", "~> 2.0")
22
+ s.add_dependency("public_suffix", ">= 2.0.2", "< 5.0")
23
23
  s.add_dependency("typhoeus", "~> 1.3")
24
-
25
- s.add_development_dependency("dotenv", "~> 1.0")
26
- s.add_development_dependency("gem-release", "~> 0.7")
27
- s.add_development_dependency("pry", "~> 0.10")
28
- s.add_development_dependency("rspec", "~> 3.0")
29
- s.add_development_dependency("rubocop", "~> 0.52")
30
- s.add_development_dependency("webmock", "~> 1.21")
31
24
  end
@@ -37,9 +37,9 @@ module GitHubPages
37
37
  # DNS and HTTP timeout, in seconds
38
38
  TIMEOUT = 7
39
39
 
40
- HUMAN_NAME = "GitHub Pages Health Check".freeze
41
- URL = "https://github.com/github/pages-health-check".freeze
42
- USER_AGENT = "Mozilla/5.0 (compatible; #{HUMAN_NAME}/#{VERSION}; +#{URL})".freeze
40
+ HUMAN_NAME = "GitHub Pages Health Check"
41
+ URL = "https://github.com/github/pages-health-check"
42
+ USER_AGENT = "Mozilla/5.0 (compatible; #{HUMAN_NAME}/#{VERSION}; +#{URL})"
43
43
 
44
44
  TYPHOEUS_OPTIONS = {
45
45
  :followlocation => true,
@@ -9,7 +9,7 @@ module GitHubPages
9
9
  class CAA
10
10
  attr_reader :host, :error, :nameservers
11
11
 
12
- def initialize(host, nameservers: nil)
12
+ def initialize(host:, nameservers: :default)
13
13
  raise ArgumentError, "host cannot be nil" if host.nil?
14
14
 
15
15
  @host = host
@@ -24,24 +24,30 @@ module GitHubPages
24
24
  def lets_encrypt_allowed?
25
25
  return false if errored?
26
26
  return true unless records_present?
27
+
27
28
  records.any? { |r| r.property_value == "letsencrypt.org" }
28
29
  end
29
30
 
30
31
  def records_present?
31
32
  return false if errored?
33
+
32
34
  records && !records.empty?
33
35
  end
34
36
 
35
37
  def records
36
- @records ||= begin
37
- get_caa_records(host) | get_caa_records(host.split(".").drop(1).join("."))
38
- end
38
+ return @records if defined?(@records)
39
+
40
+ @records = get_caa_records(host)
41
+ @records = get_caa_records(parent_host) if @records.nil? || @records.empty?
42
+
43
+ @records
39
44
  end
40
45
 
41
46
  private
42
47
 
43
48
  def get_caa_records(domain)
44
49
  return [] if domain.nil?
50
+
45
51
  query(domain).select { |r| issue_caa_record?(r) }
46
52
  end
47
53
 
@@ -59,6 +65,10 @@ module GitHubPages
59
65
  def resolver(domain)
60
66
  GitHubPages::HealthCheck::Resolver.new(domain, :nameservers => nameservers)
61
67
  end
68
+
69
+ def parent_host
70
+ host.split(".").drop(1).join(".")
71
+ end
62
72
  end
63
73
  end
64
74
  end
@@ -100,44 +100,52 @@ module GitHubPages
100
100
  @host = normalize_host(host)
101
101
  @nameservers = nameservers
102
102
  @resolver = GitHubPages::HealthCheck::Resolver.new(self.host,
103
- :nameservers => nameservers)
103
+ :nameservers => nameservers)
104
104
  end
105
105
 
106
106
  # Runs all checks, raises an error if invalid
107
+ # rubocop:disable Metrics/AbcSize
107
108
  def check!
108
- raise Errors::InvalidDomainError, :domain => self unless valid_domain?
109
- raise Errors::InvalidDNSError, :domain => self unless dns_resolves?
110
- raise Errors::DeprecatedIPError, :domain => self if deprecated_ip?
109
+ raise Errors::InvalidDomainError.new :domain => self unless valid_domain?
110
+ raise Errors::InvalidDNSError.new :domain => self unless dns_resolves?
111
+ raise Errors::DeprecatedIPError.new :domain => self if deprecated_ip?
111
112
  return true if proxied?
112
- raise Errors::InvalidARecordError, :domain => self if invalid_a_record?
113
- raise Errors::InvalidCNAMEError, :domain => self if invalid_cname?
114
- raise Errors::InvalidAAAARecordError, :domain => self if invalid_aaaa_record?
115
- raise Errors::NotServedByPagesError, :domain => self unless served_by_pages?
113
+ raise Errors::InvalidARecordError.new :domain => self if invalid_a_record?
114
+ raise Errors::InvalidCNAMEError.new :domain => self if invalid_cname?
115
+ raise Errors::InvalidAAAARecordError.new :domain => self if invalid_aaaa_record?
116
+ raise Errors::NotServedByPagesError.new :domain => self unless served_by_pages?
117
+
116
118
  true
117
119
  end
120
+ # rubocop:enable Metrics/AbcSize
118
121
 
119
122
  def deprecated_ip?
120
123
  return @deprecated_ip if defined? @deprecated_ip
124
+
121
125
  @deprecated_ip = (valid_domain? && a_record? && old_ip_address?)
122
126
  end
123
127
 
124
128
  def invalid_aaaa_record?
125
129
  return @invalid_aaaa_record if defined? @invalid_aaaa_record
130
+
126
131
  @invalid_aaaa_record = (valid_domain? && should_be_a_record? &&
127
132
  aaaa_record_present?)
128
133
  end
129
134
 
130
135
  def invalid_a_record?
131
136
  return @invalid_a_record if defined? @invalid_a_record
137
+
132
138
  @invalid_a_record = (valid_domain? && a_record? && !should_be_a_record?)
133
139
  end
134
140
 
135
141
  def invalid_cname?
136
142
  return @invalid_cname if defined? @invalid_cname
143
+
137
144
  @invalid_cname = begin
138
145
  return false unless valid_domain?
139
146
  return false if github_domain? || apex_domain?
140
147
  return true if cname_to_pages_dot_github_dot_com? || cname_to_fastly?
148
+
141
149
  !cname_to_github_user_domain? && should_be_cname_record?
142
150
  end
143
151
  end
@@ -146,8 +154,11 @@ module GitHubPages
146
154
  # Used as an escape hatch to prevent false positives on DNS checkes
147
155
  def valid_domain?
148
156
  return @valid if defined? @valid
157
+
149
158
  unicode_host = Addressable::IDNA.to_unicode(host)
150
- @valid = PublicSuffix.valid?(unicode_host, :default_rule => nil)
159
+ @valid = PublicSuffix.valid?(unicode_host,
160
+ :default_rule => nil,
161
+ :ignore_private => true)
151
162
  end
152
163
 
153
164
  # Is this domain an apex domain, meaning a CNAME would be innapropriate
@@ -161,7 +172,9 @@ module GitHubPages
161
172
  # E.g. PublicSuffix.domain("blog.digital.gov.uk") # => "digital.gov.uk"
162
173
  # For apex-level domain names, DNS providers do not support CNAME records.
163
174
  unicode_host = Addressable::IDNA.to_unicode(host)
164
- PublicSuffix.domain(unicode_host) == unicode_host
175
+ PublicSuffix.domain(unicode_host,
176
+ :default_rule => nil,
177
+ :ignore_private => true) == unicode_host
165
178
  end
166
179
 
167
180
  # Should the domain use an A record?
@@ -181,6 +194,7 @@ module GitHubPages
181
194
  # Are any of the domain's A records pointing elsewhere?
182
195
  def non_github_pages_ip_present?
183
196
  return unless dns?
197
+
184
198
  a_records = dns.select { |answer| answer.type == Dnsruby::Types::A }
185
199
 
186
200
  a_records.any? { |answer| !github_pages_ip?(answer.address.to_s) }
@@ -256,6 +270,7 @@ module GitHubPages
256
270
  return false if cname_to_github_user_domain?
257
271
  return false if cname_to_pages_dot_github_dot_com?
258
272
  return false if cname_to_fastly? || fastly_ip?
273
+
259
274
  served_by_pages?
260
275
  end
261
276
 
@@ -270,9 +285,11 @@ module GitHubPages
270
285
  def dns
271
286
  return @dns if defined? @dns
272
287
  return unless valid_domain?
288
+
273
289
  @dns = Timeout.timeout(TIMEOUT) do
274
290
  GitHubPages::HealthCheck.without_warnings do
275
291
  next if host.nil?
292
+
276
293
  REQUESTED_RECORD_TYPES
277
294
  .map { |type| resolver.query(type) }
278
295
  .flatten.uniq
@@ -300,11 +317,13 @@ module GitHubPages
300
317
  # Is this domain's first response an A record?
301
318
  def a_record?
302
319
  return unless dns?
320
+
303
321
  dns.first.type == Dnsruby::Types::A
304
322
  end
305
323
 
306
324
  def aaaa_record_present?
307
325
  return unless dns?
326
+
308
327
  dns.any? { |answer| answer.type == Dnsruby::Types::AAAA }
309
328
  end
310
329
 
@@ -312,6 +331,7 @@ module GitHubPages
312
331
  def cname_record?
313
332
  return unless dns?
314
333
  return false unless cname
334
+
315
335
  cname.valid_domain?
316
336
  end
317
337
  alias cname? cname_record?
@@ -319,12 +339,15 @@ module GitHubPages
319
339
  # The domain to which this domain's CNAME resolves
320
340
  # Returns nil if the domain is not a CNAME
321
341
  def cname
322
- return unless dns.first.type == Dnsruby::Types::CNAME
323
- @cname ||= Domain.new(dns.first.cname.to_s)
342
+ cnames = dns.take_while { |answer| answer.type == Dnsruby::Types::CNAME }
343
+ return if cnames.empty?
344
+
345
+ @cname ||= Domain.new(cnames.last.cname.to_s)
324
346
  end
325
347
 
326
348
  def mx_records_present?
327
349
  return unless dns?
350
+
328
351
  dns.any? { |answer| answer.type == Dnsruby::Types::MX }
329
352
  end
330
353
 
@@ -337,7 +360,7 @@ module GitHubPages
337
360
  return true if response.headers["Server"] == "GitHub.com"
338
361
 
339
362
  # Typhoeus mangles the case of the header, compare insensitively
340
- response.headers.any? { |k, _v| k =~ /X-GitHub-Request-Id/i }
363
+ response.headers.any? { |k, _v| k.downcase == "x-github-request-id" }
341
364
  end
342
365
  end
343
366
 
@@ -361,27 +384,40 @@ module GitHubPages
361
384
  # Does this domain redirect HTTP requests to HTTPS?
362
385
  def enforces_https?
363
386
  return false unless https? && http_response.headers["Location"]
387
+
364
388
  redirect = Addressable::URI.parse(http_response.headers["Location"])
365
389
  redirect.scheme == "https" && redirect.host == host
366
390
  end
367
391
 
368
392
  # Can an HTTPS certificate be issued for this domain?
369
393
  def https_eligible?
370
- (cname_to_github_user_domain? || pointed_to_github_pages_ip?) &&
371
- !aaaa_record_present? && !non_github_pages_ip_present? &&
372
- caa.lets_encrypt_allowed?
394
+ # Can't have any IP's which aren't GitHub's present.
395
+ return false if non_github_pages_ip_present?
396
+ # Can't have any AAAA records present
397
+ return false if aaaa_record_present?
398
+ # Must be a CNAME or point to our IPs.
399
+
400
+ # Only check the one domain if a CNAME. Don't check the parent domain.
401
+ return true if cname_to_github_user_domain?
402
+
403
+ # Check CAA records for the full domain and its parent domain.
404
+ pointed_to_github_pages_ip? && caa.lets_encrypt_allowed?
373
405
  end
374
406
 
375
407
  # Any errors querying CAA records
376
408
  def caa_error
377
409
  return nil unless caa.errored?
410
+
378
411
  caa.error.class.name
379
412
  end
380
413
 
381
414
  private
382
415
 
383
416
  def caa
384
- @caa ||= GitHubPages::HealthCheck::CAA.new(host, :nameservers => nameservers)
417
+ @caa ||= GitHubPages::HealthCheck::CAA.new(
418
+ :host => cname&.host || host,
419
+ :nameservers => nameservers
420
+ )
385
421
  end
386
422
 
387
423
  # The domain's response to HTTP(S) requests, following redirects
@@ -3,8 +3,8 @@
3
3
  module GitHubPages
4
4
  module HealthCheck
5
5
  class Error < StandardError
6
- DOCUMENTATION_BASE = "https://help.github.com".freeze
7
- DOCUMENTATION_PATH = "/categories/github-pages-basics/".freeze
6
+ DOCUMENTATION_BASE = "https://help.github.com"
7
+ DOCUMENTATION_PATH = "/categories/github-pages-basics/"
8
8
  LOCAL_ONLY = false # Error is only used when running locally
9
9
 
10
10
  attr_reader :repository, :domain
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Dir[File.expand_path("errors/*_error.rb", __dir__)].each do |f|
3
+ Dir[File.expand_path("errors/*_error.rb", __dir__)].sort.each do |f|
4
4
  require f
5
5
  end
6
6
 
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class BuildError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/troubleshooting-jekyll-builds/".freeze
7
+ DOCUMENTATION_PATH = "/articles/troubleshooting-jekyll-builds/"
8
8
  LOCAL_ONLY = true
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class DeprecatedIPError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  <<-MSG
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class InvalidARecordError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  <<-MSG
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class InvalidAAAARecordError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  <<-MSG
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class InvalidCNAMEError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  <<-MSG
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class InvalidDNSError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  "Domain's DNS record could not be retrieved"
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class InvalidDomainError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  "Domain is not a valid domain"
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  module Errors
6
6
  class NotServedByPagesError < GitHubPages::HealthCheck::Error
7
- DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/".freeze
7
+ DOCUMENTATION_PATH = "/articles/setting-up-a-custom-domain-with-github-pages/"
8
8
 
9
9
  def message
10
10
  "Domain does not resolve to the GitHub Pages server"
@@ -4,7 +4,7 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  class Printer
6
6
  PRETTY_LEFT_WIDTH = 11
7
- PRETTY_JOINER = " | ".freeze
7
+ PRETTY_JOINER = " | "
8
8
 
9
9
  attr_reader :health_check
10
10
 
@@ -5,7 +5,7 @@ module GitHubPages
5
5
  class Repository < Checkable
6
6
  attr_reader :name, :owner
7
7
 
8
- REPO_REGEX = %r{\A[a-z0-9_\-]+/[a-z0-9_\-\.]+\z}i
8
+ REPO_REGEX = %r{\A[a-z0-9_\-]+/[a-z0-9_\-\.]+\z}i.freeze
9
9
 
10
10
  HASH_METHODS = %i[
11
11
  name_with_owner built? last_built build_duration build_error
@@ -15,6 +15,7 @@ module GitHubPages
15
15
  unless name_with_owner.match(REPO_REGEX)
16
16
  raise Errors::InvalidRepositoryError
17
17
  end
18
+
18
19
  parts = name_with_owner.split("/")
19
20
  @owner = parts.first
20
21
  @name = parts.last
@@ -28,6 +29,7 @@ module GitHubPages
28
29
 
29
30
  def check!
30
31
  raise Errors::BuildError.new(:repository => self), build_error unless built?
32
+
31
33
  true
32
34
  end
33
35
 
@@ -45,15 +47,16 @@ module GitHubPages
45
47
  alias reason build_error
46
48
 
47
49
  def build_duration
48
- last_build && last_build.duration
50
+ last_build&.duration
49
51
  end
50
52
 
51
53
  def last_built
52
- last_build && last_build.updated_at
54
+ last_build&.updated_at
53
55
  end
54
56
 
55
57
  def domain
56
58
  return if cname.nil?
59
+
57
60
  @domain ||= GitHubPages::HealthCheck::Domain.redundant(cname)
58
61
  end
59
62
 
@@ -61,6 +64,7 @@ module GitHubPages
61
64
 
62
65
  def client
63
66
  raise Errors::MissingAccessTokenError if @access_token.nil?
67
+
64
68
  @client ||= Octokit::Client.new(:access_token => @access_token)
65
69
  end
66
70
 
@@ -4,10 +4,10 @@ module GitHubPages
4
4
  module HealthCheck
5
5
  class Resolver
6
6
  DEFAULT_RESOLVER_OPTIONS = {
7
- :retry_times => 2,
7
+ :retry_times => 2,
8
8
  :query_timeout => 5,
9
- :dnssec => false,
10
- :do_caching => false
9
+ :dnssec => false,
10
+ :do_caching => false
11
11
  }.freeze
12
12
  PUBLIC_NAMESERVERS = %w(
13
13
  8.8.8.8
@@ -43,16 +43,16 @@ module GitHubPages
43
43
  self.class.default_resolver
44
44
  when :authoritative
45
45
  Dnsruby::Resolver.new(DEFAULT_RESOLVER_OPTIONS.merge(
46
- :nameservers => authoritative_nameservers
47
- ))
46
+ :nameservers => authoritative_nameservers
47
+ ))
48
48
  when :public
49
49
  Dnsruby::Resolver.new(DEFAULT_RESOLVER_OPTIONS.merge(
50
- :nameservers => PUBLIC_NAMESERVERS
51
- ))
50
+ :nameservers => PUBLIC_NAMESERVERS
51
+ ))
52
52
  when Array
53
53
  Dnsruby::Resolver.new(DEFAULT_RESOLVER_OPTIONS.merge(
54
- :nameservers => nameservers
55
- ))
54
+ :nameservers => nameservers
55
+ ))
56
56
  else
57
57
  raise "Invalid nameserver type: #{nameservers.inspect}"
58
58
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitHubPages
4
4
  module HealthCheck
5
- VERSION = "1.13.0".freeze
5
+ VERSION = "1.17.0"
6
6
  end
7
7
  end
@@ -4,7 +4,7 @@ set -ex
4
4
 
5
5
  script/bootstrap
6
6
 
7
- script/test
7
+ script/test $@
8
8
  script/check-cdn-ips
9
9
  bundle exec script/check www.parkermoore.de | grep 'valid?: true'
10
10
  bundle exec script/check ben.balter.com | grep 'valid?: true'
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+
3
+ : ${RUBY_VERSION:="2.7"}
4
+ docker build -t github-pages-health-check --build-arg RUBY_VERSION=$RUBY_VERSION .
5
+ if [ -n "$DEBUG" ]; then
6
+ # Run a shell.
7
+ docker run -it --rm -v $(pwd):/app/github-pages-health-check github-pages-health-check
8
+ else
9
+ # Run CI
10
+ docker run --rm github-pages-health-check script/cibuild --profile --fail-fast
11
+ fi
@@ -3,4 +3,4 @@
3
3
  set -e
4
4
 
5
5
  bundle exec rspec $@
6
- script/fmt $@
6
+ script/fmt
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-pages-health-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-28 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -56,16 +56,22 @@ dependencies:
56
56
  name: public_suffix
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.2
62
+ - - "<"
60
63
  - !ruby/object:Gem::Version
61
- version: '2.0'
64
+ version: '5.0'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 2.0.2
72
+ - - "<"
67
73
  - !ruby/object:Gem::Version
68
- version: '2.0'
74
+ version: '5.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: typhoeus
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -80,100 +86,20 @@ dependencies:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '1.3'
83
- - !ruby/object:Gem::Dependency
84
- name: dotenv
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.0'
97
- - !ruby/object:Gem::Dependency
98
- name: gem-release
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.7'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.7'
111
- - !ruby/object:Gem::Dependency
112
- name: pry
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.10'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.10'
125
- - !ruby/object:Gem::Dependency
126
- name: rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '3.0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '3.0'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '0.52'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.52'
153
- - !ruby/object:Gem::Dependency
154
- name: webmock
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '1.21'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.21'
167
89
  description: Checks your GitHub Pages site for commons DNS configuration issues.
168
90
  email: support@github.com
169
91
  executables: []
170
92
  extensions: []
171
93
  extra_rdoc_files: []
172
94
  files:
95
+ - ".dockerignore"
96
+ - ".github/workflows/push-cibuild.yml"
173
97
  - ".gitignore"
174
98
  - ".rspec"
175
99
  - ".rubocop.yml"
100
+ - ".ruby-version"
176
101
  - ".travis.yml"
102
+ - Dockerfile
177
103
  - Gemfile
178
104
  - LICENSE.md
179
105
  - README.md
@@ -209,6 +135,7 @@ files:
209
135
  - script/check
210
136
  - script/check-cdn-ips
211
137
  - script/cibuild
138
+ - script/cibuild-docker
212
139
  - script/console
213
140
  - script/fmt
214
141
  - script/release
@@ -218,7 +145,7 @@ homepage: https://github.com/github/github-pages-health-check
218
145
  licenses:
219
146
  - MIT
220
147
  metadata: {}
221
- post_install_message:
148
+ post_install_message:
222
149
  rdoc_options: []
223
150
  require_paths:
224
151
  - lib
@@ -233,9 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
160
  - !ruby/object:Gem::Version
234
161
  version: '0'
235
162
  requirements: []
236
- rubyforge_project:
237
- rubygems_version: 2.7.6
238
- signing_key:
163
+ rubygems_version: 3.1.2
164
+ signing_key:
239
165
  specification_version: 4
240
166
  summary: Checks your GitHub Pages site for commons DNS configuration issues
241
167
  test_files: []