From b3f6b81dd2c9a6ae401df7c17aa43d4f67bc1d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Sun, 31 May 2026 15:56:38 +0200 Subject: [PATCH 1/2] Use rv to install Rubies. --- Dockerfile | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index c328b89..bda439b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,40 +28,31 @@ RUN apt-get update && apt-get install -y \ ca-certificates \ libjemalloc-dev \ parallel \ + xz-utils \ && rm -rf /var/lib/apt/lists/* -# Install ruby-install once (cached layer) -RUN curl -fsSL https://github.com/postmodern/ruby-install/releases/download/v0.10.1/ruby-install-0.10.1.tar.gz | tar -xzf - \ - && cd ruby-install-0.10.1 \ - && make install \ - && cd .. \ - && rm -rf ruby-install-0.10.1 +# Install rv once (cached layer) +ARG RV_VERSION=0.5.3 +ARG RV_DOWNLOAD_URL=https://github.com/spinel-coop/rv/releases/download/v${RV_VERSION}/rv-x86_64-unknown-linux-gnu.tar.xz + +RUN mkdir -p /tmp/rv-install \ + && curl -fsSL "$RV_DOWNLOAD_URL" | tar -xJ --strip-components=1 -C /tmp/rv-install \ + && install -m 0755 /tmp/rv-install/rv /usr/local/bin/rv \ + && rm -rf /tmp/rv-install # Stage for Ruby 4.0.1 compilation FROM base AS ruby-4-0-1 RUN mkdir -p /opt/rubies && \ - MAKE_OPTS="-j$(nproc)" \ - ruby-install \ - --install-dir /opt/rubies/ruby-4.0.1 \ - --jobs $(nproc) \ - --cleanup \ - ruby 4.0.1 \ - -- --with-jemalloc \ - && /opt/rubies/ruby-4.0.1/bin/gem install bundler --no-document + RV_UPDATE_MODE=none rv ruby install --install-dir /opt/rubies 4.0.1 \ + && rm -f /usr/local/bin/rv # Stage for Ruby 3.4.5 compilation FROM base AS ruby-3-4-5 RUN mkdir -p /opt/rubies && \ - MAKE_OPTS="-j$(nproc)" \ - ruby-install \ - --install-dir /opt/rubies/ruby-3.4.5 \ - --jobs $(nproc) \ - --cleanup \ - ruby 3.4.5 \ - -- --with-jemalloc \ - && /opt/rubies/ruby-3.4.5/bin/gem install bundler --no-document + RV_UPDATE_MODE=none rv ruby install --install-dir /opt/rubies 3.4.5 \ + && rm -f /usr/local/bin/rv # Final stage - copy compiled Rubies FROM base AS final @@ -70,7 +61,8 @@ FROM base AS final RUN git clone https://github.com/shellspec/shellspec.git /tmp/shellspec \ && cd /tmp/shellspec \ && make install PREFIX=/usr/local \ - && rm -rf /tmp/shellspec + && rm -rf /tmp/shellspec \ + && rm -f /usr/local/bin/rv # Copy compiled Ruby installations from parallel stages COPY --from=ruby-4-0-1 /opt/rubies/ruby-4.0.1 /opt/rubies/ruby-4.0.1 From 83d34347671eb44796ddb319f1ea500854e6b4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Sun, 31 May 2026 16:04:19 +0200 Subject: [PATCH 2/2] Build docker in PRs. --- .github/workflows/ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0b03f6..b03f069 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,8 +143,7 @@ jobs: docker-build: name: Build and Push Docker Test Image runs-on: ubuntu-latest - # Only run on pushes to main when Docker files change - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main') permissions: contents: read packages: write @@ -161,18 +160,20 @@ jobs: - 'docker-compose.yml' - name: Log in to GitHub Container Registry - if: steps.changes.outputs.docker == 'true' + if: steps.changes.outputs.docker == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image + - name: Build Docker image if: steps.changes.outputs.docker == 'true' - run: | - docker compose build - docker compose push + run: docker compose build + + - name: Push Docker image + if: steps.changes.outputs.docker == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' + run: docker compose push test-shellspec-linux: name: ShellSpec Tests (Linux)