Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Travis CI to test that website links are valid #709

Merged
merged 16 commits into from
May 20, 2016
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ before_install:
- chmod +x bazel-0.1.2-installer-linux-x86_64.sh
- ./bazel-0.1.2-installer-linux-x86_64.sh --user

before_script:
# required for building the website docs
- (cd website && npm install && npm install gulp && which gulp)
- wget -q https://github.com/spf13/hugo/releases/download/v0.15/hugo_0.15_amd64.deb
- sudo dpkg -i hugo*.deb
- hugo version
- pip install --user requests==2.9.0
- pip install --user LinkChecker
- linkchecker --version

script:
- which gcc-4.8
- gcc --version
- which g++-4.8
- g++ --version
- scripts/travis/build.sh && scripts/travis/test.sh
- g++ --version
# TODO: change below from || to && once all links are fixed so we fail build on bad ones
- (cd website && make site) || scripts/travis/build.sh && scripts/travis/test.sh
1 change: 1 addition & 0 deletions website/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
setup:
@brew list hugo || brew install hugo
@npm install
@which gulp || npm install gulp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned below, I'd like to see linkchecker installed here


serve:
@hugo server --watch
Expand Down
12 changes: 12 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ browser from the command line:
$ open http://localhost:1313/heron
```

## Checking Links

To verify that the links in the docs are all valid, run `make linkchecker`, which will produce a
report of broken links. If `linkchecker` fails to install or run properly, you can install it manually.
Note that `linkchecker` versions 9.2 and 9.3 require the python `requests` >= 2.2.0 and < 2.10.0.

```bash
$ pip uninstall requests
$ pip install requests==2.9.0
$ pip install linkchecker
```

## Publishing the Site

The content on the [twitter.github.io/heron](http://twitter.github.io/heron) website is what is
Expand Down
18 changes: 13 additions & 5 deletions website/linkchecker.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#! bin/bash
#!/bin/bash

set -e

#linkchecker removes previous runs.
pip install linkchecker
which linkchecker || pip install linkchecker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest moving this into the Makefile so that make setup covers this. I think that's a bit cleaner.

rm -f linkchecker-errors.csv && rm -f linkchecker-out.csv
linkchecker public/index.html --no-warnings -F csv

set +e
linkchecker public/index.html --no-warnings -F csv
STATUS=$?
set -e

#uses error code: on fail, write linkchecker-errors.csv for debugging
if [[ $? == 1 ]]; then
if [[ $STATUS != 0 ]]; then
cut -sd ';' -f 1,2 linkchecker-out.csv | tr ';' ' ' | \
awk '{ print $2 " " $1}' | sort -u >> linkchecker-errors.csv;
echo "linkchecker failed - check linkchecker-errors.csv";
echo "linkchecker failed - check linkchecker-errors.csv";
exit $STATUS
else
echo "linkchecker passes";
fi
Expand Down