forked from ev3dev/ev3dev.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cibuild.sh
executable file
·72 lines (63 loc) · 2.51 KB
/
cibuild.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
set -e # halt script on error
echo "Searching for BOMs -------------------------------"
FOUND_BOM=false
for filename in ./**/*.*; do
# Make sure that the file is UTF-8 so we don't search binary files or other encodings
CURRENT_FILE_ENCODING="`file --mime-encoding --brief "$filename"`"
if [ "$CURRENT_FILE_ENCODING" == "utf-8" ] && [ "`head -c 3 -- "$filename"`" == $'\xef\xbb\xbf' ]
then
# Make note of all the files that failed so we can see it in the Travis log
FOUND_BOM=true
echo "Found BOM in file $filename!"
fi
done
if [ $FOUND_BOM == true ]
then
# We still want to run the other validation checks even if we found BOMs
echo "Checks failed! Jekyll can't handle BOMs. See above for list of problematic files."
else
echo "Checks passed! No BOMs found."
fi
echo "Building site ------------------------------------"
bundle exec jekyll build --trace
if [ "$TRAVIS" == "true" ]; then
# Travis has issues with https, so we have to ignore quite a few extra sites
# credit: code snippet borrowed from jekyllrb.com website source
IGNORE_HREFS=$(ruby -e 'puts %w{
example.com
https:\/\/github\.com\/myuser\/myrepo
.*revolds-whitepaper\.pdf
https:\/\/github.com\/ev3dev\/ev3dev\.github\.io\/edit\/.*
robosnap.net
warmcat.com
01.org
alldatasheet.com
kernel\.org
lab\.open-roberta\.org
questforspace\.com
bountysource\.com
barryodonovan\.com
}.map{|h| "/#{h}/"}.join(",")')
else
# credit: code snippet borrowed from jekyllrb.com website source
IGNORE_HREFS=$(ruby -e 'puts %w{
example.com
https:\/\/github\.com\/myuser\/myrepo
https:\/\/github.com\/ev3dev\/ev3dev\.github\.io\/edit\/.*
robosnap.net
}.map{|h| "/#{h}/"}.join(",")')
fi
# Explanation of ignored sites:
# - example.com and github.com/myuser/myrepo are fake/example links
# - The edit on github pages don't exist when you create a page, so ignoring them.
# They are automatically generated anyway.
# - robosnap.net no longer exists, but keeping the link for historical reasons
echo "Validating HTML ----------------------------------"
# We want to use the publish script so that we can implement other transformations in the future
ruby publish.rb --no-fix-links --test "htmlproofer ./ --url-ignore $IGNORE_HREFS --check-html --allow-hash-href"
# If the site build succeeded but we found BOMs, we want to fail the build
if [ $FOUND_BOM == true ]
then
exit 1
fi