Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine #477

Merged
merged 11 commits into from
Aug 3, 2018
87 changes: 16 additions & 71 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ steps: &steps
- dependencies-{{ checksum "Gemfile.lock" }}

- run:
name: Run tests
command: bin/test.sh
name: Run CI checks
command: bin/ci.sh

- run:
name: Save coverage
Expand All @@ -29,26 +29,6 @@ steps: &steps
- .bundle

jobs:
lint:
docker:
- image: deividrodriguez/byebug:2.5.1-readline-clang

steps:
- checkout

- restore_cache:
keys:
- dependencies-{{ checksum "Gemfile.lock" }}

- run:
name: Run linters
command: bin/lint.sh

- save_cache:
key: dependencies-{{ checksum "Gemfile.lock" }}
paths:
- .bundle

prior-to-prior-to-latest-readline-gcc:
docker:
- image: deividrodriguez/byebug:2.3.7-readline-gcc
Expand Down Expand Up @@ -132,55 +112,20 @@ workflows:

test:
jobs:
- lint

- prior-to-prior-to-latest-readline-gcc:
requires:
- lint

- prior-to-prior-to-latest-libedit-gcc:
requires:
- lint

- prior-to-prior-to-latest-readline-clang:
requires:
- lint

- prior-to-prior-to-latest-libedit-clang:
requires:
- lint

- prior-to-latest-readline-gcc:
requires:
- lint

- prior-to-latest-libedit-gcc:
requires:
- lint

- prior-to-latest-readline-clang:
requires:
- lint

- prior-to-latest-libedit-clang:
requires:
- lint

- latest-readline-gcc:
requires:
- lint

- latest-libedit-gcc:
requires:
- lint

- latest-readline-clang:
requires:
- lint

- latest-libedit-clang:
requires:
- lint
- prior-to-prior-to-latest-readline-gcc
- prior-to-prior-to-latest-libedit-gcc
- prior-to-prior-to-latest-readline-clang
- prior-to-prior-to-latest-libedit-clang

- prior-to-latest-readline-gcc
- prior-to-latest-libedit-gcc
- prior-to-latest-readline-clang
- prior-to-latest-libedit-clang

- latest-readline-gcc
- latest-libedit-gcc
- latest-readline-clang
- latest-libedit-clang

- upload_coverage:
requires:
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ before_install:

install:
- gem update --system 2.7.7
- gem install bundler --version 1.16.3

- if [ "$LIBEDIT" == "true" ]; then
rvm reinstall "$TRAVIS_RUBY_VERSION" --configure --enable-libedit;
fi

script:
- bin/test.sh
- bin/ci.sh

matrix:
fast_finish: true
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ DEPENDENCIES
yard (= 0.9.15)

BUNDLED WITH
1.16.2
1.16.3
2 changes: 1 addition & 1 deletion bin/lint.sh → bin/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -eo pipefail
set +x

bin/bundle install --jobs 3 --retry 3 --path .bundle
bin/rake lint
bin/rake

set -x
10 changes: 0 additions & 10 deletions bin/test.sh

This file was deleted.

55 changes: 44 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:stretch
FROM alpine:3.7

# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
Expand All @@ -17,17 +17,34 @@ ENV CC $compiler

RUN set -ex \
\
&& baseDeps=" \
$compiler \
&& baseDeps=" \
bash \
ca-certificates \
cmake \
clang \
gcc \
libffi-dev \
libressl-dev \
make \
" \
&& buildOnlyDeps=" \
libssl1.0-dev \
autoconf \
bison \
build-base \
bzip2-dev \
dpkg \
dpkg-dev \
gdbm-dev \
glib-dev \
libc-dev \
libxml2-dev \
libxslt-dev \
$line_edit_lib \
linux-headers \
ncurses-dev \
ruby \
" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $baseDeps $buildOnlyDeps \
&& rm -rf /var/lib/apt/lists/* \
&& apk add --no-cache --virtual .ruby-builddeps $baseDeps $buildOnlyDeps \
\
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${ruby_version%.*}/ruby-$ruby_version.tar.xz" \
&& echo "$ruby_download_sha256 *ruby.tar.xz" | sha256sum -c - \
Expand All @@ -48,16 +65,32 @@ RUN set -ex \
&& make -j "$(nproc)" \
&& make install \
\
&& apt-get purge -y --auto-remove $buildOnlyDeps \
&& libDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
&& runOnlyDeps=" \
$libDeps \
binutils \
git \
libc-dev \
libc6-compat \
" \
&& apk add --virtual .ruby-rundeps $baseDeps $runOnlyDeps \
&& apk del .ruby-builddeps \
&& cd / \
&& rm -r /usr/src/ruby \
\
&& gem update --system 2.7.7 \
&& gem install bundler --version 1.16.3 --force \
&& rm -r /root/.gem

RUN apt-get update && apt-get install -y --no-install-recommends \
clang-format \
shellcheck
RUN SHELLCHECK_VERSION=v0.5.0 \
&& wget "https://storage.googleapis.com/shellcheck/shellcheck-$SHELLCHECK_VERSION.linux.x86_64.tar.xz" \
&& tar -xJf shellcheck-$SHELLCHECK_VERSION.linux.x86_64.tar.xz \
&& cp shellcheck-$SHELLCHECK_VERSION/shellcheck /usr/bin/

ENV BUNDLE_SILENCE_ROOT_WARNING=1

Expand Down
39 changes: 24 additions & 15 deletions docker/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require "net/http"
require "yaml"
require "open3"

module Docker
#
Expand Down Expand Up @@ -33,9 +34,7 @@ def initialize(version:, line_editor:, compiler:)
end

def build
print "Building image #{tag}... "

status = system <<-COMMAND, out: File::NULL
command = <<-COMMAND
docker build \
--tag "#{tag}" \
--build-arg "ruby_version=#{version}" \
Expand All @@ -47,17 +46,19 @@ def build
.
COMMAND

puts(status ? "✔" : "❌")
print "Building image #{tag}: #{squish(command)} "

run(command)
end

def test
print "Testing image #{tag}... "

status = system <<-COMMAND, out: File::NULL, err: File::NULL
docker run --rm -v$(pwd):/byebug #{tag} bash -c 'bundle && bundle exec rake'
command = <<-COMMAND
docker run --rm -v$(pwd):/byebug #{tag} bash -c ' bin/bundle && bin/rake'
COMMAND

puts(status ? "✔" : "❌")
print "Testing image #{tag}: #{squish(command)} "

run(command)
end

def push
Expand All @@ -77,11 +78,7 @@ def push
return
end

pushed = system <<-COMMAND, out: File::NULL
docker push #{tag}
COMMAND

puts pushed ? "✔" : "❌"
run("docker push #{tag}")
end

class << self
Expand Down Expand Up @@ -130,7 +127,7 @@ def for_all_images
private

def line_editor_package
line_editor == "readline" ? "libreadline-dev" : "libedit-dev"
line_editor == "readline" ? "readline-dev" : "libedit-dev"
end

def line_editor_configure_flag
Expand All @@ -145,8 +142,20 @@ def sha256
release_info.find { |entry| entry["version"] == version }["sha256"]["xz"]
end

def run(command)
output, status = Open3.capture2e(command)

puts(status ? "✔" : "❌")

puts output unless status.success?
end

def tag
"deividrodriguez/byebug:#{version}-#{line_editor}-#{compiler}"
end

def squish(command)
command.gsub(/[\n ]+/, " ").strip
end
end
end
2 changes: 1 addition & 1 deletion tasks/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ def applicable_files
end

def clean?(file)
!File.read(file, encoding: Encoding::UTF_8).match?(/ +$/)
File.read(file, encoding: Encoding::UTF_8) !~ / +$/
end
end