Skip to content

Commit

Permalink
Get moved python file fetcher specs passing
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Dec 9, 2018
1 parent b74e7ab commit ed0c5ee
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 241 deletions.
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,21 @@ ENV RUSTUP_HOME=/opt/rust \
RUN export CARGO_HOME=/opt/rust ; curl https://sh.rustup.rs -sSf | sh -s -- -y


### NEW NATIVE HELPERS LOCATION

ENV DEPENDABOT_NATIVE_HELPERS_PATH="/opt"


### TERRAFORM

COPY terraform/helpers/build /tmp/terraform-build
RUN bash /tmp/terraform-build /opt/terraform
ENV PATH="$PATH:/opt/terraform/bin" DEPENDABOT_NATIVE_HELPERS_PATH="/opt"
COPY terraform/helpers /opt/terraform/helpers
RUN bash /opt/terraform/helpers/build /opt/terraform
ENV PATH="$PATH:/opt/terraform/bin"


### PYTHON (MERGE WITH SECTION FUTHER UP)

COPY python/helpers /opt/python/helpers
RUN bash /opt/python/helpers/build /opt/python
ENV PATH="$PATH:/opt/python/bin"

10 changes: 7 additions & 3 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ COPY lib/dependabot/version.rb /home/dependabot/dependabot-core/lib/dependabot/
RUN bundle install

RUN mkdir -p /home/dependabot/dependabot-core/terraform
COPY terraform/Gemfile terraform/Gemfile.lock terraform/dependabot-terraform.gemspec /home/dependabot/dependabot-core/terraform/
COPY terraform/Gemfile terraform/dependabot-terraform.gemspec /home/dependabot/dependabot-core/terraform/
RUN cd terraform && bundle install

RUN mkdir -p /home/dependabot/dependabot-core/docker
COPY docker/Gemfile docker/Gemfile.lock docker/dependabot-docker.gemspec /home/dependabot/dependabot-core/docker/
COPY docker/Gemfile docker/dependabot-docker.gemspec /home/dependabot/dependabot-core/docker/
RUN cd docker && bundle install

RUN mkdir -p /home/dependabot/dependabot-core/git_submodules
COPY git_submodules/Gemfile git_submodules/Gemfile.lock git_submodules/dependabot-git-submodules.gemspec /home/dependabot/dependabot-core/git_submodules/
COPY git_submodules/Gemfile git_submodules/dependabot-git-submodules.gemspec /home/dependabot/dependabot-core/git_submodules/
RUN cd git_submodules && bundle install

RUN mkdir -p /home/dependabot/dependabot-core/python
COPY python/Gemfile python/dependabot-python.gemspec /home/dependabot/dependabot-core/python/
RUN cd python && bundle install
14 changes: 9 additions & 5 deletions bin/docker-dev-shell
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ docker run --rm -ti \
-v "$(pwd)/spec:$CODE_DIR/spec" \
-v "$(pwd)/helpers:$CODE_DIR/helpers" \
-v "$(pwd)/Gemfile:$CODE_DIR/Gemfile" \
-v "$(pwd)/terraform/Gemfile.lock:$CODE_DIR/terraform/Gemfile.lock" \
-v "$(pwd)/terraform/dependabot-terraform.gemspec:$CODE_DIR/terraform/dependabot-core.gemspec" \
-v "$(pwd)/terraform/Gemfile:$CODE_DIR/terraform/Gemfile" \
-v "$(pwd)/terraform/dependabot-terraform.gemspec:$CODE_DIR/terraform/dependabot-terraform.gemspec" \
-v "$(pwd)/terraform/lib:$CODE_DIR/terraform/lib" \
-v "$(pwd)/terraform/spec:$CODE_DIR/terraform/spec" \
-v "$(pwd)/docker/Gemfile.lock:$CODE_DIR/docker/Gemfile.lock" \
-v "$(pwd)/docker/dependabot-docker.gemspec:$CODE_DIR/docker/dependabot-core.gemspec" \
-v "$(pwd)/docker/Gemfile:$CODE_DIR/docker/Gemfile" \
-v "$(pwd)/docker/dependabot-docker.gemspec:$CODE_DIR/docker/dependabot-docker.gemspec" \
-v "$(pwd)/docker/lib:$CODE_DIR/docker/lib" \
-v "$(pwd)/docker/spec:$CODE_DIR/docker/spec" \
-v "$(pwd)/git_submodules/Gemfile.lock:$CODE_DIR/git_submodules/Gemfile.lock" \
-v "$(pwd)/git_submodules/Gemfile:$CODE_DIR/git_submodules/Gemfile" \
-v "$(pwd)/git_submodules/dependabot-git-submodules.gemspec:$CODE_DIR/git_submodules/dependabot-core.gemspec" \
-v "$(pwd)/git_submodules/lib:$CODE_DIR/git_submodules/lib" \
-v "$(pwd)/git_submodules/spec:$CODE_DIR/git_submodules/spec" \
-v "$(pwd)/python/Gemfile:$CODE_DIR/python/Gemfile" \
-v "$(pwd)/python/dependabot-python.gemspec:$CODE_DIR/python/dependabot-python.gemspec" \
-v "$(pwd)/python/lib:$CODE_DIR/python/lib" \
-v "$(pwd)/python/spec:$CODE_DIR/python/spec" \
--cap-add=SYS_PTRACE \
"$IMAGE_NAME" "${CONTAINER_ARGS[@]}"
7 changes: 7 additions & 0 deletions python/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "dependabot-core", path: "../"

gemspec
22 changes: 22 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## `dependabot-terraform`

Terraform support for [`dependabot-core`][core-repo].

### Running locally

1. Install native helpers
```
$ helpers/build helpers/install-dir/terraform
```

2. Install Ruby dependencies
```
$ bundle install
```

3. Run tests
```
$ bundle exec rspec spec
```

[core-repo]: https://github.com/dependabot/dependabot-core
44 changes: 44 additions & 0 deletions python/dependabot-python.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

require "find"

Gem::Specification.new do |spec|
core_gemspec = Bundler.load_gemspec_uncached("../dependabot-core.gemspec")

spec.name = "dependabot-python"
spec.summary = "Python support for dependabot-core"
spec.version = core_gemspec.version
spec.description = core_gemspec.description

spec.author = core_gemspec.author
spec.email = core_gemspec.email
spec.homepage = core_gemspec.homepage
spec.license = core_gemspec.license

spec.require_path = "lib"
spec.files = []

spec.required_ruby_version = core_gemspec.required_ruby_version
spec.required_rubygems_version = core_gemspec.required_ruby_version

spec.add_dependency "dependabot-core", Dependabot::VERSION

core_gemspec.development_dependencies.each do |dep|
spec.add_development_dependency dep.name, dep.requirement.to_s
end

next unless File.exist?("../.gitignore")

ignores = File.readlines("../.gitignore").grep(/\S+/).map(&:chomp)

next unless File.directory?("lib") && File.directory?("helpers")

prefix = "/" + File.basename(File.expand_path(__dir__)) + "/"
Find.find("lib", "helpers") do |path|
if ignores.any? { |i| File.fnmatch(i, prefix + path, File::FNM_DOTMATCH) }
Find.prune
else
spec.files << path unless File.directory?(path)
end
end
end
17 changes: 17 additions & 0 deletions python/helpers/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

install_dir=$1
if [ -z "$install_dir" ]; then
echo "usage: $0 INSTALL_DIR"
exit 1
fi

if [ ! -d "$install_dir/bin" ]; then
mkdir -p "$install_dir/bin"
fi

helpers_dir="$(dirname "${BASH_SOURCE[0]}")"
PYENV_VERSION=2.7.15 pyenv exec pip install -r "${helpers_dir}/requirements.txt"
PYENV_VERSION=3.6.7 pyenv exec pip install -r "${helpers_dir}/requirements.txt"
Loading

0 comments on commit ed0c5ee

Please sign in to comment.