Skip to content

Commit 7db5215

Browse files
committed
Add validation of the kit versions data
Very simple checking for now, but likely good enough to catch typos.
1 parent f8890cd commit 7db5215

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Rakefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'yaml'
2+
13
task :clean do
24
sh('rm -rf _site')
35
end
@@ -24,7 +26,21 @@ task :build => [:dependencies, :submodules] do
2426
sh('bundle exec jekyll build --config _config.yml')
2527
end
2628

27-
task :validate => [:build] do
29+
task :validate_kit_versions do
30+
data = YAML.load_file('_data/kit_versions.yml')
31+
data.each do |entry|
32+
actual = entry.keys.to_set
33+
expected = ['version', 'released'].to_set
34+
missing = expected - actual
35+
extra = actual - expected
36+
messages = []
37+
messages << "Missing keys: #{missing.to_a.join(', ')}" if missing.size() > 0
38+
messages << "Extra keys: #{extra.to_a.join(', ')}" if extra.size() > 0
39+
raise "For entry\n#{entry}\n#{messages.join("\n")}\n\n" if messages.size() > 0
40+
end
41+
end
42+
43+
task :validate_links => [:build] do
2844
# Explanation of arguments:
2945
# --assume-extension # Tells html-proofer that `.html` files can be accessed without the `.html` part in the url.
3046
# --disable-external # For speed. Ideally we'd check external links too, but ignoring for now.
@@ -33,3 +49,5 @@ task :validate => [:build] do
3349
# --url-swap # Adjust for Jekyll's baseurl. See https://github.com/gjtorikian/html-proofer/issues/618 for more.
3450
sh('bundle exec htmlproofer _site --assume-extension --disable-external --empty-alt-ignore --allow-hash-href --url-swap "^/docs/:/"')
3551
end
52+
53+
task :validate => [:validate_kit_versions, :validate_links]

0 commit comments

Comments
 (0)