Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sudo: false
rvm: 2.4.2
cache:
bundler: true
script: bundle exec rake ci
# Notifications, used by our Gitter channel.
notifications:
webhooks:
Expand Down
23 changes: 19 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ rescue LoadError => e
exit -1
end

require 'pathname'

HOST = 'www.ruby-lang.org'
LANGUAGES = %w[bg de en es fr id it ja ko pl pt ru tr vi zh_cn zh_tw]
CONFIG = "_config.yml"
Expand Down Expand Up @@ -122,27 +124,33 @@ namespace :check do
date ? date.getutc.strftime('%Y/%m/%d') : nil
end

def glob(pattern)
Pathname.glob(pattern).reject {|path| path.expand_path.to_s =~ %r{\A#{Regexp.escape(Bundler.bundle_path.to_s)}/} }.map(&:to_s)
end

desc "Check for missing author variables in news posts"
task :author do
print "Checking for missing author variables in news posts..."

md_files = Dir["**/_posts/*.md"]
md_files = glob("**/_posts/*.md")

author_missing = md_files.select {|fn| !author_variable_defined?(fn) }
if author_missing.empty?
puts " ok"
else
puts "\nNo author variable defined in:"
puts author_missing.map {|s| " #{s}\n"}.join

raise
end
end

desc "Check for missing lang variables in markdown files"
task :lang do
print "Checking for missing lang variables in markdown files..."

md_files = Dir["**/*.md"]
skip_patterns = [/README.md/, %r{[^/]*/examples/}]
md_files = glob("**/*.md")
skip_patterns = [/README.md/, %r{[^/]*/examples/}, %r{\A_includes/}]

skip_patterns.each do |pattern|
md_files.delete_if {|fn| fn =~ pattern }
Expand All @@ -154,14 +162,16 @@ namespace :check do
else
puts "\nNo lang variable defined in:"
puts lang_missing.map {|s| " #{s}\n"}.join

raise
end
end

desc "Check publication dates (UTC) for consistency with filename"
task :pubdates do
print "Checking for date mismatch in posts (filename / YAML front matter)..."

posts = Dir["**/_posts/*.md"]
posts = glob("**/_posts/*.md")

date_mismatch = []
posts.each do |post|
Expand All @@ -176,6 +186,8 @@ namespace :check do
else
puts "\nDate mismatch in:"
puts date_mismatch.map {|s| " #{s}\n"}.join

raise
end
end

Expand Down Expand Up @@ -213,6 +225,8 @@ namespace :check do
else
puts "New Broken Link: #{origin} -> #{dest}"
end

raise
end
end
end
Expand All @@ -234,3 +248,4 @@ end

desc "Run some tests (lang, author, pubdates)"
task :check => ['check:lang', 'check:author', 'check:pubdates']
task :ci => [:test, :build]