forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_common
executable file
·51 lines (40 loc) · 1.51 KB
/
_common
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
export LOCAL_IMAGE="dependabot/updater:latest"
export GPR_IMAGE="docker.pkg.github.com/dependabot/dependabot-updater/dependabot-updater"
function docker_build() {
[[ -n "$SKIP_BUILD" ]] && return
extract_version
docker build $DOCKER_BUILD_ARGS -f Dockerfile.updater -t "$LOCAL_IMAGE" --build-arg OMNIBUS_VERSION=$OMNIBUS_VERSION .
# Verify max layers; an AUFS limit that was _crucial_ on Heroku (but not now)
IMAGE_LAYERS=$(docker history -q "$LOCAL_IMAGE" | wc -l | sed -e 's/ //g')
echo "$LOCAL_IMAGE contains $IMAGE_LAYERS layers"
[[ $IMAGE_LAYERS -lt 126 ]]
}
function docker_exec() {
docker_build
docker run --env "DEPENDABOT_TEST_ACCESS_TOKEN=$DEPENDABOT_TEST_ACCESS_TOKEN" \
--rm \
-v "$(pwd)/.:/home/dependabot/dependabot-updater:delegated" \
-ti "$LOCAL_IMAGE" "$@"
}
function docker_bundle_exec() {
docker_build
VCR_ARGS=""
if [ -n "$VCR" ]; then
VCR_ARGS="--env \"VCR=$VCR\""
fi
docker run --env "DEPENDABOT_TEST_ACCESS_TOKEN=$DEPENDABOT_TEST_ACCESS_TOKEN" \
$VCR_ARGS \
--rm \
-v "$(pwd)/updater/spec/fixtures/vcr_cassettes:/home/dependabot/dependabot-updater/spec/fixtures/vcr_cassettes" \
"$LOCAL_IMAGE" bundle exec "$@"
}
function extract_version() {
if [ -z "$OMNIBUS_VERSION" ]; then
OMNIBUS_VERSION="$(grep 'dependabot-omnibus ([0-9]' Gemfile.lock | sed -e 's/^[ ]*//g' | sort | uniq | sed -e 's/.*(//g' -e 's/).*//g')"
export OMNIBUS_VERSION
VERSION="$OMNIBUS_VERSION-$(git rev-parse HEAD)"
else
VERSION=$OMNIBUS_VERSION
fi
export VERSION
}