diff --git a/.travis.yml b/.travis.yml index 53d954071..be166146d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,59 +3,10 @@ language: go sudo: false install: - - export GOPATH_FIRST="${GOPATH%%:*}" - - > - git clone \ - --depth 1 \ - https://github.com/tianon/markdownfmt.git \ - "$GOPATH_FIRST/src/github.com/shurcooL/markdownfmt" - - export BLACKFRIDAY_VERSION="$(awk '$1 == "ENV" && $2 == "BLACKFRIDAY_VERSION" { print $3; exit }' "$GOPATH_FIRST/src/github.com/shurcooL/markdownfmt/Dockerfile")" - - > - git clone \ - --depth 1 \ - -b "$BLACKFRIDAY_VERSION" \ - https://github.com/russross/blackfriday.git \ - "$GOPATH_FIRST/src/github.com/russross/blackfriday" - - go get -v github.com/shurcooL/markdownfmt + - .travis/get-markdownfmt.sh script: - - files="$(find -name '*.md' -print0 | xargs -0 markdownfmt -l)"; - if [ "$files" ]; then - echo >&2 'Need markdownfmt:'; - echo >&2 "$files"; - echo >&2; - echo "$files" | xargs markdownfmt -d >&2; - exit 1; - fi - - failed=''; - for short in */README-short.txt; do - chars="$(echo -n "$(cat "$short")" | wc -m)"; - lines="$(cat "$short" | wc -l)"; - if [ "$chars" -gt 100 -o "$lines" -gt 1 ]; then - failed+=" $short"; - fi - done; - if [ "$failed" ]; then - echo >&2 "Too long (or too many lines):$failed"; - exit 1; - fi - - failed=''; - for repo in */; do - if [ ! -e "$repo/github-repo" ]; then - failed+=" $repo"; - fi - done; - if [ "$failed" ]; then - echo >&2 "Missing github-repo for:$failed"; - exit 1; - fi - - if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then - if [ "$(git diff --numstat "$TRAVIS_COMMIT_RANGE" -- '*/README.md')" ]; then - echo >&2 'Error:'' at least one repo README.md has changed'; - echo >&2 'These files are autogenerated, so it is unnecessary to modify them'; - echo >&2 'Please update content.md and docker-library-bot will take care of README.md'; - echo >&2 'See:'' https://github.com/docker-library/docs/#image-namereadmemd'; - echo >&2; - exit 1; - fi - fi + - .travis/check-markdownfmt.sh + - .travis/check-short.sh + - .travis/check-required-files.sh + - .travis/check-pr-no-readme.sh diff --git a/.travis/check-markdownfmt.sh b/.travis/check-markdownfmt.sh new file mode 100755 index 000000000..ef5f6b10b --- /dev/null +++ b/.travis/check-markdownfmt.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.." + +files="$(find -name '*.md' -print0 | xargs -0 markdownfmt -l)" +if [ "$files" ]; then + echo >&2 'Need markdownfmt:' + echo >&2 "$files" + echo >&2 + echo "$files" | xargs markdownfmt -d >&2 + exit 1 +fi diff --git a/.travis/check-pr-no-readme.sh b/.travis/check-pr-no-readme.sh new file mode 100755 index 000000000..645e6e2c2 --- /dev/null +++ b/.travis/check-pr-no-readme.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.." + +if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then + if [ "$(git diff --numstat "$TRAVIS_COMMIT_RANGE" -- '*/README.md')" ]; then + echo >&2 'Error: at least one repo README.md has changed' + echo >&2 'These files are autogenerated, so it is unnecessary to modify them' + echo >&2 'Please update content.md and docker-library-bot will take care of README.md' + echo >&2 'See: https://github.com/docker-library/docs/#image-namereadmemd' + echo >&2 + exit 1 + fi +fi diff --git a/.travis/check-required-files.sh b/.travis/check-required-files.sh new file mode 100755 index 000000000..5bba09231 --- /dev/null +++ b/.travis/check-required-files.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.." + +exitCode=0 +for requiredFile in \ + content.md \ + github-repo \ +; do + failed='' + for repo in */; do + case "${repo%/}" in + scratch) continue ;; + esac + if [ ! -e "$repo/$requiredFile" ]; then + failed+=" $repo" + fi + done + if [ "$failed" ]; then + echo >&2 "Missing $requiredFile for:$failed" + exitCode=1 + fi +done +exit "$exitCode" diff --git a/.travis/check-short.sh b/.travis/check-short.sh new file mode 100755 index 000000000..e82460529 --- /dev/null +++ b/.travis/check-short.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.." + +failed='' +for short in */README-short.txt; do + chars="$(echo -n "$(cat "$short")" | wc -m)" + lines="$(cat "$short" | wc -l)" + if [ "$chars" -gt 100 -o "$lines" -gt 1 ]; then + failed+=" $short" + fi +done + +if [ "$failed" ]; then + echo >&2 "Too long (or too many lines):$failed" + exit 1 +fi diff --git a/.travis/get-markdownfmt.sh b/.travis/get-markdownfmt.sh new file mode 100755 index 000000000..a42f2beb6 --- /dev/null +++ b/.travis/get-markdownfmt.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +set -x +[ -n "$GOPATH" ] +export GOPATH_FIRST="${GOPATH%%:*}" +git clone \ + --depth 1 \ + https://github.com/tianon/markdownfmt.git \ + "$GOPATH_FIRST/src/github.com/shurcooL/markdownfmt" +export BLACKFRIDAY_VERSION="$(awk '$1 == "ENV" && $2 == "BLACKFRIDAY_VERSION" { print $3; exit }' "$GOPATH_FIRST/src/github.com/shurcooL/markdownfmt/Dockerfile")" +git clone \ + --depth 1 \ + -b "$BLACKFRIDAY_VERSION" \ + https://github.com/russross/blackfriday.git \ + "$GOPATH_FIRST/src/github.com/russross/blackfriday" +go get -v github.com/shurcooL/markdownfmt