Skip to content

Commit

Permalink
Use docker.sh on the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
worxli committed Oct 19, 2018
1 parent 5194040 commit 04e4e0f
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 57 deletions.
13 changes: 8 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
command: ./tools/ci/docker_update
- run:
name: Pull and tag scion_base image
command: ./tools/ci/prepare_image 3e44fd367a50d6d46fc9208850fe0a2149c98fc0b54b5c77d94e9b6994783070
command: ./tools/ci/prepare_image 89ee7e0b01200680f8620439bba7df9b8e825a04b57258c5ee6758a274443430
when: always
- run:
name: Build scion:latest image
Expand All @@ -38,7 +38,10 @@ jobs:
# Build and run tests:
- run:
name: Create and start container
command: ./tools/ci/setup_container
command: |
set +e -x
mkdir -p "/tmp/artifacts"
SCION_MOUNT="/tmp/artifacts" ./docker.sh start
when: always
- run:
name: Build
Expand Down Expand Up @@ -71,9 +74,9 @@ jobs:
BUILD=$(date +%s)
[ -n "$CIRCLE_BUILD_NUM" ] && BUILD="build${CIRCLE_BUILD_NUM}"
ARTIFACTS="circleci.${CIRCLE_PROJECT_USERNAME}.${CIRCLE_PROJECT_REPONAME}.${TARGET}.${BUILD}"
mkdir -p "/tmp/artifacts/$ARTIFACTS" "/tmp/artifacts.out"
./tools/ci/clean_up /tmp/artifacts/$ARTIFACTS
tar caf "/tmp/artifacts.out/$ARTIFACTS.tar.gz" -C /tmp/artifacts "$ARTIFACTS"
mkdir -p "/tmp/artifacts.out"
tar caf "/tmp/artifacts.out/$ARTIFACTS.tar.gz" -C /tmp artifacts
./docker.sh stop
when: always
- store_artifacts:
path: /tmp/artifacts.out
Expand Down
5 changes: 3 additions & 2 deletions docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ cmd_run() {
SCION_MOUNT=${SCION_MOUNT:-$(mktemp -d /tmp/scion_out.XXXXXX)}
echo "SCION_MOUNT directory: $SCION_MOUNT"
local args=$(common_args)
args+=" -i -t --rm"
args+=" -i -t --rm --entrypoint=/docker-entrypoint.sh"
setup_volumes
docker run $args scion "$@"
}
Expand All @@ -120,6 +120,7 @@ cmd_start() {
setup_volumes
docker container create $args scion -c "tail -f /dev/null"
docker start "$cntr"
docker exec scion /docker-entrypoint.sh
}

cmd_exec() {
Expand All @@ -134,7 +135,7 @@ cmd_stop() {

setup_volumes() {
set -e
for i in gen logs gen-certs gen-cache; do
for i in gen logs gen-certs gen-cache htmlcov; do
mkdir -p "$SCION_MOUNT/$i"
# Check dir exists, and is owned by the current (effective) user. If
# it's owned by the wrong user, the docker environment won't be able to
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ RUN sudo chown -R scion: $HOME
COPY docker/docker-entrypoint.sh /

CMD []
ENTRYPOINT ["/docker-entrypoint.sh"]
ENTRYPOINT ["/bin/bash", "-l"]
2 changes: 1 addition & 1 deletion tools/ci/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

docker container exec ${1:-scion_ci} bash -c "set -eo pipefail; make -s |& tee logs/make.run"
./docker.sh exec "set -eo pipefail; make -s |& tee logs/make.run"
7 changes: 0 additions & 7 deletions tools/ci/clean_up

This file was deleted.

17 changes: 3 additions & 14 deletions tools/ci/integration
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,12 @@
. tools/ci/common.sh
set -eo pipefail

cntr="${1:-scion_ci}"

docker container exec $cntr bash -c "set -x; ./scion.sh topology ${DOCKER:+-d}"
./docker.sh exec "set -x; ./scion.sh topology ${DOCKER:+-d}"

if [ -n "$DOCKER" ]; then
# Make sure stale configs/state on the host are removed.
for i in gen gen-certs; do
[ -e "$i" ] && rm -r "$i"
done
rm -f ./logs/* ./gen-cache/*
mkdir -p gen-cache
# Copy out new topology
docker cp "$cntr:/home/scion/go/src/github.com/scionproto/scion/gen" .
docker cp "$cntr:/home/scion/go/src/github.com/scionproto/scion/gen-certs" .
# Run tests from host.
./integration/integration_test.sh -d "$cntr" |& tee logs/integration.run
./docker.sh exec "set -eo pipefail; ./integration/integration_test.sh |& tee logs/integration.run"
else
# Run tests inside the CI container.
docker container exec "$cntr" bash -c "set -eo pipefail; sudo service zookeeper start; ./integration/integration_test.sh |& tee logs/integration.run"
./docker.sh exec "set -eo pipefail; sudo service zookeeper start; ./integration/integration_test.sh |& tee logs/integration.run"
fi
2 changes: 1 addition & 1 deletion tools/ci/lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

docker container exec ${1:-scion_ci} bash -c "set -eo pipefail; ./scion.sh lint |& tee logs/lint.run"
./docker.sh exec "set -eo pipefail; ./scion.sh lint |& tee logs/lint.run"
24 changes: 12 additions & 12 deletions tools/ci/local
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

. tools/ci/common.sh

cntr="${1:-scion_ci}"
# Hardcoded in docker.sh
cntr="scion"

if [ -n "$DOCKER" ]; then
args="-d $cntr"
# Stop a local scion run because we don't want to interfere
./scion.sh stop
echo "Stop local zookeeper"
Expand All @@ -15,27 +15,27 @@ fi
./docker.sh build || exit 1
[ -n "$DOCKER" ] && { make -sC docker/perapp || exit 1; }

docker inspect "$cntr" &>/dev/null && { echo "Removing stale container"; docker rm -f "$cntr"; }
./tools/ci/setup_container $args || exit 1
docker container inspect "$cntr" &>/dev/null && { echo "Removing stale container"; docker rm -f "$cntr"; }

tmpdir=$(mktemp -d /tmp/artifacts.XXXXXXX)
SCION_MOUNT="$tmpdir" ./docker.sh start || exit 1

result=0
./tools/ci/build "$cntr"
./tools/ci/build
result=$((result+$?))
./tools/ci/lint "$cntr"
./tools/ci/lint
result=$((result+$?))
./tools/ci/unittest "$cntr"
./tools/ci/unittest
result=$((result+$?))
./tools/ci/sphinx "$cntr"
./tools/ci/sphinx
result=$((result+$?))

./tools/ci/integration $args "$cntr"
./tools/ci/integration
result=$((result+$?))

tmpdir=$(mktemp -d /tmp/artifacts.XXXXXXX)
./tools/ci/clean_up "$tmpdir" "$cntr" || exit 1
echo "Artifacts dir: $tmpdir"

[ $result -eq 0 ] && docker rm -f "$cntr"
[ $result -eq 0 ] && ./docker.sh stop
./scion.sh stop

if [ $result -eq 0 ]; then
Expand Down
12 changes: 0 additions & 12 deletions tools/ci/setup_container

This file was deleted.

2 changes: 1 addition & 1 deletion tools/ci/sphinx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

docker container exec ${1:-scion_ci} bash -lc "set -eo pipefail; make -f sphinx-doc/Makefile clean html |& tee logs/sphinx.run"
./docker.sh exec "set -eo pipefail; make -f sphinx-doc/Makefile clean html |& tee logs/sphinx.run"
2 changes: 1 addition & 1 deletion tools/ci/unittest
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

docker container exec ${1:-scion_ci} bash -c "set -eo pipefail; ./scion.sh test |& tee logs/unittests.run"
./docker.sh exec "set -eo pipefail; ./scion.sh test |& tee logs/unittests.run"

0 comments on commit 04e4e0f

Please sign in to comment.