I maintain several awesome-style lists, namely: awesome-react-native, awesome-devenv, awesome-colorschemes, awesome-weekly, and awesome-beginners.
Some more complete than others, and being an OCD curator, some really serve my own needs.
What I (and probably others) didn’t realize, is that since the web is constantly changing, these lists are subject to breaking — directly proportional to the number of links they host.
Travis CI
I’ve been using Travis CI for nearly every serious project I host on Github, and it is really valuable, especially when I have an open-source project which is really nothing more than an idea, execution, and good intentions of the original author and community.
For my awesome-lists, to make sure they don’t break without my noticing, and to make sure each pull request contains a valid link, I thought of using Travis CI along with a custom script to parse and verify links from a markdown document.
Surely this is not really testing code, and I hope it still is blessed by Travis CI (thanks for this awesome free service for open-source projects, guys!) but still it can be looked at as a sort of an integration test.
The validation script is pretty naive, at the expense of being dead simple and yet effective:
= ||
doc = Nokogiri::HTML(Kramdown::Document.new(open().read).to_html)
links = doc.css().to_a
puts
invalids = []
Parallel.each(links, :in_threads => 4) do
begin
uri = URI.join(BASE_URI, link.attr())
open(uri)
putc()
rescue
putc()
invalids << link
end
end
unless invalids.empty?
puts
invalids.each do
puts
end
puts
exit(1)
end
puts
And the Travis setup should be something like this:
language: ruby
rvm:
- 2.2
script: bundle exec ruby validate.rb
And then, on each commit a build runs. A failing build looks like this:
Validating 254 links...
.........................................................F....................................................................................................................................................................................................
Failed links:
- react-native-context-menu
Done with errors.
And is nicely exposed with a Travis badge on my READMEs.
Check this out live on my awesome-react-native list.