Skip to content

Commit 8f643b9

Browse files
authored
Merge pull request kodecocodes#647 from aquarchitect/master
GitHub Pages
2 parents ff30d17 + 6ca1ad1 commit 8f643b9

File tree

2 files changed

+149
-39
lines changed

2 files changed

+149
-39
lines changed

.travis.yml

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,50 @@ osx_image: xcode9
44

55
install:
66

7+
- gem install xcpretty-travis-formatter
78
# - ./install_swiftlint.sh
89

910
script:
1011

11-
- xcodebuild test -project ./All-Pairs\ Shortest\ Paths/APSP/APSP.xcodeproj -scheme APSPTests
12-
- xcodebuild test -project ./Array2D/Tests/Tests.xcodeproj -scheme Tests
13-
- xcodebuild test -project ./AVL\ Tree/Tests/Tests.xcodeproj -scheme Tests
14-
- xcodebuild test -project ./Binary\ Search/Tests/Tests.xcodeproj -scheme Tests
15-
- xcodebuild test -project ./Boyer-Moore-Horspool/Tests/Tests.xcodeproj -scheme Tests
16-
- xcodebuild test -project ./Binary\ Search\ Tree/Solution\ 1/Tests/Tests.xcodeproj -scheme Tests
17-
- xcodebuild test -project ./Bloom\ Filter/Tests/Tests.xcodeproj -scheme Tests
18-
- xcodebuild test -project ./Bounded\ Priority\ Queue/Tests/Tests.xcodeproj -scheme Tests
19-
- xcodebuild test -project ./Breadth-First\ Search/Tests/Tests.xcodeproj -scheme Tests
20-
- xcodebuild test -project ./Bucket\ Sort/Tests/Tests.xcodeproj -scheme Tests
21-
- xcodebuild test -project ./B-Tree/Tests/Tests.xcodeproj -scheme Tests
22-
- xcodebuild test -project ./Comb\ Sort/Tests/Tests.xcodeproj -scheme Tests
23-
- xcodebuild test -project ./Convex\ Hull/Convex\ Hull.xcodeproj -scheme Tests -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0'
24-
- xcodebuild test -project ./Counting\ Sort/Tests/Tests.xcodeproj -scheme Tests
25-
- xcodebuild test -project ./Depth-First\ Search/Tests/Tests.xcodeproj -scheme Tests
26-
- xcodebuild test -project ./Graph/Graph.xcodeproj -scheme GraphTests
27-
- xcodebuild test -project ./Heap/Tests/Tests.xcodeproj -scheme Tests
28-
- xcodebuild test -project ./Heap\ Sort/Tests/Tests.xcodeproj -scheme Tests
29-
- xcodebuild test -project ./Insertion\ Sort/Tests/Tests.xcodeproj -scheme Tests
30-
- xcodebuild test -project ./K-Means/Tests/Tests.xcodeproj -scheme Tests
31-
- xcodebuild test -project ./Linked\ List/Tests/Tests.xcodeproj -scheme Tests
32-
- xcodebuild test -project ./Singly\ Linked\ List/Tests/Tests.xcodeproj -scheme Tests
33-
- xcodebuild test -project ./Longest\ Common\ Subsequence/Tests/Tests.xcodeproj -scheme Tests
34-
- xcodebuild test -project ./Minimum\ Spanning\ Tree\ \(Unweighted\)/Tests/Tests.xcodeproj -scheme Tests
35-
- xcodebuild test -project ./Priority\ Queue/Tests/Tests.xcodeproj -scheme Tests
36-
- xcodebuild test -project ./Queue/Tests/Tests.xcodeproj -scheme Tests
37-
- xcodebuild test -project ./Quicksort/Tests/Tests-Quicksort.xcodeproj -scheme Tests-Quicksort
38-
- xcodebuild test -project ./Radix\ Sort/Tests/Tests.xcodeproj -scheme Tests
39-
- xcodebuild test -project ./Rootish\ Array\ Stack/Tests/Tests.xcodeproj -scheme Tests
40-
- xcodebuild test -project ./Select\ Minimum\ Maximum/Tests/Tests.xcodeproj -scheme Tests
41-
- xcodebuild test -project ./Selection\ Sort/Tests/Tests.xcodeproj -scheme Tests
42-
- xcodebuild test -project ./Shell\ Sort/Tests/Tests.xcodeproj -scheme Tests
43-
- xcodebuild test -project ./Shortest\ Path\ \(Unweighted\)/Tests/Tests.xcodeproj -scheme Tests
44-
- xcodebuild test -project ./Single-Source\ Shortest\ Paths\ \(Weighted\)/SSSP.xcodeproj -scheme SSSPTests
45-
- xcodebuild test -project ./Stack/Tests/Tests.xcodeproj -scheme Tests
46-
- xcodebuild test -project ./Topological\ Sort/Tests/Tests.xcodeproj -scheme Tests
47-
- xcodebuild test -project ./Treap/Treap/Treap.xcodeproj -scheme Tests
48-
- xcodebuild test -project ./Palindromes/Test/Test.xcodeproj -scheme Test
49-
- xcodebuild test -project ./Ternary\ Search\ Tree/Tests/Tests.xcodeproj -scheme Tests
12+
- xcodebuild test -project ./Array2D/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
13+
- xcodebuild test -project ./All-Pairs\ Shortest\ Paths/APSP/APSP.xcodeproj -scheme APSPTests | xcpretty -f `xcpretty-travis-formatter`
14+
- xcodebuild test -project ./AVL\ Tree/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
15+
- xcodebuild test -project ./Binary\ Search/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
16+
- xcodebuild test -project ./Boyer-Moore-Horspool/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
17+
- xcodebuild test -project ./Binary\ Search\ Tree/Solution\ 1/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
18+
- xcodebuild test -project ./Bloom\ Filter/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
19+
- xcodebuild test -project ./Bounded\ Priority\ Queue/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
20+
- xcodebuild test -project ./Breadth-First\ Search/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
21+
- xcodebuild test -project ./Bucket\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
22+
- xcodebuild test -project ./B-Tree/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
23+
- xcodebuild test -project ./Comb\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
24+
- xcodebuild test -project ./Convex\ Hull/Convex\ Hull.xcodeproj -scheme Tests -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0' | xcpretty -f `xcpretty-travis-formatter`
25+
- xcodebuild test -project ./Counting\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
26+
- xcodebuild test -project ./Depth-First\ Search/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
27+
- xcodebuild test -project ./Graph/Graph.xcodeproj -scheme GraphTests | xcpretty -f `xcpretty-travis-formatter`
28+
- xcodebuild test -project ./Heap/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
29+
- xcodebuild test -project ./Heap\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
30+
- xcodebuild test -project ./Insertion\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
31+
- xcodebuild test -project ./K-Means/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
32+
- xcodebuild test -project ./Linked\ List/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
33+
- xcodebuild test -project ./Singly\ Linked\ List/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
34+
- xcodebuild test -project ./Longest\ Common\ Subsequence/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
35+
- xcodebuild test -project ./Minimum\ Spanning\ Tree\ \(Unweighted\)/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
36+
- xcodebuild test -project ./Priority\ Queue/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
37+
- xcodebuild test -project ./Queue/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
38+
- xcodebuild test -project ./Quicksort/Tests/Tests-Quicksort.xcodeproj -scheme Test-Quicksort | xcpretty -f `xcpretty-travis-formatter`
39+
- xcodebuild test -project ./Radix\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
40+
- xcodebuild test -project ./Rootish\ Array\ Stack/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
41+
- xcodebuild test -project ./Select\ Minimum\ Maximum/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
42+
- xcodebuild test -project ./Selection\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
43+
- xcodebuild test -project ./Shell\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
44+
- xcodebuild test -project ./Shortest\ Path\ \(Unweighted\)/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
45+
- xcodebuild test -project ./Single-Source\ Shortest\ Paths\ \(Weighted\)/SSSP.xcodeproj -scheme SSSPTests | xcpretty -f `xcpretty-travis-formatter`
46+
- xcodebuild test -project ./Stack/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
47+
- xcodebuild test -project ./Topological\ Sort/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
48+
- xcodebuild test -project ./Treap/Treap/Treap.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
49+
- xcodebuild test -project ./Palindromes/Test/Test.xcodeproj -scheme Test | xcpretty -f `xcpretty-travis-formatter`
50+
- xcodebuild test -project ./Ternary\ Search\ Tree/Tests/Tests.xcodeproj -scheme Tests | xcpretty -f `xcpretty-travis-formatter`
51+
52+
after_success:
53+
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gfm-render.sh; fi

gfm-render.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env bash
2+
3+
# $1 - readme
4+
function render_markdown_to_html {
5+
# escape escaping characters
6+
if [[ $(uname) == "Darwin" ]]; then
7+
content=$(
8+
cat "$1" \
9+
| sed 's/\\/\\\\/g' \
10+
| sed 's/"/\\"/g' \
11+
| sed $'s/\t/\\\\t/g' \
12+
| sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\\n/g' \
13+
)
14+
else
15+
content=$(
16+
cat "$1" \
17+
| sed 's/\\/\\\\/g' \
18+
| sed 's/"/\\"/g' \
19+
| sed 's/\t/\\t/g' \
20+
| sed ':a;N;$!ba;s/\n/\\n/g' \
21+
)
22+
fi
23+
24+
# network call to GitHub API
25+
json="{\"text\":\"$content\",\"mode\":\"gfm\",\"context\":\"$USERNAME/swift-algorithm-club\"}"
26+
echo -e "$(curl -s --data "$json" -u $USERNAME:$TOKEN https://api.github.com/markdown)"
27+
}
28+
29+
# $1 - comment
30+
function push_to_gh_pages {
31+
git checkout -b gh-pages
32+
git add .
33+
git commit -m "$1"
34+
git push -f https://$TOKEN@github.com/$USERNAME/swift-algorithm-club.git gh-pages
35+
}
36+
37+
# download github systax highlight stylesheet
38+
echo "> Downloading github-light.css..."
39+
curl -s -O https://raw.githubusercontent.com/primer/github-syntax-light/master/lib/github-light.css
40+
41+
# if index.html does not exist, create one;
42+
# otherwise, empty its content.
43+
if [[ -z index.html ]]; then
44+
touch index.html
45+
else
46+
> index.html
47+
fi
48+
49+
# iterate immediate directories
50+
find . -maxdepth 1 -type d | while read folder; do
51+
readme=''
52+
53+
# get the right extension for the README file if there is one
54+
if [[ -f $folder/README.md ]]; then readme="$folder/README.md"; fi
55+
if [[ -f $folder/README.markdown ]]; then readme="$folder/README.markdown"; fi
56+
57+
# exclude the repository's README
58+
if [[ !(-z $readme) && ($readme != "./README.markdown") ]]; then
59+
name=$(basename "$folder")
60+
echo "> Generating $name/index.html..."
61+
62+
cat > "$folder/index.html" << EOF
63+
<!DOCTYPE html>
64+
<head>
65+
<link rel="stylesheet" type="text/css" href="../github-light.css">
66+
<style>
67+
body {
68+
font-size: 18px;
69+
}
70+
code {
71+
padding: 0.2em;
72+
margin: 0;
73+
font-size: 85%;
74+
background-color: #f6f8fa;
75+
line-height: 1.45;
76+
border-radius: 3px
77+
}
78+
pre code {
79+
padding: 0px;
80+
background-color: transparent;
81+
}
82+
.highlight {
83+
margin: 0px;
84+
padding: 0px 16px;
85+
font-size: 85%;
86+
line-height: 1.45;
87+
overflow: auto;
88+
background-color: #f6f8fa;
89+
border-radius: 3px;
90+
}
91+
</style>
92+
</head>
93+
<body>
94+
$(render_markdown_to_html "$readme")
95+
</body>
96+
</html>
97+
EOF
98+
# temporarily write the list of HTML filenames to the main index.html
99+
echo "$lists<li><a href=\"$name/index.html\">$name</a></li>" >> index.html
100+
fi
101+
done
102+
103+
echo "<!DOCTYPE html><body><h1>Swift Algorithm</h1><ul>$(echo -n $(cat index.html))</ul></body></html>" > index.html
104+
105+
# push to gh-pages
106+
if [[ $CI = true ]]; then push_to_gh_pages "Generated by TravisCI on $(date +%D)"; fi

0 commit comments

Comments
 (0)