Skip to content

Commit a58364a

Browse files
geofffranksameowlia
authored andcommitted
Add script for starting docker locally to test
Signed-off-by: Amelia Downs <adowns@vmware.com>
1 parent 93de6ca commit a58364a

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

scripts/local-testing-helper.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
THIS_FILE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
CI="${THIS_FILE_DIR}/../../wg-app-platform-runtime-ci"
7+
. "$CI/shared/helpers/git-helpers.bash"
8+
REPO_NAME=$(git_get_remote_name)
9+
10+
function setup_docker {
11+
if [[ ${DB:-empty} == "empty" ]]; then
12+
DB=mysql
13+
fi
14+
15+
DB="${DB}" "${THIS_FILE_DIR}/create-docker-container.bash" -d
16+
17+
docker exec "${REPO_NAME}-docker-container" '/repo/scripts/docker/build-binaries.bash'
18+
}
19+
20+
function test_in_docker_locally {
21+
setup_docker
22+
docker exec "${REPO_NAME}-docker-container" '/repo/scripts/docker/tests-templates.bash'
23+
docker exec "${REPO_NAME}-docker-container" '/repo/scripts/docker/test.bash' "$@"
24+
docker exec "${REPO_NAME}-docker-container" '/repo/scripts/docker/lint.bash'
25+
}
26+
27+
function start_docker_for_testing {
28+
setup_docker
29+
docker exec -ti "${REPO_NAME}-docker-container" bash
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
THIS_FILE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
. "${THIS_FILE_DIR}/local-testing-helper.sh"
7+
8+
start_docker_for_testing

scripts/test-in-docker-locally.bash

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@
33
set -eu
44

55
THIS_FILE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6-
CI="${THIS_FILE_DIR}/../../wg-app-platform-runtime-ci"
7-
. "$CI/shared/helpers/git-helpers.bash"
8-
REPO_NAME=$(git_get_remote_name)
6+
. "${THIS_FILE_DIR}/local-testing-helper.sh"
97

10-
if [[ ${DB:-empty} == "empty" ]]; then
11-
DB=mysql
12-
fi
13-
14-
DB="${DB}" "${THIS_FILE_DIR}/create-docker-container.bash" -d
15-
16-
docker exec $REPO_NAME-docker-container '/repo/scripts/docker/build-binaries.bash'
17-
docker exec $REPO_NAME-docker-container '/repo/scripts/docker/tests-templates.bash'
18-
docker exec $REPO_NAME-docker-container '/repo/scripts/docker/test.bash' "$@"
19-
docker exec $REPO_NAME-docker-container '/repo/scripts/docker/lint.bash'
8+
test_in_docker_locally "$@"

0 commit comments

Comments
 (0)