From 7f25b426846fe513f0351fa215dcccc88bd4d9be Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:37:26 -0800 Subject: [PATCH 1/5] =?UTF-8?q?Multi-version=20Ruby=20Docker=20setup=20(1.?= =?UTF-8?q?9=E2=80=934.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dockerfile: conditional OpenSSL, archive format, parallel make, bundler - docker-bake.hcl: 15 Ruby versions as buildx bake targets - test-all-rubies.sh: build + test all versions - .dockerignore: exclude Gemfile.lock for bundler compat - Gemfile: conditional rake version, test-unit gem for 2.0+ - Fix uninitialized @section ivar warning in Section --- .dockerignore | 1 + Dockerfile | 57 ++++++++++++ Gemfile | 13 ++- docker-bake.hcl | 224 +++++++++++++++++++++++++++++++++++++++++++++ lib/kss/section.rb | 1 + test-all-rubies.sh | 25 +++++ 6 files changed, 317 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-bake.hcl create mode 100755 test-all-rubies.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b844b14 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Gemfile.lock diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..860215b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +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 bundle install --jobs $(nproc) +CMD ["bundle", "exec", "rake", "test"] diff --git a/Gemfile b/Gemfile index 05dc014..57eaf4a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,16 @@ -source :rubygems +source "https://rubygems.org" group :test do - gem "minitest", ">= 1.5.0" + gem "minitest", "~> 4.0" + gem "test-unit" unless RUBY_VERSION < "2.0" end group :development do gem "mg", ">= 0.0.8" - gem "rake", ">= 0.8.7" + if RUBY_VERSION < "2.3" + gem "rake", "~> 12.0" + else + gem "rake", "~> 13.0" + end gem "rubyforge", ">= 2.0.3" -end \ No newline at end of file +end diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 0000000..6c93769 --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,224 @@ +variable "VERSIONS" { + default = { + "1.9" = { version = "1.9.3-p551", archive = "bz2", openssl = "1.0.2", bundler = "1.17.3" } + "2.0" = { version = "2.0.0-p648", archive = "bz2", openssl = "1.0.2", bundler = "1.17.3" } + "2.1" = { version = "2.1.10", archive = "bz2", openssl = "1.0.2", bundler = "1.17.3" } + "2.2" = { version = "2.2.10", archive = "bz2", openssl = "1.0.2", bundler = "1.17.3" } + "2.3" = { version = "2.3.8", archive = "bz2", openssl = "1.0.2", bundler = "1.17.3" } + "2.4" = { version = "2.4.10", archive = "bz2", openssl = "1.1", bundler = "1.17.3" } + "2.5" = { version = "2.5.9", archive = "bz2", openssl = "1.1", bundler = "1.17.3" } + "2.6" = { version = "2.6.10", archive = "bz2", openssl = "1.1", bundler = "1.17.3" } + "2.7" = { version = "2.7.8", archive = "bz2", openssl = "1.1", bundler = "" } + "3.0" = { version = "3.0.7", archive = "gz", openssl = "1.1", bundler = "" } + "3.1" = { version = "3.1.7", archive = "gz", openssl = "1.1", bundler = "" } + "3.2" = { version = "3.2.10", archive = "gz", openssl = "1.1", bundler = "" } + "3.3" = { version = "3.3.10", archive = "gz", openssl = "1.1", bundler = "" } + "3.4" = { version = "3.4.8", archive = "gz", openssl = "1.1", bundler = "" } + "4.0" = { version = "4.0.1", archive = "gz", openssl = "1.1", bundler = "" } + } +} + +group "default" { + targets = [ + "ruby-1-9", + "ruby-2-0", + "ruby-2-1", + "ruby-2-2", + "ruby-2-3", + "ruby-2-4", + "ruby-2-5", + "ruby-2-6", + "ruby-2-7", + "ruby-3-0", + "ruby-3-1", + "ruby-3-2", + "ruby-3-3", + "ruby-3-4", + "ruby-4-0", + ] +} + +target "_common" { + dockerfile = "Dockerfile" + context = "." +} + +target "ruby-1-9" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "1.9" + RUBY_VERSION = VERSIONS["1.9"].version + RUBY_ARCHIVE = VERSIONS["1.9"].archive + OPENSSL = VERSIONS["1.9"].openssl + INSTALL_BUNDLER = VERSIONS["1.9"].bundler + } + tags = ["kss-test:1.9"] +} + +target "ruby-2-0" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.0" + RUBY_VERSION = VERSIONS["2.0"].version + RUBY_ARCHIVE = VERSIONS["2.0"].archive + OPENSSL = VERSIONS["2.0"].openssl + INSTALL_BUNDLER = VERSIONS["2.0"].bundler + } + tags = ["kss-test:2.0"] +} + +target "ruby-2-1" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.1" + RUBY_VERSION = VERSIONS["2.1"].version + RUBY_ARCHIVE = VERSIONS["2.1"].archive + OPENSSL = VERSIONS["2.1"].openssl + INSTALL_BUNDLER = VERSIONS["2.1"].bundler + } + tags = ["kss-test:2.1"] +} + +target "ruby-2-2" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.2" + RUBY_VERSION = VERSIONS["2.2"].version + RUBY_ARCHIVE = VERSIONS["2.2"].archive + OPENSSL = VERSIONS["2.2"].openssl + INSTALL_BUNDLER = VERSIONS["2.2"].bundler + } + tags = ["kss-test:2.2"] +} + +target "ruby-2-3" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.3" + RUBY_VERSION = VERSIONS["2.3"].version + RUBY_ARCHIVE = VERSIONS["2.3"].archive + OPENSSL = VERSIONS["2.3"].openssl + INSTALL_BUNDLER = VERSIONS["2.3"].bundler + } + tags = ["kss-test:2.3"] +} + +target "ruby-2-4" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.4" + RUBY_VERSION = VERSIONS["2.4"].version + RUBY_ARCHIVE = VERSIONS["2.4"].archive + OPENSSL = VERSIONS["2.4"].openssl + INSTALL_BUNDLER = VERSIONS["2.4"].bundler + } + tags = ["kss-test:2.4"] +} + +target "ruby-2-5" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.5" + RUBY_VERSION = VERSIONS["2.5"].version + RUBY_ARCHIVE = VERSIONS["2.5"].archive + OPENSSL = VERSIONS["2.5"].openssl + INSTALL_BUNDLER = VERSIONS["2.5"].bundler + } + tags = ["kss-test:2.5"] +} + +target "ruby-2-6" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.6" + RUBY_VERSION = VERSIONS["2.6"].version + RUBY_ARCHIVE = VERSIONS["2.6"].archive + OPENSSL = VERSIONS["2.6"].openssl + INSTALL_BUNDLER = VERSIONS["2.6"].bundler + } + tags = ["kss-test:2.6"] +} + +target "ruby-2-7" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "2.7" + RUBY_VERSION = VERSIONS["2.7"].version + RUBY_ARCHIVE = VERSIONS["2.7"].archive + OPENSSL = VERSIONS["2.7"].openssl + INSTALL_BUNDLER = VERSIONS["2.7"].bundler + } + tags = ["kss-test:2.7"] +} + +target "ruby-3-0" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "3.0" + RUBY_VERSION = VERSIONS["3.0"].version + RUBY_ARCHIVE = VERSIONS["3.0"].archive + OPENSSL = VERSIONS["3.0"].openssl + INSTALL_BUNDLER = VERSIONS["3.0"].bundler + } + tags = ["kss-test:3.0"] +} + +target "ruby-3-1" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "3.1" + RUBY_VERSION = VERSIONS["3.1"].version + RUBY_ARCHIVE = VERSIONS["3.1"].archive + OPENSSL = VERSIONS["3.1"].openssl + INSTALL_BUNDLER = VERSIONS["3.1"].bundler + } + tags = ["kss-test:3.1"] +} + +target "ruby-3-2" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "3.2" + RUBY_VERSION = VERSIONS["3.2"].version + RUBY_ARCHIVE = VERSIONS["3.2"].archive + OPENSSL = VERSIONS["3.2"].openssl + INSTALL_BUNDLER = VERSIONS["3.2"].bundler + } + tags = ["kss-test:3.2"] +} + +target "ruby-3-3" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "3.3" + RUBY_VERSION = VERSIONS["3.3"].version + RUBY_ARCHIVE = VERSIONS["3.3"].archive + OPENSSL = VERSIONS["3.3"].openssl + INSTALL_BUNDLER = VERSIONS["3.3"].bundler + } + tags = ["kss-test:3.3"] +} + +target "ruby-3-4" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "3.4" + RUBY_VERSION = VERSIONS["3.4"].version + RUBY_ARCHIVE = VERSIONS["3.4"].archive + OPENSSL = VERSIONS["3.4"].openssl + INSTALL_BUNDLER = VERSIONS["3.4"].bundler + } + tags = ["kss-test:3.4"] +} + +target "ruby-4-0" { + inherits = ["_common"] + args = { + RUBY_MAJOR = "4.0" + RUBY_VERSION = VERSIONS["4.0"].version + RUBY_ARCHIVE = VERSIONS["4.0"].archive + OPENSSL = VERSIONS["4.0"].openssl + INSTALL_BUNDLER = VERSIONS["4.0"].bundler + } + tags = ["kss-test:4.0"] +} diff --git a/lib/kss/section.rb b/lib/kss/section.rb index b042404..af9eb3b 100644 --- a/lib/kss/section.rb +++ b/lib/kss/section.rb @@ -18,6 +18,7 @@ class Section def initialize(comment_text=nil, filename=nil) @raw = comment_text @filename = filename + @section = nil end # Splits up the raw comment text into comment sections that represent diff --git a/test-all-rubies.sh b/test-all-rubies.sh new file mode 100755 index 0000000..593ca7b --- /dev/null +++ b/test-all-rubies.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +echo "Building all Ruby versions..." +docker buildx bake + +failed="" +for tag in 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; do + echo "" + echo "=== Ruby $tag ===" + if docker run --rm "kss-test:$tag"; then + echo "--- Ruby $tag: PASS ---" + else + echo "--- Ruby $tag: FAIL ---" + failed="$failed $tag" + fi +done + +echo "" +if [ -n "$failed" ]; then + echo "FAILED:$failed" + exit 1 +else + echo "All versions passed." +fi From d05778de90c0ce878fa06a64ae5e6c44b5724408 Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:46:28 -0800 Subject: [PATCH 2/5] Replace removed exists? with exist? for Ruby 3.2+ compat --- lib/kss/comment_parser.rb | 2 +- lib/kss/parser.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kss/comment_parser.rb b/lib/kss/comment_parser.rb index 09bba5b..08607b2 100644 --- a/lib/kss/comment_parser.rb +++ b/lib/kss/comment_parser.rb @@ -66,7 +66,7 @@ def self.parse_multi_line(line) def initialize(file_path_or_string_input, options={}) @options = options @options[:preserve_whitespace] = false if @options[:preserve_whitespace].nil? - if File.exists?(file_path_or_string_input) + if File.exist?(file_path_or_string_input) @file_path = file_path_or_string_input else @string_input = file_path_or_string_input diff --git a/lib/kss/parser.rb b/lib/kss/parser.rb index 25f51c0..ddf3491 100644 --- a/lib/kss/parser.rb +++ b/lib/kss/parser.rb @@ -16,7 +16,7 @@ def initialize(*paths_or_strings) @sections = {} paths_or_strings.each do |path_or_string| - if Dir.exists?(path_or_string) + if Dir.exist?(path_or_string) # argument is a path path = path_or_string Dir["#{path}/**/*.{css,less,sass,scss,erb}"].each do |filename| From cfac1bb730c52e31d1c7e0746b359080e538e7e2 Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Mon, 2 Mar 2026 10:48:49 -0800 Subject: [PATCH 3/5] Add GitHub Actions CI, ruby-head target, fix warnings - GHA workflow: 16-version Docker matrix + gate job - Dockerfile.head: build Ruby from git (bookworm + baseruby) - docker-bake.hcl: add ruby-head target - Bundle cache mount in Dockerfiles - Fix test bug: unused var + frozen string mutation - Fix uninitialized @file_path/@string_input ivars - Bump minitest for 3.4+ (object_id warning) - Remove dead deps: mg, rubyforge, has_rdoc - Parallelize test-all-rubies.sh via GNU parallel - Expand .dockerignore, delete .travis.yml --- .dockerignore | 11 ++++++++ .github/workflows/test.yml | 54 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 5 ---- Dockerfile | 7 ++++- Dockerfile.head | 31 ++++++++++++++++++++++ Gemfile | 10 ++++--- Rakefile | 20 -------------- docker-bake.hcl | 7 +++++ kss.gemspec | 1 - lib/kss/comment_parser.rb | 2 ++ test-all-rubies.sh | 22 +++------------- test/section_test.rb | 4 +-- 12 files changed, 124 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml create mode 100644 Dockerfile.head diff --git a/.dockerignore b/.dockerignore index b844b14..db8b31a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,12 @@ +.bundle +.git +.github +Dockerfile* Gemfile.lock +Knylefile +LICENSE +README.md +SPEC.md +docker-bake.hcl +example +test-all-rubies.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9c790ed --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,54 @@ +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 + include: + - 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 "kss-test:${{ matrix.ruby }}" + + gate: + name: All Tests + needs: [test] + if: always() + runs-on: ubuntu-slim + steps: + - if: ${{ !success() }} + run: exit 1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f5422dc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: ruby -rvm: - - 2.0.0 - - 1.9.3 - diff --git a/Dockerfile b/Dockerfile index 860215b..9694506 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,5 +53,10 @@ RUN if [ -n "$INSTALL_BUNDLER" ]; then \ WORKDIR /app COPY . . -RUN bundle install --jobs $(nproc) +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"] diff --git a/Dockerfile.head b/Dockerfile.head new file mode 100644 index 0000000..e1992c3 --- /dev/null +++ b/Dockerfile.head @@ -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"] diff --git a/Gemfile b/Gemfile index bec092f..8d0f718 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,20 @@ 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" end group :development do - gem "mg", ">= 0.0.8" if RUBY_VERSION < "2.3" gem "rake", "~> 12.0" else gem "rake", "~> 13.0" end - gem "rubyforge", ">= 2.0.3" end diff --git a/Rakefile b/Rakefile index 856c862..4c3d2c0 100644 --- a/Rakefile +++ b/Rakefile @@ -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 \ No newline at end of file diff --git a/docker-bake.hcl b/docker-bake.hcl index 6c93769..9c25144 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -35,6 +35,7 @@ group "default" { "ruby-3-3", "ruby-3-4", "ruby-4-0", + "ruby-head", ] } @@ -222,3 +223,9 @@ target "ruby-4-0" { } tags = ["kss-test:4.0"] } + +target "ruby-head" { + dockerfile = "Dockerfile.head" + context = "." + tags = ["kss-test:head"] +} diff --git a/kss.gemspec b/kss.gemspec index d6fdf88..df276c4 100644 --- a/kss.gemspec +++ b/kss.gemspec @@ -8,7 +8,6 @@ Gem::Specification.new do |s| s.homepage = "http://github.com/kneath/kss" s.email = "kneath@gmail.com" s.authors = [ "Kyle Neath" ] - s.has_rdoc = false s.license = "MIT" s.files = %w( README.md Rakefile LICENSE ) diff --git a/lib/kss/comment_parser.rb b/lib/kss/comment_parser.rb index 08607b2..8e28b13 100644 --- a/lib/kss/comment_parser.rb +++ b/lib/kss/comment_parser.rb @@ -66,6 +66,8 @@ def self.parse_multi_line(line) def initialize(file_path_or_string_input, options={}) @options = options @options[:preserve_whitespace] = false if @options[:preserve_whitespace].nil? + @file_path = nil + @string_input = nil if File.exist?(file_path_or_string_input) @file_path = file_path_or_string_input else diff --git a/test-all-rubies.sh b/test-all-rubies.sh index 593ca7b..c127084 100755 --- a/test-all-rubies.sh +++ b/test-all-rubies.sh @@ -4,22 +4,8 @@ set -e echo "Building all Ruby versions..." docker buildx bake -failed="" -for tag in 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; do - echo "" - echo "=== Ruby $tag ===" - if docker run --rm "kss-test:$tag"; then - echo "--- Ruby $tag: PASS ---" - else - echo "--- Ruby $tag: FAIL ---" - failed="$failed $tag" - fi -done - echo "" -if [ -n "$failed" ]; then - echo "FAILED:$failed" - exit 1 -else - echo "All versions passed." -fi +echo "Running tests..." +parallel --will-cite --tag --tagstring "Ruby {}" --line-buffer \ + docker run --rm "kss-test:{}" \ + ::: 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 diff --git a/test/section_test.rb b/test/section_test.rb index 29e4138..ae0e4ee 100644 --- a/test/section_test.rb +++ b/test/section_test.rb @@ -40,8 +40,8 @@ def setup end test "parses word phrases as styleguide references" do - @comment_text.gsub!('2.1.1', 'Buttons - Truly Lime') - section = Kss::Section.new(@comment_text, 'example.css') + text = @comment_text.gsub('2.1.1', 'Buttons - Truly Lime') + @section = Kss::Section.new(text, 'example.css') assert_equal 'Buttons - Truly Lime', @section.section end From 3c28ba2ed5c80f28e9d14c7bef8731fe5ee1e86b Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Mon, 2 Mar 2026 12:19:27 -0800 Subject: [PATCH 4/5] Add SimpleCov coverage gated on COVERAGE env, CI enables for Ruby 4.0 only --- .dockerignore | 1 + .github/workflows/test.yml | 5 ++++- .gitignore | 3 ++- Gemfile | 1 + test/helper.rb | 8 ++++++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index db8b31a..d681be2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,3 +10,4 @@ SPEC.md docker-bake.hcl example test-all-rubies.sh +coverage/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c790ed..7736f5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,10 @@ jobs: - "3.4" - "4.0" - head + coverage: [0] include: + - ruby: "4.0" + coverage: 1 - ruby: head allow_failure: true steps: @@ -42,7 +45,7 @@ jobs: env: RUBY: ${{ matrix.ruby }} - name: Test - run: docker run --rm "kss-test:${{ matrix.ruby }}" + run: docker run --rm -e COVERAGE=${{ matrix.coverage }} "kss-test:${{ matrix.ruby }}" gate: name: All Tests diff --git a/.gitignore b/.gitignore index b876770..190c1e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .bundle Gemfile.lock bin -.sass-cache \ No newline at end of file +.sass-cache +coverage/ \ No newline at end of file diff --git a/Gemfile b/Gemfile index 8d0f718..7de125a 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ group :test do 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 diff --git a/test/helper.rb b/test/helper.rb index b1f41d8..3469b1d 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,3 +1,11 @@ +if ENV["COVERAGE"] + require "simplecov" + SimpleCov.start do + enable_coverage :branch + add_filter "/test/" + end +end + require 'minitest/autorun' require 'kss' From 870e5b08c05688941c689cb03e1287a19efd74bb Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Mon, 2 Mar 2026 12:57:58 -0800 Subject: [PATCH 5/5] Fix Bundler 1.x/2.x compat in Dockerfile, gate coverage on COVERAGE=1 --- Dockerfile | 8 +++++--- test-all-rubies.sh | 7 ++++--- test/helper.rb | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9694506..741aee7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,9 +54,11 @@ WORKDIR /app COPY . . RUN --mount=type=cache,target=/bundle-cache \ - bundle config set --local path /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 + && 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"] diff --git a/test-all-rubies.sh b/test-all-rubies.sh index c127084..8eee57a 100755 --- a/test-all-rubies.sh +++ b/test-all-rubies.sh @@ -6,6 +6,7 @@ docker buildx bake echo "" echo "Running tests..." -parallel --will-cite --tag --tagstring "Ruby {}" --line-buffer \ - docker run --rm "kss-test:{}" \ - ::: 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 +parallel --will-cite --tag --tagstring "Ruby {1}" --line-buffer \ + docker run --rm -e COVERAGE={2} "kss-test:{1}" \ + ::: 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 \ + :::+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 diff --git a/test/helper.rb b/test/helper.rb index 3469b1d..b619f3b 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,4 +1,4 @@ -if ENV["COVERAGE"] +if ENV["COVERAGE"] == "1" require "simplecov" SimpleCov.start do enable_coverage :branch