Skip to content
Merged
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
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
38 changes: 15 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading