Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.bundle
.git
.github
Dockerfile*
Gemfile.lock
Knylefile
LICENSE
README.md
SPEC.md
docker-bake.hcl
example
test-all-rubies.sh
coverage/
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Tests

on:
push:
branches: [master]
pull_request:
workflow_dispatch:

jobs:
test:
name: Ruby ${{ matrix.ruby }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allow_failure || false }}
strategy:
fail-fast: false
matrix:
ruby:
- "1.9"
- "2.0"
- "2.1"
- "2.2"
- "2.3"
- "2.4"
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
- "3.4"
- "4.0"
- head
coverage: [0]
include:
- ruby: "4.0"
coverage: 1
- ruby: head
allow_failure: true
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build
run: docker buildx bake --load "ruby-${RUBY//\./-}"
env:
RUBY: ${{ matrix.ruby }}
- name: Test
run: docker run --rm -e COVERAGE=${{ matrix.coverage }} "kss-test:${{ matrix.ruby }}"

gate:
name: All Tests
needs: [test]
if: always()
runs-on: ubuntu-slim
steps:
- if: ${{ !success() }}
run: exit 1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.bundle
Gemfile.lock
bin
.sass-cache
.sass-cache
coverage/
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

64 changes: 64 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM debian:bullseye

RUN apt-get update && apt-get install -y \
autotools-dev build-essential curl ca-certificates \
libssl-dev libreadline-dev libffi-dev libyaml-dev zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

ARG OPENSSL=1.0.2
# Build OpenSSL 1.0.2 only when needed (Ruby <2.4 is incompatible with OpenSSL 1.1+)
RUN if [ "$OPENSSL" = "1.0.2" ]; then \
curl -fSL https://www.openssl.org/source/openssl-1.0.2u.tar.gz | tar -xzC /usr/local/src \
&& cd /usr/local/src/openssl-1.0.2u \
&& ./config --prefix=/opt/openssl-1.0.2 shared \
&& make -j"$(nproc)" \
&& make install_sw \
&& rm -rf /usr/local/src/openssl-1.0.2u; \
fi

ARG RUBY_MAJOR=1.9
ARG RUBY_VERSION=1.9.3-p551
ARG RUBY_ARCHIVE=bz2

# Download and extract Ruby source
RUN mkdir -p /usr/local/src/ruby \
&& curl -fSL "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR}/ruby-${RUBY_VERSION}.tar.${RUBY_ARCHIVE}" \
| tar -x$([ "$RUBY_ARCHIVE" = "bz2" ] && echo j || echo z)C /usr/local/src/ruby --strip-components=1

# Patch config.guess/config.sub for aarch64 support, then compile
RUN cp /usr/share/misc/config.guess /usr/local/src/ruby/tool/ \
&& cp /usr/share/misc/config.sub /usr/local/src/ruby/tool/ \
&& cd /usr/local/src/ruby \
&& OPENSSL_DIR=$([ "$OPENSSL" = "1.0.2" ] && echo /opt/openssl-1.0.2 || echo /usr) \
&& ./configure --prefix=/opt/rubies/ruby-${RUBY_VERSION} --disable-install-doc \
--with-openssl-dir=$OPENSSL_DIR \
&& if [ "$(printf '%s\n' "2.5" "$RUBY_MAJOR" | sort -V | head -n1)" = "2.5" ]; then \
make -j"$(nproc)"; \
else \
make; \
fi \
&& make install \
&& rm -rf /usr/local/src/ruby

ENV PATH=/opt/rubies/ruby-${RUBY_VERSION}/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/openssl-1.0.2/lib
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

ARG INSTALL_BUNDLER=1.17.3
RUN if [ -n "$INSTALL_BUNDLER" ]; then \
gem install bundler -v $INSTALL_BUNDLER --no-document 2>/dev/null \
|| gem install bundler -v $INSTALL_BUNDLER --no-rdoc --no-ri; \
fi

WORKDIR /app
COPY . .

RUN --mount=type=cache,target=/bundle-cache \
(bundle config set --local path /bundle-cache 2>/dev/null \
|| bundle config --local path /bundle-cache) \
&& (bundle check || bundle install --jobs $(nproc)) \
&& mkdir -p vendor/bundle \
&& cp -a /bundle-cache/. vendor/bundle/ \
&& (bundle config set --local path vendor/bundle 2>/dev/null \
|| bundle config --local path vendor/bundle)
CMD ["bundle", "exec", "rake", "test"]
31 changes: 31 additions & 0 deletions Dockerfile.head
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM debian:bookworm

RUN apt-get update && apt-get install -y \
autotools-dev autoconf bison build-essential curl ca-certificates git \
ruby \
libssl-dev libreadline-dev libffi-dev libyaml-dev zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

RUN git clone --depth 1 https://github.com/ruby/ruby.git /usr/local/src/ruby \
&& cd /usr/local/src/ruby \
&& ./autogen.sh \
&& cp /usr/share/misc/config.guess tool/ \
&& cp /usr/share/misc/config.sub tool/ \
&& ./configure --prefix=/opt/rubies/ruby-head --disable-install-doc \
&& make -j"$(nproc)" \
&& make install \
&& rm -rf /usr/local/src/ruby

ENV PATH=/opt/rubies/ruby-head/bin:$PATH
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

WORKDIR /app
COPY . .

RUN --mount=type=cache,target=/bundle-cache \
bundle config set --local path /bundle-cache \
&& (bundle check || bundle install --jobs $(nproc)) \
&& mkdir -p vendor/bundle \
&& cp -a /bundle-cache/* vendor/bundle/ \
&& bundle config set --local path vendor/bundle
CMD ["bundle", "exec", "rake", "test"]
22 changes: 16 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
source 'https://rubygems.org'
source "https://rubygems.org"

group :test do
gem "minitest", "~> 5.0.4"
if RUBY_VERSION >= "4.0"
gem "minitest", "~> 6.0"
elsif RUBY_VERSION >= "3.4"
gem "minitest", "~> 5.25"
else
gem "minitest", "~> 5.0.4"
end
gem "test-unit" unless RUBY_VERSION < "2.0"
gem "simplecov", require: false if RUBY_VERSION >= "2.4"
end

group :development do
gem "mg", ">= 0.0.8"
gem "rake", ">= 0.8.7"
gem "rubyforge", ">= 2.0.3"
end
if RUBY_VERSION < "2.3"
gem "rake", "~> 12.0"
else
gem "rake", "~> 13.0"
end
end
20 changes: 0 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,3 @@ task :console do
exec "irb -I lib -rkss"
end

#
# Gems
#

begin
require 'mg'
MG.new("kss.gemspec")
rescue LoadError
warn "mg not available."
warn "Install it with: gem install mg"
end

desc "Push a new version to Gemcutter and publish docs."
task :publish => "gem:publish" do
require File.dirname(__FILE__) + '/lib/kss/version'

sh "git tag v#{Kss::VERSION}"
sh "git push origin master --tags"
sh "git clean -fd"
end
Loading