mirror of
https://github.com/jcwimer/docker-swarm-autoscaler
synced 2026-03-24 23:04:43 +00:00
36 lines
746 B
Bash
36 lines
746 B
Bash
#!/usr/bin/env bash
|
|
set -ex
|
|
|
|
function main {
|
|
build-image
|
|
run-ruby-tests
|
|
}
|
|
|
|
function cd-to-top-of-repo {
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
}
|
|
|
|
function build-image {
|
|
cd-to-top-of-repo
|
|
docker build -t docker-swarm-autoscaler-tests ./tests
|
|
}
|
|
|
|
function run-ruby-tests {
|
|
cd-to-top-of-repo
|
|
echo 'INFO: Running rspec unit tests...'
|
|
local -r container_id=$(
|
|
docker create --rm \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
docker-swarm-autoscaler-tests \
|
|
bash -c "cd /root/tests && \
|
|
bundle exec rake spec"
|
|
)
|
|
|
|
docker cp . "${container_id}:/root/"
|
|
|
|
trap "docker rm ${container_id}" SIGHUP
|
|
docker start --attach --interactive "${container_id}"
|
|
}
|
|
|
|
[[ "${0}" == "${BASH_SOURCE[0]}" ]] && main "${@}"
|