Skip to content

Commit

Permalink
Adds support for Continous Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
eksperimental committed Mar 1, 2015
1 parent 289270c commit bd9f22f
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/_site
/_site
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: ruby
rvm:
- 2.1
python:
- 2.7
install:
- sudo pip install html5validator
- bundle install
script:
- bundle exec jekyll build
- ./script/cibuild
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source 'https://rubygems.org'

gem 'github-pages'
gem 'jekyll-redirect-from'
gem 'html-proofer'
24 changes: 20 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.7)
blankslate (2.1.2.4)
celluloid (0.16.0)
timers (~> 4.0.0)
Expand All @@ -16,8 +17,11 @@ GEM
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.9.0)
coffee-script-source (1.9.1)
colorator (0.1)
colored (1.2)
ethon (0.7.3)
ffi (>= 1.3.0)
execjs (2.3.0)
fast-stemmer (1.0.2)
ffi (1.9.6)
Expand Down Expand Up @@ -47,6 +51,14 @@ GEM
html-pipeline (1.9.0)
activesupport (>= 2)
nokogiri (~> 1.4)
html-proofer (2.1.0)
addressable (~> 2.3)
colored (~> 1.2)
mercenary (~> 0.3.2)
nokogiri (~> 1.5)
parallel (~> 1.3)
typhoeus (~> 0.7)
yell (~> 2.0)
i18n (0.7.0)
jekyll (2.4.0)
classifier-reborn (~> 2.0)
Expand Down Expand Up @@ -95,9 +107,10 @@ GEM
net-dns (0.8.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
parallel (1.4.0)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.9)
posix-spawn (0.3.10)
public_suffix (1.4.6)
pygments.rb (0.6.1)
posix-spawn (~> 0.3.6)
Expand All @@ -108,20 +121,23 @@ GEM
rdiscount (2.1.7)
redcarpet (3.1.2)
safe_yaml (1.0.4)
sass (3.4.11)
sass (3.4.13)
terminal-table (1.4.5)
thread_safe (0.3.4)
timers (4.0.1)
hitimes
toml (0.1.2)
parslet (~> 1.5.0)
typhoeus (0.7.1)
ethon (>= 0.7.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
yajl-ruby (1.2.1)
yell (2.0.5)

PLATFORMS
ruby

DEPENDENCIES
github-pages
jekyll-redirect-from
html-proofer
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ permalink: /blog/:year/:month/:day/:title/
redcarpet:
extensions: ['with_toc_data', 'tables']
gems:
- jekyll-redirect-from
- jekyll-redirect-from
exclude: [vendor]
13 changes: 13 additions & 0 deletions script/cibuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$DIR"
echo "------------------------------------------------------------------------"
echo "* Task #1: html5validator"
./filter-html5validator
echo
echo "------------------------------------------------------------------------"
echo "* Task #2: htmlproof"
./filter-htmlproof
echo
echo "------------------------------------------------------------------------"
16 changes: 16 additions & 0 deletions script/filter-html5validator
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$DIR"
source "$DIR/filter-lib.sh"

filter_errors() {
grep -v "Bad value “X-UA-Compatible” for attribute “http-equiv” on element “meta”" #|
#grep " error: "
}

filter_html5validator() {
filter_it "$DIR/../_site/" "html5validator --blacklist docs"
}

filter_html5validator
41 changes: 41 additions & 0 deletions script/filter-htmlproof
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$DIR"
source "$DIR/filter-lib.sh"

filter_errors() {
grep -v "linking to /docs/stable/elixir/Kernel.html#%7C%3E/2, but %7C%3E/2 does not exist" |
grep -vP "internally linking to \/docs\/.*, which does not exist" |
grep -vP "trying to find hash of \/docs\/.*, but .* does not exist" |

filter_more_errors |

#delete every file hat has no error (that is, anything file that is not follow by a line starting with " * ")
perl -0777 -pe 's/\- .*\n(?!\s+\*\s+)//g'
}

filter_more_errors() {
perl -CSAD -ne '
BEGIN {
my $current_file = "";
}
if ( /^- / ) {
$current_file = $_;
} elsif ( $current_file =~ /getting_started/ ) {
s/\s+\*\s+no favicon specified\n//;
}
print
' $1
}

filter_success() {
perl -CSAD -pe "s/\|\s+Error:\s+HTML-Proofer found \d+ failures?\!//g" |
perl -0777 -CSAD -pe "s/\n{3,}/\n\n/g"
}

filter_htmlproof() {
filter_it "$DIR/../" "bundle exec htmlproof ./_site --file-ignore /docs/ --only-4xx --check-favicon --check-html --check-external-hash"
}

filter_htmlproof
48 changes: 48 additions & 0 deletions script/filter-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

TEMP_DIR=$(mktemp -dt "$(basename $0).XXXXXXXXXX")

STDOUT="$TEMP_DIR/htmlproof_stdout"
STDERR="$TEMP_DIR/htmlproof_stderr"
STDERR_PRE="$TEMP_DIR/htmlproof_stderr_pre"

clean_temp_files() {
rm -rf "$TEMP_DIR" 2> /dev/null
}

function validate() {
local cmd="$1"
echo "$cmd" &&
$cmd 1>"$STDOUT" 2>"$STDERR_PRE"
cat "$STDERR_PRE" | filter_errors >"$STDERR"
}

filter_success() {
perl -0777 -CSAD -pe "s/\n{3,}/\n\n/g"
}

# filter_it <full_path_dir> <command>
filter_it() {
local dir=$(readlink -f "$1")
pushd "$dir" 1> /dev/null
pwd
validate "$2"
errors=$(<"$STDERR")
length=${#errors}
if [ "$length" -gt 0 ]; then
echo "ERROR: Documents are not valid" >&2
echo
cat "$STDERR" >&2
clean_temp_files
popd 1> /dev/null
return 1
else
cat "$STDOUT" | filter_success
echo
echo "OK: Documents successfully validated"
cat "$STDERR" >&2
clean_temp_files
popd 1> /dev/null
return 0
fi
}

0 comments on commit bd9f22f

Please sign in to comment.