소스 검색

Merge pull request #887 from infosiftr/travis-refactor

Refactor Travis to use a series of short scripts so that the output is cleaner (and easier to manage / test locally)
Tianon Gravi 8 년 전
부모
커밋
3cce78c36c
6개의 변경된 파일93개의 추가작업 그리고 54개의 파일을 삭제
  1. 5 54
      .travis.yml
  2. 13 0
      .travis/check-markdownfmt.sh
  3. 15 0
      .travis/check-pr-no-readme.sh
  4. 25 0
      .travis/check-required-files.sh
  5. 18 0
      .travis/check-short.sh
  6. 17 0
      .travis/get-markdownfmt.sh

+ 5 - 54
.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

+ 13 - 0
.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

+ 15 - 0
.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

+ 25 - 0
.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"

+ 18 - 0
.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

+ 17 - 0
.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