├── .travis.yml ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE.md ├── README.md ├── gitlab_ci ├── Dockerfile └── README.md └── test ├── index.html └── run.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: ruby 3 | services: 4 | - docker 5 | script: 6 | - ./test/run.sh 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Welcome! 2 | 3 | We're so glad you're thinking about contributing to an 18F open source project! If you're unsure about anything, just ask -- or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. We love all friendly contributions. 4 | 5 | We want to ensure a welcoming environment for all of our projects. Our staff follow the [18F Code of Conduct](https://github.com/18F/code-of-conduct/blob/master/code-of-conduct.md) and all contributors should do the same. 6 | 7 | We encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), and its [README](README.md). 8 | 9 | If you have any questions or want to read more, check out the [18F Open Source Policy GitHub repository]( https://github.com/18f/open-source-policy), or just [shoot us an email](mailto:18f@gsa.gov). 10 | 11 | ## Public domain 12 | 13 | This project is in the public domain within the United States, and 14 | copyright and related rights in the work worldwide are waived through 15 | the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/). 16 | 17 | All contributions to this project will be released under the CC0 18 | dedication. By submitting a pull request, you are agreeing to comply 19 | with this waiver of copyright interest. 20 | 21 | ## Development 22 | 23 | ```bash 24 | # install 25 | git clone https://github.com/18F/html-proofer-docker.git 26 | cd html-proofer-docker 27 | ./test/run.sh 28 | ``` 29 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.4-alpine 2 | 3 | RUN echo 'gem: --no-document' >> /etc/gemrc 4 | 5 | # needed at runtime 6 | RUN apk add --no-cache \ 7 | libcurl 8 | 9 | RUN apk add --no-cache --virtual build-dependencies \ 10 | build-base \ 11 | libxml2-dev \ 12 | libxslt-dev \ 13 | && gem install html-proofer \ 14 | && apk del build-dependencies 15 | 16 | ENTRYPOINT ["htmlproofer"] 17 | CMD ["--help"] 18 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | As a work of the United States Government, this project is in the 2 | public domain within the United States. 3 | 4 | Additionally, we waive copyright and related rights in the work 5 | worldwide through the CC0 1.0 Universal public domain dedication. 6 | 7 | ## CC0 1.0 Universal Summary 8 | 9 | This is a human-readable summary of the [Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode). 10 | 11 | ### No Copyright 12 | 13 | The person who associated a work with this deed has dedicated the work to 14 | the public domain by waiving all of his or her rights to the work worldwide 15 | under copyright law, including all related and neighboring rights, to the 16 | extent allowed by law. 17 | 18 | You can copy, modify, distribute and perform the work, even for commercial 19 | purposes, all without asking permission. 20 | 21 | ### Other Information 22 | 23 | In no way are the patent or trademark rights of any person affected by CC0, 24 | nor are the rights that other persons may have in the work or in how the 25 | work is used, such as publicity or privacy rights. 26 | 27 | Unless expressly stated otherwise, the person who associated a work with 28 | this deed makes no warranties about the work, and disclaims liability for 29 | all uses of the work, to the fullest extent permitted by applicable law. 30 | When using or citing the work, you should not imply endorsement by the 31 | author or the affirmer. 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HTML Proofer, Dockerized [![Build Status](https://travis-ci.org/18F/html-proofer-docker.svg?branch=master)](https://travis-ci.org/18F/html-proofer-docker) 2 | 3 | HTML validation, made easy. This repository is the [HTML Proofer](https://github.com/gjtorikian/html-proofer) Ruby gem wrapped up in a Docker container, so you don't have to fuss with installing things like [Ruby](https://www.ruby-lang.org/) or [Nokogiri](http://www.nokogiri.org/). 4 | 5 | ## Usage 6 | 7 | Requires [Docker](https://www.docker.com/). 8 | 9 | ```bash 10 | docker run 18fgsa/html-proofer 11 | ``` 12 | 13 | This will print out the usage instructions. Arguments for [the `htmlproofer` CLI](https://github.com/gjtorikian/html-proofer#using-on-the-command-line) can then be appended to the command. Note that **it's not (yet) recommended this be used against live sites** due to [this issue](https://github.com/gjtorikian/html-proofer/issues/334). 14 | 15 | ### Directory of files 16 | 17 | e.g. those created by a static site builder like [Jekyll](http://jekyllrb.com/) or [Hugo](https://gohugo.io/). You will need to [mount the directory as a data volume](https://docs.docker.com/storage/volumes/#start-a-container-with-a-volume) so it's available in the container, like so: 18 | 19 | ```bash 20 | docker run -v /absolute/path/to/site/:/mounted-site 18fgsa/html-proofer /mounted-site 21 | ``` 22 | 23 | ### Single file 24 | 25 | You can also mount a single file, like so: 26 | 27 | ```bash 28 | docker run -v /absolute/path/to/file.html:/mounted-file.html 18fgsa/html-proofer /mounted-file.html 29 | ``` 30 | 31 | ### GitLab CI 32 | 33 | You can use this image in GitLab CI, just configure job in `.gitlab-ci.yml` like this: 34 | 35 | ```yaml 36 | test: 37 | image: 18fgsa/html-proofer:gitlab-ci 38 | script: 39 | - htmlproofer _site --empty-alt-ignore 40 | ``` 41 | -------------------------------------------------------------------------------- /gitlab_ci/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM 18fgsa/html-proofer 2 | 3 | ENTRYPOINT [] 4 | CMD [] 5 | -------------------------------------------------------------------------------- /gitlab_ci/README.md: -------------------------------------------------------------------------------- 1 | This directory is a workaround for [GitLab CI](https://about.gitlab.com/gitlab-ci/) [not supporting "non-shell `ENTRYPOINT`s"](https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/1421). The GitLab CI-specific Dockerfile needs to be in a different directory than the canonical one due to [a limitation of Docker Hub](https://github.com/docker/hub-feedback/issues/292). 2 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | docker build -t html-proofer . 6 | 7 | echo ------------- 8 | 9 | # intercept output while still printing the output 10 | # http://stackoverflow.com/a/12451419/358804 11 | exec 5>&1 12 | # expect failure 13 | OUTPUT=$((! docker run -v "$(pwd)/test/index.html:/index.html" html-proofer /index.html) 2>&1 | tee >(cat - >&5)) 14 | 15 | echo ------------- 16 | 17 | if echo $OUTPUT | grep -q '1 file'; then 18 | echo "PASS: Found the test file." 19 | else 20 | echo "FAIL: Didn't find the test file." 21 | exit 1 22 | fi 23 | 24 | if echo $OUTPUT | grep -q '#unknown'; then 25 | echo "PASS: Found the broken link." 26 | else 27 | echo "FAIL: Didn't find the broken link." 28 | exit 1 29 | fi 30 | --------------------------------------------------------------------------------