Skip to content

Commit

Permalink
Be a little more ruby-standard (#762)
Browse files Browse the repository at this point in the history
This switches the way we fetch dependencies for ruby from `gem` to
`bundler` which is more standard in the ruby world. This is basically a
noop unless you are doing ruby development. But if you *are* doing ruby
development then you can use standard ruby commands like `bundle exec
rspec` locally which makes the project *much* more approachable for ruby
folks. It isn't authoritative though. Jenkins will still use docker, as
will building the docs.

I've not gone so far as to use rake for ruby stuff yet. I'll get there
in a subsequent PR probably.
  • Loading branch information
nik9000 authored Apr 3, 2019
1 parent 36066e4 commit ee05da1
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_PATH: "vendor/bundle"
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!Gemfile*
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ bin
!html/sitemap.xml
metastore_db
html_docs/
!resources/asciidoctor/**/bin
resources/asciidoctor/vendor/**/cache
vendor

# Comes from running tests in resources/asciidoctor
resources/asciidoctor/build
Expand Down
29 changes: 11 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,6 @@ RUN install_packages \
# have to be empty. So we delete them.
RUN rm -rf /var/log/nginx && rm -rf /run

# Gem inventory:
# * Used by the docs build
# * asciidoctor
# * thread_safe
# * Speculative
# * asciidoctor-diagram
# * asciimath
# * Used to check the build in CI
# * rubocop
# * rspec
RUN gem install --no-document \
asciidoctor:1.5.8 \
asciidoctor-diagram:1.5.12 \
asciimath:1.0.8 \
rubocop:0.64.0 \
rspec:3.8.0 \
thread_safe:0.3.6

# Wheel inventory:
# * Used to test the docs build
# * beautifulsoup4
Expand All @@ -79,3 +61,14 @@ RUN pip3 install \
beautifulsoup4==4.7.1 \
lxml==4.3.1 \
pycodestyle==2.5.0

# Install ruby deps with bundler to make things more standard for Ruby folks.
RUN gem install bundler:2.0.1
RUN bundle config --global silence_root_warning 1
COPY Gemfile* /
RUN bundle install --binstubs --system --frozen
# --frozen forces us to regenerate Gemfile.lock locally before using it in
# docker which is important because we need Gemfile.lock to lock the gems to a
# consistent version and we can't rely on running bundler in docker to update
# it because we can't copy from the image to the host machine while building
# the image.
18 changes: 18 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# IMPORTANT: If you change this file you should run `bundle lock` to
# regenerate Gemfile.lock or building the docker image will fail.
source "https://rubygems.org"

ruby "~> 2.3"

# We commit Gemfile.lock so we're not going to have "unexpected" version bumps
# of our gems. This file specifies what we think *should* work. Gemfile.lock
# specifies what we *know* does work.
gem "asciidoctor", "~> 1.5" # Used by the docs build
gem "thread_safe", "~> 0.3.6" # Used by asciidoctor
gem "asciidoctor-diagram", "~> 1.5" # Speculative
gem "asciimath", "~> 1.0" # Speculative

group :test do
gem "rspec", "~> 3.8"
gem "rubocop", "~> 0.64.0"
end
56 changes: 56 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
GEM
remote: https://rubygems.org/
specs:
asciidoctor (1.5.8)
asciidoctor-diagram (1.5.12)
asciidoctor (~> 1.5.0)
asciimath (1.0.8)
ast (2.4.0)
diff-lcs (1.3)
jaro_winkler (1.5.2)
parallel (1.16.2)
parser (2.6.2.0)
ast (~> 2.4.0)
powerpack (0.1.2)
rainbow (3.0.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.64.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.0)
thread_safe (0.3.6)
unicode-display_width (1.4.1)

PLATFORMS
ruby

DEPENDENCIES
asciidoctor (~> 1.5)
asciidoctor-diagram (~> 1.5)
asciimath (~> 1.0)
rspec (~> 3.8)
rubocop (~> 0.64.0)
thread_safe (~> 0.3.6)

RUBY VERSION
ruby 2.5.3p105

BUNDLED WITH
1.17.1
2 changes: 1 addition & 1 deletion build_docs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def build_docker_image():
else:
acc.append(line)

cmd = ["docker", "image", "build", "-t", "elastic/docs_build", "-"]
cmd = ["docker", "image", "build", "-t", "elastic/docs_build", DIR]
build = common_popen(cmd, dockerfile)
handle_popen(build, handle_line)
if build.returncode != 0:
Expand Down
11 changes: 10 additions & 1 deletion resources/asciidoctor/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
These are Elastic's extensions to Asciidoctor! The `lib` directory contains
the actual extensions and the spec directory contains the tests. You can run
the tests with `build_docs --self-test`.
the tests with `build_docs --self-test` to reproduce the authoritative, in
docker tests. You can also use more ruby standard stuff like:

```
bundle install
bundle exec rspec
bundle exec rubocop
```

but it is not authoritative.

0 comments on commit ee05da1

Please sign in to comment.