parallel travis tests

pull/5459/head
Medya Gh 2019-09-25 08:33:34 -07:00
parent 8e138a7eea
commit c97aa4dcc1
2 changed files with 42 additions and 29 deletions

View File

@ -1,8 +1,13 @@
language: go
os: linux
env:
- GOPROXY=https://proxy.golang.org
global:
- GOPROXY=https://proxy.golang.org
matrix:
- TESTSUITE_LINT=true
- TESTSUITE_BOILERPLATE=true
- TESTSUITE_UNIT=true
matrix:
include:
- go: 1.12.9

62
test.sh
View File

@ -15,41 +15,49 @@
# limitations under the License.
set -eu -o pipefail
# TODO: fix exit code numbers
# TODO: make test should work locally as it was before
exitcode=0
echo "= go mod ================================================================"
go mod download 2>&1 | grep -v "go: finding" || true
go mod tidy -v && echo ok || ((exitcode += 2))
echo "= make lint ============================================================="
make -s lint-ci && echo ok || ((exitcode += 4))
echo "= boilerplate ==========================================================="
readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python)
readonly BDIR="./hack/boilerplate"
missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR} | egrep -v '/assets.go|/translations.go|/site/themes/|/site/node_modules|\./out|/hugo/' || true)"
if [[ -n "${missing}" ]]; then
echo "boilerplate missing: $missing"
echo "consider running: ${BDIR}/fix.sh"
((exitcode += 4))
else
echo "ok"
if [ ! -z "$TESTSUITE_LINT"] then
echo "= make lint ============================================================="
make -s lint-ci && echo ok || ((exitcode += 4))
fi
echo "= schema_check =========================================================="
go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8))
echo "= go test ==============================================================="
cov_tmp="$(mktemp)"
readonly COVERAGE_PATH=./out/coverage.txt
echo "mode: count" >"${COVERAGE_PATH}"
pkgs=$(go list -f '{{ if .TestGoFiles }}{{.ImportPath}}{{end}}' ./cmd/... ./pkg/... | xargs)
go test \
-tags "container_image_ostree_stub containers_image_openpgp" \
-covermode=count \
-coverprofile="${cov_tmp}" \
${pkgs} && echo ok || ((exitcode += 16))
tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}"
if [ ! -z "$TESTSUITE_BOILERPLATE"] then
echo "= boilerplate ==========================================================="
readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python)
readonly BDIR="./hack/boilerplate"
missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR} | egrep -v '/assets.go|/translations.go|/site/themes/|/site/node_modules|\./out|/hugo/' || true)"
if [[ -n "${missing}" ]]; then
echo "boilerplate missing: $missing"
echo "consider running: ${BDIR}/fix.sh"
((exitcode += 4))
else
echo "ok"
fi
echo "= schema_check =========================================================="
go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8))
fi
if [ ! -z "$TESTSUITE_UNIT"] then
echo "= go test ==============================================================="
cov_tmp="$(mktemp)"
readonly COVERAGE_PATH=./out/coverage.txt
echo "mode: count" >"${COVERAGE_PATH}"
pkgs=$(go list -f '{{ if .TestGoFiles }}{{.ImportPath}}{{end}}' ./cmd/... ./pkg/... | xargs)
go test \
-tags "container_image_ostree_stub containers_image_openpgp" \
-covermode=count \
-coverprofile="${cov_tmp}" \
${pkgs} && echo ok || ((exitcode += 16))
tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}"
fi
exit "${exitcode}"