Validate and enforce style via CI
This commit is contained in:
parent
678ff1f164
commit
39a52d72a2
6
.rubocop.yml
Normal file
6
.rubocop.yml
Normal file
@ -0,0 +1,6 @@
|
||||
AllCops:
|
||||
Exclude:
|
||||
- _site/**/*
|
||||
|
||||
Metrics/LineLength:
|
||||
Enabled: false
|
@ -16,4 +16,8 @@ Gem::Specification.new do |s|
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.add_runtime_dependency "jekyll", "~> 3.5"
|
||||
s.add_runtime_dependency "jekyll-seo-tag", "~> 2.0"
|
||||
s.add_development_dependency 'w3c_validators', "~> 1.3"
|
||||
s.add_development_dependency 'html-proofer', "~> 3.0"
|
||||
s.add_development_dependency 'rubocop', "~> 0.50"
|
||||
|
||||
end
|
||||
|
@ -3,4 +3,7 @@
|
||||
set -e
|
||||
|
||||
bundle exec jekyll build
|
||||
bundle exec htmlproofer ./_site --check-html --disable-external
|
||||
bundle exec rubocop -D
|
||||
bundle exec script/validate-html
|
||||
gem build jekyll-theme-hacker.gemspec
|
||||
|
27
script/validate-html
Executable file
27
script/validate-html
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'w3c_validators'
|
||||
|
||||
def validator(file)
|
||||
extension = File.extname(file)
|
||||
if extension == '.html'
|
||||
W3CValidators::NuValidator.new
|
||||
elsif extension == '.css'
|
||||
W3CValidators::CSSValidator.new
|
||||
end
|
||||
end
|
||||
|
||||
def validate(file)
|
||||
puts "Checking #{file}..."
|
||||
|
||||
path = File.expand_path "../_site/#{file}", __dir__
|
||||
results = validator(file).validate_file(path)
|
||||
|
||||
return puts 'Valid!' if results.errors.empty?
|
||||
|
||||
results.errors.each { |err| puts err.to_s }
|
||||
exit 1
|
||||
end
|
||||
|
||||
validate 'index.html'
|
||||
validate File.join 'assets', 'css', 'style.css'
|
Loading…
Reference in New Issue
Block a user