Skip to content

Commit

Permalink
Fix CI pipeline (#180)
Browse files Browse the repository at this point in the history
* Upgrade codeclimate test reporter

* Bump docker

* Skip flaky test

* revert

* Update to go1.17

* Add dns and lookups

* Remove debug statements

* Move docker build up

* Update test.sh to fail

* run http test

* clean up test.sh

Co-authored-by: Dylan Hitt <[email protected]>
  • Loading branch information
SimonBaeumer and dylanhitt authored Feb 25, 2022
1 parent 2be2330 commit b067197
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
5 changes: 3 additions & 2 deletions integration/containers/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM golang:1.15
FROM golang:1.17

RUN mkdir -p $GOPATH/github.com/commander/commander-cli

# For some reason circleci will not mount the dir?
COPY . $GOPATH/github.com/commander/commander-cli/
WORKDIR $GOPATH/github.com/commander/commander-cli/

RUN curl https://s3.amazonaws.com/codeclimate/test-reporter/test-reporter-0.6.3-linux-amd64 --output test-reporter
RUN curl https://s3.amazonaws.com/codeclimate/test-reporter/test-reporter-0.10.1-linux-amd64 --output test-reporter
RUN chmod +x test-reporter

RUN curl -L https://github.com/commander-cli/commander/releases/download/v2.4.0/commander-linux-amd64 --output /usr/bin/commander
Expand Down
65 changes: 47 additions & 18 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -eo pipefail
set -exo pipefail

# Usage: ./test.sh <make target>
# Execute a makefile target inside a Docker environment
Expand All @@ -9,23 +9,47 @@ if [[ -n "$1" ]]; then
MAKE_TARGET="$1"
fi

docker stop commander-int-ssh-server || true
docker rm commander-int-ssh-server || true
docker stop commander-integration-go-test || true
docker rm commander-integration-go-test || true
docker network rm commander_test || true
NO_CLEANUP=0
if [[ "$2" == "--no-cleanup" ]]; then
NO_CLEANUP=1
fi

docker build -t commander-int-ssh-server -f integration/containers/ssh/Dockerfile .
docker network create --driver=bridge --subnet=172.28.0.0/16 commander_test
cleanup() {
echo "Starting cleanup"
container_name="$1"
docker stop commander-int-ssh-server || true
docker rm commander-int-ssh-server || true
docker network rm commander_test
}

docker run -d \
--rm \
--ip=172.28.0.2 \
--network commander_test \
--name commander-int-ssh-server \
commander-int-ssh-server
start_ssh_conatiner() {
local ssh_container_name="commander-int-ssh-server"
if [[ ! $(docker ps | grep $ssh_container_name) ]]; then
echo "Starting SSH server"
docker run -d \
--rm \
--ip=172.28.0.2 \
--network commander_test \
--name "$ssh_container_name" \
"$ssh_container_name"
fi
}

if [[ ! "$(docker ps -a | grep -w commander-int-test)" ]]; then
docker build -t commander-int-test -f integration/containers/test/Dockerfile .
fi

if [[ ! "$(docker ps -a | grep commander-int-ssh-server)" ]]; then
docker build -t commander-int-ssh-server -f integration/containers/ssh/Dockerfile .
fi

docker build -t commander-int-test -f integration/containers/test/Dockerfile .
if [[ ! "$(docker network ls | grep commander_test)" ]]; then
docker network create --driver=bridge --subnet=172.28.0.0/16 commander_test
fi

start_ssh_conatiner

echo "Starting tests"
docker run \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
Expand All @@ -35,6 +59,11 @@ docker run \
commander-int-test \
make "$MAKE_TARGET"

docker stop commander-int-ssh-server || true
docker rm commander-int-ssh-server || true
docker network rm commander_test || true
status_code="$?"

if [[ "$NO_CLEANUP" -eq "0" ]]; then
cleanup
fi

exit $status_code

0 comments on commit b067197

Please sign in to comment.