Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemtests now run completely in containers #46

Merged
merged 2 commits into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ build: checks
checks:
@bash ./scripts/checks.sh

# ci does everything necessary for a Github PR-triggered CI run
ci: checks test
# ci does everything necessary for a Github PR-triggered CI run.
# currently, this means building a container image and running
# all of the available tests. (systemtests require a container)
ci: build test

# generate-certificate generates a local key and cert for running the proxy.
# if an existing certificate and key exist, it will do nothing.
Expand All @@ -35,8 +37,7 @@ run: build generate-certificate

# systemtests runs the system tests suite.
systemtests:
go get gopkg.in/check.v1
go test -v -timeout 5m ./systemtests -check.v
@bash ./scripts/systemtests.sh

# unittests runs all the unit tests
unit-tests:
Expand Down
18 changes: 18 additions & 0 deletions build/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:16.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y upgrade && \
apt-get -y install curl build-essential docker.io

RUN curl -O https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will having this local save us some CI headaches?

Copy link
Contributor Author

@dseevr dseevr Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking that we put it into the repo itself? This will permanently increase the size of the repo by ~70mb for each version we upgrade to, and Github will start yelling at us and telling us to use their Large File Storage service 🙃

Also because we COPY the whole repo into our build container, it'll slow down almost every Docker-related operation we do here... 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points :) Ignore the suggestion. I wish we could build and push this to docker hub once and reuse it, though docker pull has its reliability issues too.

RUN tar -C /usr/local -xzf go1.7.4.linux-amd64.tar.gz && rm go1.7.4.linux-amd64.tar.gz

ENV PATH="/usr/local/go/bin:$PATH"
ENV GOPATH="/go"

RUN mkdir -p /go/src/github.com/contiv/ccn_proxy

WORKDIR /go/src/github.com/contiv/ccn_proxy

ENTRYPOINT ["/bin/bash"]
15 changes: 1 addition & 14 deletions build/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
FROM ubuntu:16.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y upgrade && \
apt-get -y install curl build-essential docker.io

RUN curl -O https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf go1.7.4.linux-amd64.tar.gz && rm go1.7.4.linux-amd64.tar.gz

ENV PATH="/usr/local/go/bin:$PATH"
ENV GOPATH="/go"
FROM ccn_proxy_build_base

COPY ./ /go/src/github.com/contiv/ccn_proxy

WORKDIR /go/src/github.com/contiv/ccn_proxy

RUN scripts/build-in-container.sh

ENTRYPOINT ["docker", "build"]
9 changes: 9 additions & 0 deletions build/Dockerfile.checks
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ccn_proxy_build_base

RUN go get github.com/gordonklaus/ineffassign
RUN go get github.com/golang/lint/golint
RUN go get github.com/fzipp/gocyclo
RUN go get github.com/client9/misspell/...
RUN go get github.com/remyoudompheng/go-misc/deadcode/...

ENTRYPOINT ["/bin/bash", "./scripts/checks_in_container.sh"]
9 changes: 9 additions & 0 deletions build/Dockerfile.systemtests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ccn_proxy_build_base

# go-check must be installed to run systemtests
RUN go get gopkg.in/check.v1

COPY ./ /go/src/github.com/contiv/ccn_proxy

ENTRYPOINT ["/bin/bash"]
#, "./scripts/systemtests_in_container.sh"]
3 changes: 3 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ fi

cd $START_DIR

# ensure base has been built
docker build -t "ccn_proxy_build_base" -f ./build/Dockerfile.base .

# create a local build image
docker build -t $BUILD_IMAGE_NAME -f ./build/Dockerfile.build .

Expand Down
91 changes: 10 additions & 81 deletions scripts/checks.sh
Original file line number Diff line number Diff line change
@@ -1,85 +1,14 @@
#!/bin/sh
#!/bin/bash

set -e
set -euo pipefail

dirs=$(go list ./... | sed -e 's!github.com/contiv/ccn_proxy!.!g' | grep -v ./vendor)
files=$(find . -type f -name '*.go' | grep -v ./vendor)
CHECKS_CONTAINER_NAME="ccn_proxy_checks"

echo "Running gofmt..."
set +e
out=$(gofmt -s -l ${files})
set -e
# gofmt can include empty lines in its output
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gofmt errors in:"
echo 1>&2 "${out}"
exit 1
fi
docker build -t "ccn_proxy_build_base" -f ./build/Dockerfile.base .
docker build -t $CHECKS_CONTAINER_NAME -f ./build/Dockerfile.checks .

echo "Running ineffassign..."
[ -n "`which ineffassign`" ] || go get github.com/gordonklaus/ineffassign
for i in ${dirs}
do
ineffassign $i
done

echo "Running golint..."
[ -n "`which golint`" ] || go get github.com/golang/lint/golint
set +e
out=$(golint ./... | grep -vE '^vendor')
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "golint errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running govet..."
set +e
out=$(go tool vet -composites=false ${dirs} 2>&1 | grep -v vendor)
set -e

if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "go vet errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running gocyclo..."
[ -n "`which gocyclo`" ] || go get github.com/fzipp/gocyclo
set +e
out=$(gocyclo -over 15 . | grep -v vendor)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gocycle errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running misspell..."
[ -n "`which misspell`" ] || go get github.com/client9/misspell/...
set +e
out=$(misspell -locale US -error -i exportfs ${files})
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "misspell errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running deadcode..."
[ -n "`which deadcode`" ] || go get github.com/remyoudompheng/go-misc/deadcode/...
set +e
out=$(deadcode ${dirs} 2>&1)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "deadcode errors in:"
echo 1>&2 "${out}"
exit 1
fi
# the ccn_proxy directory exists in the base image, but it's empty so we'll
# bindmount the current directory into it.
docker run --rm \
-v $(pwd):/go/src/github.com/contiv/ccn_proxy:ro \
$CHECKS_CONTAINER_NAME
82 changes: 82 additions & 0 deletions scripts/checks_in_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

set -e

export PATH="/go/bin:$PATH"

dirs=$(go list ./... | sed -e 's!github.com/contiv/ccn_proxy!.!g' | grep -v ./vendor)
files=$(find . -type f -name '*.go' | grep -v ./vendor)

echo "Running gofmt..."
set +e
out=$(gofmt -s -l ${files})
set -e
# gofmt can include empty lines in its output
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gofmt errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running ineffassign..."
for i in ${dirs}
do
ineffassign $i
done

echo "Running golint..."
set +e
out=$(golint ./... | grep -vE '^vendor')
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "golint errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running govet..."
set +e
out=$(go tool vet -composites=false ${dirs} 2>&1 | grep -v vendor)
set -e

if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "go vet errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running gocyclo..."
set +e
out=$(gocyclo -over 15 . | grep -v vendor)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "gocyclo errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running misspell..."
set +e
out=$(misspell -locale US -error -i exportfs ${files})
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "misspell errors in:"
echo 1>&2 "${out}"
exit 1
fi

echo "Running deadcode..."
set +e
out=$(deadcode ${dirs} 2>&1)
set -e
if [ "`echo \"${out}\" | sed '/^$/d' | wc -l`" -gt 0 ]
then
echo 1>&2 "deadcode errors in:"
echo 1>&2 "${out}"
exit 1
fi
Empty file modified scripts/generate-certificate.sh
100644 → 100755
Empty file.
30 changes: 0 additions & 30 deletions scripts/run.sh

This file was deleted.

Loading