Skip to content

Commit 0fcd241

Browse files
committed
Validate and enforce style via CI
1 parent 82e637a commit 0fcd241

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

.rubocop.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
AllCops:
2+
Exclude:
3+
- _site/**/*
4+
5+
Metrics/LineLength:
6+
Enabled: false

jekyll-theme-dinky.gemspec

+4
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ Gem::Specification.new do |s|
1616
s.platform = Gem::Platform::RUBY
1717
s.add_runtime_dependency "jekyll", "~> 3.5"
1818
s.add_runtime_dependency "jekyll-seo-tag", "~> 2.0"
19+
s.add_development_dependency 'w3c_validators', "~> 1.3"
20+
s.add_development_dependency 'html-proofer', "~> 3.0"
21+
s.add_development_dependency 'rubocop', "~> 0.50"
22+
1923
end

script/cibuild

+3
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
set -e
44

55
bundle exec jekyll build
6+
bundle exec htmlproofer ./_site --check-html --disable-external
7+
bundle exec rubocop -D
8+
bundle exec script/validate-html
69
gem build jekyll-theme-dinky.gemspec

script/validate-html

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'w3c_validators'
4+
5+
def validator(file)
6+
extension = File.extname(file)
7+
if extension == '.html'
8+
W3CValidators::NuValidator.new
9+
elsif extension == '.css'
10+
W3CValidators::CSSValidator.new
11+
end
12+
end
13+
14+
def validate(file)
15+
puts "Checking #{file}..."
16+
17+
path = File.expand_path "../_site/#{file}", __dir__
18+
results = validator(file).validate_file(path)
19+
20+
return puts 'Valid!' if results.errors.empty?
21+
22+
results.errors.each { |err| puts err.to_s }
23+
exit 1
24+
end
25+
26+
validate 'index.html'
27+
validate File.join 'assets', 'css', 'style.css'

0 commit comments

Comments
 (0)