Skip to content

Commit beb8b32

Browse files
authored
Merge pull request #1667 from mtsmfm/fix-test
Run test on Travis CI
2 parents b23a1ed + 964d1eb commit beb8b32

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ sudo: false
33
rvm: 2.4.2
44
cache:
55
bundler: true
6+
script: bundle exec rake ci
67
# Notifications, used by our Gitter channel.
78
notifications:
89
webhooks:

Rakefile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ rescue LoadError => e
1010
exit -1
1111
end
1212

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

127+
def glob(pattern)
128+
Pathname.glob(pattern).reject {|path| path.expand_path.to_s =~ %r{\A#{Regexp.escape(Bundler.bundle_path.to_s)}/} }.map(&:to_s)
129+
end
130+
125131
desc "Check for missing author variables in news posts"
126132
task :author do
127133
print "Checking for missing author variables in news posts..."
128134

129-
md_files = Dir["**/_posts/*.md"]
135+
md_files = glob("**/_posts/*.md")
130136

131137
author_missing = md_files.select {|fn| !author_variable_defined?(fn) }
132138
if author_missing.empty?
133139
puts " ok"
134140
else
135141
puts "\nNo author variable defined in:"
136142
puts author_missing.map {|s| " #{s}\n"}.join
143+
144+
raise
137145
end
138146
end
139147

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

144-
md_files = Dir["**/*.md"]
145-
skip_patterns = [/README.md/, %r{[^/]*/examples/}]
152+
md_files = glob("**/*.md")
153+
skip_patterns = [/README.md/, %r{[^/]*/examples/}, %r{\A_includes/}]
146154

147155
skip_patterns.each do |pattern|
148156
md_files.delete_if {|fn| fn =~ pattern }
@@ -154,14 +162,16 @@ namespace :check do
154162
else
155163
puts "\nNo lang variable defined in:"
156164
puts lang_missing.map {|s| " #{s}\n"}.join
165+
166+
raise
157167
end
158168
end
159169

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

164-
posts = Dir["**/_posts/*.md"]
174+
posts = glob("**/_posts/*.md")
165175

166176
date_mismatch = []
167177
posts.each do |post|
@@ -176,6 +186,8 @@ namespace :check do
176186
else
177187
puts "\nDate mismatch in:"
178188
puts date_mismatch.map {|s| " #{s}\n"}.join
189+
190+
raise
179191
end
180192
end
181193

@@ -213,6 +225,8 @@ namespace :check do
213225
else
214226
puts "New Broken Link: #{origin} -> #{dest}"
215227
end
228+
229+
raise
216230
end
217231
end
218232
end
@@ -234,3 +248,4 @@ end
234248

235249
desc "Run some tests (lang, author, pubdates)"
236250
task :check => ['check:lang', 'check:author', 'check:pubdates']
251+
task :ci => [:test, :build]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)