Skip to content

Commit

Permalink
Add skeleton for go_modules re-org
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Jan 2, 2019
1 parent f3e89f5 commit 7ed085f
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ jobs:
docker run -ti dependabot/dependabot-core-ci \
bash -c "cd cargo && rubocop"
docker run -ti dependabot/dependabot-core-ci \
bash -c "cd go_modules && rubocop"
- run:
name: RSpec
command: |
Expand Down Expand Up @@ -120,6 +123,9 @@ jobs:
docker run -ti dependabot/dependabot-core-ci \
bash -c "cd cargo && rspec spec --format documentation"
docker run -ti dependabot/dependabot-core-ci \
bash -c "cd go_modules && rspec spec --format documentation"
- run:
name: Push dependabot-core image to Docker hub, if on master
command: |
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ COPY git_submodules/Gemfile \
/home/dependabot/dependabot-core/git_submodules/
RUN cd git_submodules && bundle install

<<<<<<< HEAD
RUN mkdir -p /home/dependabot/dependabot-core/maven
COPY maven/Gemfile \
maven/dependabot-maven.gemspec \
Expand All @@ -69,4 +70,10 @@ COPY cargo/Gemfile \
/home/dependabot/dependabot-core/cargo/
RUN cd cargo && bundle install

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

COPY --chown=dependabot . /home/dependabot/dependabot-core/
5 changes: 5 additions & 0 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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

<<<<<<< HEAD
RUN mkdir -p /home/dependabot/dependabot-core/nuget
COPY nuget/Gemfile nuget/dependabot-nuget.gemspec /home/dependabot/dependabot-core/nuget/
RUN cd nuget && bundle install
Expand All @@ -55,3 +56,7 @@ RUN cd gradle && bundle install
RUN mkdir -p /home/dependabot/dependabot-core/cargo
COPY cargo/Gemfile cargo/dependabot-cargo.gemspec /home/dependabot/dependabot-core/cargo/
RUN cd cargo && bundle install

RUN mkdir -p /home/dependabot/dependabot-core/go_modules
COPY go_modules/Gemfile go_modules/dependabot-go_modules.gemspec /home/dependabot/dependabot-core/go_modules/
RUN cd go_modules && bundle install
4 changes: 4 additions & 0 deletions bin/docker-dev-shell
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,9 @@ docker run --rm -ti \
-v "$(pwd)/cargo/dependabot-cargo.gemspec:$CODE_DIR/cargo/dependabot-core.gemspec" \
-v "$(pwd)/cargo/lib:$CODE_DIR/cargo/lib" \
-v "$(pwd)/cargo/spec:$CODE_DIR/cargo/spec" \
-v "$(pwd)/go_modules/Gemfile:$CODE_DIR/go_modules/Gemfile" \
-v "$(pwd)/go_modules/dependabot-go_modules.gemspec:$CODE_DIR/go_modules/dependabot-go_modules.gemspec" \
-v "$(pwd)/go_modules/lib:$CODE_DIR/go_modules/lib" \
-v "$(pwd)/go_modules/spec:$CODE_DIR/go_modules/spec" \
--cap-add=SYS_PTRACE \
"$IMAGE_NAME" "${CONTAINER_ARGS[@]}"
1 change: 1 addition & 0 deletions config/rubocop-top-level.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ AllCops:
- 'maven/**/*'
- 'python/**/*'
- 'cargo/**/*'
- 'go_modules/**/*'
1 change: 1 addition & 0 deletions go_modules/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: ../config/rubocop-default.yml
7 changes: 7 additions & 0 deletions go_modules/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 go_modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## `dependabot-go_modules`

Go modules support for [`dependabot-core`][core-repo].

### Running locally

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

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 go_modules/dependabot-go_modules.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-go_modules"
spec.summary = "Go modules 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
11 changes: 11 additions & 0 deletions go_modules/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

def common_dir
@common_dir ||= Gem::Specification.find_by_name("dependabot-core").gem_dir
end

def require_common_spec(path)
require "#{common_dir}/spec/dependabot/#{path}"
end

require "#{common_dir}/spec/spec_helper.rb"
1 change: 1 addition & 0 deletions omnibus/dependabot-omnibus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "dependabot-nuget", Dependabot::VERSION
spec.add_dependency "dependabot-python", Dependabot::VERSION
spec.add_dependency "dependabot-terraform", Dependabot::VERSION
spec.add_dependency "dependabot-go_modules", Dependabot::VERSION
end
1 change: 1 addition & 0 deletions omnibus/lib/dependabot/omnibus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
require "dependabot/gradle"
require "dependabot/maven"
require "dependabot/cargo"
require "dependabot/go_modules"

0 comments on commit 7ed085f

Please sign in to comment.