Skip to content

Commit

Permalink
Compose test-with-docker with start-docker to reduce duplication
Browse files Browse the repository at this point in the history
- inline the contents of `checkdocker.sh`
  • Loading branch information
aramprice committed Mar 15, 2024
1 parent f945134 commit 5d34a01
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
7 changes: 0 additions & 7 deletions scripts/checkdocker.sh

This file was deleted.

10 changes: 6 additions & 4 deletions scripts/start-docker
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ set -euo pipefail
RELEASE_PATH="$(cd "$(dirname "$0")/.." && pwd)"
export RELEASE_PATH

. "${RELEASE_PATH}/scripts/checkdocker.sh"

if user_can_docker; then
# The Docker CLI does not need to be run as root in order to be safe in all
# cases. For example, when running on MacOS it is quarantined to a different
# virtual machine. If you are running daemon on a local machine then practice
# caution with sudo-less docker invocations.
if ! docker info 2>&1 | grep -q "permission denied"; then
DOCKER="docker"
else
# On development workstations docker must run as root.
Expand All @@ -19,4 +21,4 @@ $DOCKER run \
--privileged \
-v "${RELEASE_PATH}:/bpm" \
-it cfbpm/bpm-ci:latest \
/bin/bash
"${@:-/bin/bash}"
18 changes: 1 addition & 17 deletions scripts/test-with-docker
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,4 @@ set -euo pipefail
RELEASE_PATH="$(cd "$(dirname "$0")/.." && pwd)"
export RELEASE_PATH

. "${RELEASE_PATH}/scripts/checkdocker.sh"

if user_can_docker; then
DOCKER="docker"
else
# On development workstations docker must run as root.
# These settings are not related to the privileges that bpm creates runc containers with.
DOCKER="sudo docker"
fi

$DOCKER pull cfbpm/bpm-ci:latest

$DOCKER run \
--privileged \
-v "${RELEASE_PATH}:/bpm" \
-t cfbpm/bpm-ci:latest \
/bpm/scripts/test-unit "$@"
"${RELEASE_PATH}/scripts/start-docker" /bpm/scripts/test-unit

0 comments on commit 5d34a01

Please sign in to comment.