dependabot-core / bin /docker-dev-shell
AbdulElahGwaith's picture
Upload folder using huggingface_hub
e98c0d7 verified
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
source script/_common
HELP=false
REBUILD=false
# Enable docker buildkit with inline cache builds
export DOCKER_BUILDKIT=1
# shellcheck disable=SC2034
OPTS=$(getopt -o hr --long help,rebuild -n 'parse-options' -- "$@")
# shellcheck disable=SC2181
if [ $? != 0 ]; then
echo "failed parsing options" >&2
exit 1
fi
if [[ -z "$1" ]]; then
HELP=true
fi
# Technically every ecosystem results in building a per-ecosystem updater image.
# But currently running the `updater` unit tests requires the `bundler` ecosystem image.
if [ "$1" == "updater" ]; then
ECOSYSTEM="bundler"
else
ECOSYSTEM="$1"
fi
while true; do
case "$2" in
-h | --help ) HELP=true; shift ;;
-r | --rebuild ) REBUILD=true; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
IMAGE_NAME="dependabot/dependabot-core-development-$ECOSYSTEM"
CONTAINER_NAME="dependabot-core-development-$ECOSYSTEM"
DOCKERFILE="Dockerfile.development"
if [ "$HELP" = "true" ]; then
echo "usage: $0 <ecosystem> [--rebuild] [ARGS]"
exit 0
fi
build_image() {
export BUILT_IMAGE=true
echo "$(tput setaf 2)=> building image from Dockerfile$(tput sgr0)"
DEPENDABOT_USER_UID=$(id -u)
DEPENDABOT_USER_GID=$(id -g)
export DEPENDABOT_USER_UID
export DEPENDABOT_USER_GID
docker_build "$ECOSYSTEM"
echo "$(tput setaf 2)=> building image from $DOCKERFILE$(tput sgr0)"
docker build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg "FROM_IMAGE=$UPDATER_IMAGE_NAME" \
-t "$IMAGE_NAME" \
-f "$DOCKERFILE" \
.
}
IMAGE_ID=$(docker inspect --type=image -f '{{.Id}}' "$IMAGE_NAME" 2> /dev/null || true)
if [ -z "$IMAGE_ID" ]; then
echo "$(tput setaf 4) > image $IMAGE_NAME doesn't exist$(tput sgr0)"
build_image
elif [ "$REBUILD" = "true" ]; then
echo "$(tput setaf 4) > rebuild of $IMAGE_NAME requested$(tput sgr0)"
build_image
else
echo "$(tput setaf 4) > image $IMAGE_NAME already exists$(tput sgr0)"
fi
CONTAINER_ARGS=("bash")
if [ "$#" -gt "1" ]; then
CONTAINER_ARGS=("${@:2}")
fi
set +e
RUNNING=$(docker ps --format '{{.Names}}' | grep "$CONTAINER_NAME$")
set -e
echo "$RUNNING"
if [ -n "$RUNNING" ]; then
if [ -z "$BUILT_IMAGE" ]; then
# image was not rebuilt - can we reuse existing?
exec docker exec -ti "$CONTAINER_NAME" "${CONTAINER_ARGS[@]}"
else
# image was rebuilt - exit running container
docker stop "$CONTAINER_NAME"
fi
fi
DOCKER_OPTS=()
if [ -n "$DEPENDABOT_PROXY" ]; then
DOCKER_OPTS+=(-e "http_proxy=$DEPENDABOT_PROXY")
DOCKER_OPTS+=(-e "HTTP_PROXY=$DEPENDABOT_PROXY")
DOCKER_OPTS+=(-e "https_proxy=$DEPENDABOT_PROXY")
DOCKER_OPTS+=(-e "HTTPS_PROXY=$DEPENDABOT_PROXY")
fi
if [ -n "$DOCKER_NETWORK" ]; then
DOCKER_OPTS+=(--network "$DOCKER_NETWORK")
fi
# for Mac with Docker Desktop or Rancher Desktop
if [[ "$(uname)" == "Darwin" ]]; then
# Use Docker Desktop's special SSH agent path
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
fi
# for Mac with Docker Desktop or Rancher Desktop, use:Add commentMore actions
# SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock ./bin/docker-dev-shell go_modules -r
if [ -n "$SSH_AUTH_SOCK" ]; then
DOCKER_OPTS+=("-v" "$SSH_AUTH_SOCK:/tmp/ssh-auth.sock")
DOCKER_OPTS+=("-e" "SSH_AUTH_SOCK=/tmp/ssh-auth.sock")
fi
echo "$(tput setaf 2)=> running docker development shell$(tput sgr0)"
CODE_DIR="/home/dependabot"
touch .core-bash_history # allow bash history to persist across invocations
mkdir -p dry-run tmp
docker run --rm -ti \
-v "$(pwd)/.core-bash_history:/home/dependabot/.bash_history" \
-v "$(pwd)/.rubocop.yml:$CODE_DIR/.rubocop.yml" \
-v "$(pwd)/.rubocop_todo.yml:$CODE_DIR/.rubocop_todo.yml" \
-v "$(pwd)/.ruby-version:$CODE_DIR/.ruby-version" \
-v "$(pwd)/bin:$CODE_DIR/bin" \
-v "$(pwd)/bazel/.rubocop.yml:$CODE_DIR/bazel/.rubocop.yml" \
-v "$(pwd)/bazel/dependabot-bazel.gemspec:$CODE_DIR/bazel/dependabot-bazel.gemspec" \
-v "$(pwd)/bazel/lib:$CODE_DIR/bazel/lib" \
-v "$(pwd)/bazel/script:$CODE_DIR/bazel/script" \
-v "$(pwd)/bazel/spec:$CODE_DIR/bazel/spec" \
-v "$(pwd)/bun/.rubocop.yml:$CODE_DIR/bun/.rubocop.yml" \
-v "$(pwd)/bun/dependabot-bun.gemspec:$CODE_DIR/bun/dependabot-bun.gemspec" \
-v "$(pwd)/bun/helpers:$CODE_DIR/bun/helpers" \
-v "$(pwd)/bun/lib:$CODE_DIR/bun/lib" \
-v "$(pwd)/bun/script:$CODE_DIR/bun/script" \
-v "$(pwd)/bun/spec:$CODE_DIR/bun/spec" \
-v "$(pwd)/bundler/.rubocop.yml:$CODE_DIR/bundler/.rubocop.yml" \
-v "$(pwd)/bundler/dependabot-bundler.gemspec:$CODE_DIR/bundler/dependabot-bundler.gemspec" \
-v "$(pwd)/bundler/helpers:$CODE_DIR/bundler/helpers" \
-v "$(pwd)/bundler/lib:$CODE_DIR/bundler/lib" \
-v "$(pwd)/bundler/script:$CODE_DIR/bundler/script" \
-v "$(pwd)/bundler/spec:$CODE_DIR/bundler/spec" \
-v "$(pwd)/cargo/.rubocop.yml:$CODE_DIR/cargo/.rubocop.yml" \
-v "$(pwd)/cargo/dependabot-cargo.gemspec:$CODE_DIR/cargo/dependabot-cargo.gemspec" \
-v "$(pwd)/cargo/lib:$CODE_DIR/cargo/lib" \
-v "$(pwd)/cargo/script:$CODE_DIR/cargo/script" \
-v "$(pwd)/cargo/spec:$CODE_DIR/cargo/spec" \
-v "$(pwd)/common/.rubocop.yml:$CODE_DIR/common/.rubocop.yml" \
-v "$(pwd)/common/bin:$CODE_DIR/common/bin" \
-v "$(pwd)/common/dependabot-common.gemspec:$CODE_DIR/common/dependabot-common.gemspec" \
-v "$(pwd)/common/lib:$CODE_DIR/common/lib" \
-v "$(pwd)/common/script:$CODE_DIR/common/script" \
-v "$(pwd)/common/spec:$CODE_DIR/common/spec" \
-v "$(pwd)/composer/.rubocop.yml:$CODE_DIR/composer/.rubocop.yml" \
-v "$(pwd)/composer/dependabot-composer.gemspec:$CODE_DIR/composer/dependabot-composer.gemspec" \
-v "$(pwd)/composer/helpers:$CODE_DIR/composer/helpers" \
-v "$(pwd)/composer/lib:$CODE_DIR/composer/lib" \
-v "$(pwd)/composer/script:$CODE_DIR/composer/script" \
-v "$(pwd)/composer/spec:$CODE_DIR/composer/spec" \
-v "$(pwd)/conda/.rubocop.yml:$CODE_DIR/conda/.rubocop.yml" \
-v "$(pwd)/conda/dependabot-conda.gemspec:$CODE_DIR/conda/dependabot-conda.gemspec" \
-v "$(pwd)/conda/lib:$CODE_DIR/conda/lib" \
-v "$(pwd)/conda/script:$CODE_DIR/conda/script" \
-v "$(pwd)/conda/spec:$CODE_DIR/conda/spec" \
-v "$(pwd)/devcontainers/.rubocop.yml:$CODE_DIR/devcontainers/.rubocop.yml" \
-v "$(pwd)/devcontainers/dependabot-devcontainers.gemspec:$CODE_DIR/devcontainers/dependabot-devcontainers.gemspec" \
-v "$(pwd)/devcontainers/lib:$CODE_DIR/devcontainers/lib" \
-v "$(pwd)/devcontainers/script:$CODE_DIR/devcontainers/script" \
-v "$(pwd)/devcontainers/spec:$CODE_DIR/devcontainers/spec" \
-v "$(pwd)/docker/.rubocop.yml:$CODE_DIR/docker/.rubocop.yml" \
-v "$(pwd)/docker/dependabot-docker.gemspec:$CODE_DIR/docker/dependabot-docker.gemspec" \
-v "$(pwd)/docker/lib:$CODE_DIR/docker/lib" \
-v "$(pwd)/docker/script:$CODE_DIR/docker/script" \
-v "$(pwd)/docker/spec:$CODE_DIR/docker/spec" \
-v "$(pwd)/docker_compose/.rubocop.yml:$CODE_DIR/docker_compose/.rubocop.yml" \
-v "$(pwd)/docker_compose/dependabot-docker_compose.gemspec:$CODE_DIR/docker_compose/dependabot-docker_compose.gemspec" \
-v "$(pwd)/docker_compose/lib:$CODE_DIR/docker_compose/lib" \
-v "$(pwd)/docker_compose/script:$CODE_DIR/docker_compose/script" \
-v "$(pwd)/docker_compose/spec:$CODE_DIR/docker_compose/spec" \
-v "$(pwd)/dotnet_sdk/.rubocop.yml:$CODE_DIR/dotnet_sdk/.rubocop.yml" \
-v "$(pwd)/dotnet_sdk/dependabot-dotnet_sdk.gemspec:$CODE_DIR/dotnet_sdk/dependabot-dotnet_sdk.gemspec" \
-v "$(pwd)/dotnet_sdk/lib:$CODE_DIR/dotnet_sdk/lib" \
-v "$(pwd)/dotnet_sdk/script:$CODE_DIR/dotnet_sdk/script" \
-v "$(pwd)/dotnet_sdk/spec:$CODE_DIR/dotnet_sdk/spec" \
-v "$(pwd)/dry-run:$CODE_DIR/dry-run" \
-v "$(pwd)/elm/.rubocop.yml:$CODE_DIR/elm/.rubocop.yml" \
-v "$(pwd)/elm/dependabot-elm.gemspec:$CODE_DIR/elm/dependabot-elm.gemspec" \
-v "$(pwd)/elm/lib:$CODE_DIR/elm/lib" \
-v "$(pwd)/elm/script:$CODE_DIR/elm/script" \
-v "$(pwd)/elm/spec:$CODE_DIR/elm/spec" \
-v "$(pwd)/git_submodules/.rubocop.yml:$CODE_DIR/git_submodules/.rubocop.yml" \
-v "$(pwd)/git_submodules/dependabot-git_submodules.gemspec:$CODE_DIR/git_submodules/dependabot-git_submodules.gemspec" \
-v "$(pwd)/git_submodules/lib:$CODE_DIR/git_submodules/lib" \
-v "$(pwd)/git_submodules/script:$CODE_DIR/git_submodules/script" \
-v "$(pwd)/git_submodules/spec:$CODE_DIR/git_submodules/spec" \
-v "$(pwd)/github_actions/.rubocop.yml:$CODE_DIR/github_actions/.rubocop.yml" \
-v "$(pwd)/github_actions/dependabot-github_actions.gemspec:$CODE_DIR/github_actions/dependabot-github_actions.gemspec" \
-v "$(pwd)/github_actions/lib:$CODE_DIR/github_actions/lib" \
-v "$(pwd)/github_actions/script:$CODE_DIR/github_actions/script" \
-v "$(pwd)/github_actions/spec:$CODE_DIR/github_actions/spec" \
-v "$(pwd)/go_modules/.rubocop.yml:$CODE_DIR/go_modules/.rubocop.yml" \
-v "$(pwd)/go_modules/dependabot-go_modules.gemspec:$CODE_DIR/go_modules/dependabot-go_modules.gemspec" \
-v "$(pwd)/go_modules/helpers:$CODE_DIR/go_modules/helpers" \
-v "$(pwd)/go_modules/lib:$CODE_DIR/go_modules/lib" \
-v "$(pwd)/go_modules/script:$CODE_DIR/go_modules/script" \
-v "$(pwd)/go_modules/spec:$CODE_DIR/go_modules/spec" \
-v "$(pwd)/gradle/.rubocop.yml:$CODE_DIR/gradle/.rubocop.yml" \
-v "$(pwd)/gradle/dependabot-gradle.gemspec:$CODE_DIR/gradle/dependabot-gradle.gemspec" \
-v "$(pwd)/gradle/lib:$CODE_DIR/gradle/lib" \
-v "$(pwd)/gradle/script:$CODE_DIR/gradle/script" \
-v "$(pwd)/gradle/spec:$CODE_DIR/gradle/spec" \
-v "$(pwd)/helm/.rubocop.yml:$CODE_DIR/helm/.rubocop.yml" \
-v "$(pwd)/helm/dependabot-helm.gemspec:$CODE_DIR/helm/dependabot-helm.gemspec" \
-v "$(pwd)/helm/lib:$CODE_DIR/helm/lib" \
-v "$(pwd)/helm/script:$CODE_DIR/helm/script" \
-v "$(pwd)/helm/spec:$CODE_DIR/helm/spec" \
-v "$(pwd)/hex/.rubocop.yml:$CODE_DIR/hex/.rubocop.yml" \
-v "$(pwd)/hex/dependabot-hex.gemspec:$CODE_DIR/hex/dependabot-hex.gemspec" \
-v "$(pwd)/hex/helpers:$CODE_DIR/hex/helpers" \
-v "$(pwd)/hex/lib:$CODE_DIR/hex/lib" \
-v "$(pwd)/hex/script:$CODE_DIR/hex/script" \
-v "$(pwd)/hex/spec:$CODE_DIR/hex/spec" \
-v "$(pwd)/julia/.rubocop.yml:$CODE_DIR/julia/.rubocop.yml" \
-v "$(pwd)/julia/dependabot-julia.gemspec:$CODE_DIR/julia/dependabot-julia.gemspec" \
-v "$(pwd)/julia/helpers:$CODE_DIR/julia/helpers" \
-v "$(pwd)/julia/lib:$CODE_DIR/julia/lib" \
-v "$(pwd)/julia/script:$CODE_DIR/julia/script" \
-v "$(pwd)/julia/spec:$CODE_DIR/julia/spec" \
-v "$(pwd)/maven/.rubocop.yml:$CODE_DIR/maven/.rubocop.yml" \
-v "$(pwd)/maven/dependabot-maven.gemspec:$CODE_DIR/maven/dependabot-maven.gemspec" \
-v "$(pwd)/maven/lib:$CODE_DIR/maven/lib" \
-v "$(pwd)/maven/script:$CODE_DIR/maven/script" \
-v "$(pwd)/maven/spec:$CODE_DIR/maven/spec" \
-v "$(pwd)/npm_and_yarn/.rubocop.yml:$CODE_DIR/npm_and_yarn/.rubocop.yml" \
-v "$(pwd)/npm_and_yarn/dependabot-npm_and_yarn.gemspec:$CODE_DIR/npm_and_yarn/dependabot-npm_and_yarn.gemspec" \
-v "$(pwd)/npm_and_yarn/helpers:$CODE_DIR/npm_and_yarn/helpers" \
-v "$(pwd)/npm_and_yarn/lib:$CODE_DIR/npm_and_yarn/lib" \
-v "$(pwd)/npm_and_yarn/script:$CODE_DIR/npm_and_yarn/script" \
-v "$(pwd)/npm_and_yarn/spec:$CODE_DIR/npm_and_yarn/spec" \
-v "$(pwd)/nuget/.rubocop.yml:$CODE_DIR/nuget/.rubocop.yml" \
-v "$(pwd)/nuget/dependabot-nuget.gemspec:$CODE_DIR/nuget/dependabot-nuget.gemspec" \
-v "$(pwd)/nuget/helpers:$CODE_DIR/nuget/helpers" \
-v "$(pwd)/nuget/lib:$CODE_DIR/nuget/lib" \
-v "$(pwd)/nuget/script:$CODE_DIR/nuget/script" \
-v "$(pwd)/nuget/spec:$CODE_DIR/nuget/spec" \
-v "$(pwd)/omnibus/.rubocop.yml:$CODE_DIR/omnibus/.rubocop.yml" \
-v "$(pwd)/omnibus/Gemfile:$CODE_DIR/omnibus/Gemfile" \
-v "$(pwd)/omnibus/dependabot-omnibus.gemspec:$CODE_DIR/omnibus/dependabot-omnibus.gemspec" \
-v "$(pwd)/omnibus/lib:$CODE_DIR/omnibus/lib" \
-v "$(pwd)/opentofu/.rubocop.yml:$CODE_DIR/opentofu/.rubocop.yml" \
-v "$(pwd)/opentofu/dependabot-opentofu.gemspec:$CODE_DIR/opentofu/dependabot-opentofu.gemspec" \
-v "$(pwd)/opentofu/helpers:$CODE_DIR/opentofu/helpers" \
-v "$(pwd)/opentofu/lib:$CODE_DIR/opentofu/lib" \
-v "$(pwd)/opentofu/script:$CODE_DIR/opentofu/script" \
-v "$(pwd)/opentofu/spec:$CODE_DIR/opentofu/spec" \
-v "$(pwd)/pub/.rubocop.yml:$CODE_DIR/pub/.rubocop.yml" \
-v "$(pwd)/pub/dependabot-pub.gemspec:$CODE_DIR/pub/dependabot-pub.gemspec" \
-v "$(pwd)/pub/lib:$CODE_DIR/pub/lib" \
-v "$(pwd)/pub/script:$CODE_DIR/pub/script" \
-v "$(pwd)/pub/spec:$CODE_DIR/pub/spec" \
-v "$(pwd)/python/.rubocop.yml:$CODE_DIR/python/.rubocop.yml" \
-v "$(pwd)/python/dependabot-python.gemspec:$CODE_DIR/python/dependabot-python.gemspec" \
-v "$(pwd)/python/helpers:$CODE_DIR/python/helpers" \
-v "$(pwd)/python/lib:$CODE_DIR/python/lib" \
-v "$(pwd)/python/script:$CODE_DIR/python/script" \
-v "$(pwd)/python/spec:$CODE_DIR/python/spec" \
-v "$(pwd)/rust_toolchain/.rubocop.yml:$CODE_DIR/rust_toolchain/.rubocop.yml" \
-v "$(pwd)/rust_toolchain/dependabot-rust_toolchain.gemspec:$CODE_DIR/rust_toolchain/dependabot-rust_toolchain.gemspec" \
-v "$(pwd)/rust_toolchain/lib:$CODE_DIR/rust_toolchain/lib" \
-v "$(pwd)/rust_toolchain/script:$CODE_DIR/rust_toolchain/script" \
-v "$(pwd)/rust_toolchain/spec:$CODE_DIR/rust_toolchain/spec" \
-v "$(pwd)/swift/.rubocop.yml:$CODE_DIR/swift/.rubocop.yml" \
-v "$(pwd)/swift/dependabot-swift.gemspec:$CODE_DIR/swift/dependabot-swift.gemspec" \
-v "$(pwd)/swift/lib:$CODE_DIR/swift/lib" \
-v "$(pwd)/swift/script:$CODE_DIR/swift/script" \
-v "$(pwd)/swift/spec:$CODE_DIR/swift/spec" \
-v "$(pwd)/terraform/.rubocop.yml:$CODE_DIR/terraform/.rubocop.yml" \
-v "$(pwd)/terraform/dependabot-terraform.gemspec:$CODE_DIR/terraform/dependabot-terraform.gemspec" \
-v "$(pwd)/terraform/helpers:$CODE_DIR/terraform/helpers" \
-v "$(pwd)/terraform/lib:$CODE_DIR/terraform/lib" \
-v "$(pwd)/terraform/script:$CODE_DIR/terraform/script" \
-v "$(pwd)/terraform/spec:$CODE_DIR/terraform/spec" \
-v "$(pwd)/uv/.rubocop.yml:$CODE_DIR/uv/.rubocop.yml" \
-v "$(pwd)/uv/dependabot-uv.gemspec:$CODE_DIR/uv/dependabot-uv.gemspec" \
-v "$(pwd)/uv/helpers:$CODE_DIR/uv/helpers" \
-v "$(pwd)/uv/lib:$CODE_DIR/uv/lib" \
-v "$(pwd)/uv/script:$CODE_DIR/uv/script" \
-v "$(pwd)/uv/spec:$CODE_DIR/uv/spec" \
-v "$(pwd)/vcpkg/.rubocop.yml:$CODE_DIR/vcpkg/.rubocop.yml" \
-v "$(pwd)/vcpkg/dependabot-vcpkg.gemspec:$CODE_DIR/vcpkg/dependabot-vcpkg.gemspec" \
-v "$(pwd)/vcpkg/lib:$CODE_DIR/vcpkg/lib" \
-v "$(pwd)/vcpkg/script:$CODE_DIR/vcpkg/script" \
-v "$(pwd)/vcpkg/spec:$CODE_DIR/vcpkg/spec" \
-v "$(pwd)/tmp:/$CODE_DIR/tmp" \
-v "$(pwd)/updater/.rubocop.yml:$CODE_DIR/dependabot-updater/.rubocop.yml" \
-v "$(pwd)/updater/bin:$CODE_DIR/dependabot-updater/bin" \
-v "$(pwd)/updater/Gemfile.lock:$CODE_DIR/dependabot-updater/Gemfile.lock" \
-v "$(pwd)/updater/Gemfile:$CODE_DIR/dependabot-updater/Gemfile" \
-v "$(pwd)/updater/lib:$CODE_DIR/dependabot-updater/lib" \
-v "$(pwd)/updater/spec:$CODE_DIR/dependabot-updater/spec" \
--name "$CONTAINER_NAME" \
--env "LOCAL_GITHUB_ACCESS_TOKEN=$LOCAL_GITHUB_ACCESS_TOKEN" \
--env "DEPENDABOT_TEST_ACCESS_TOKEN" \
"${DOCKER_OPTS[@]}" \
--cap-add=SYS_PTRACE \
"$IMAGE_NAME" "${CONTAINER_ARGS[@]}"
# vim: set ft=bash: