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
2 changes: 2 additions & 0 deletions website/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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

@pip install linkchecker

serve:
@hugo server --watch
Expand Down
14 changes: 14 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Running the Heron documentation locally requires that you have the following ins
* [Make](https://www.gnu.org/software/make/)
* [Node.js](https://nodejs.org/en/)
* [npm](https://www.npmjs.com/)
* [pip](https://pypi.python.org/pypi/pip)

### OS X Setup

Expand Down Expand Up @@ -74,6 +75,19 @@ 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 due to this [https://github.com/wummel/linkchecker/pull/657](issue), `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
22 changes: 17 additions & 5 deletions website/linkchecker.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#! bin/bash
#!/bin/bash

set -e

function die {
echo $1 && exit 1
}

#linkchecker removes previous runs.
pip install linkchecker
which linkchecker || die 'Linkchecker must be installed to run this script. Exiting'
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