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
37 changes: 37 additions & 0 deletions .github/actions/check-versions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Check version alignment'
description: 'Verify Ruby and Node versions agree across .ruby-version, .node-version, .tool-versions, and Dockerfile'

runs:
using: 'composite'
steps:
- name: Verify language version alignment
shell: bash
run: |
set -eu

ruby_version=$(tr -d '[:space:]' < .ruby-version)
node_version=$(tr -d '[:space:]' < .node-version)

tool_ruby=$(awk '/^ruby[[:space:]]/ {print $2}' .tool-versions)
tool_node=$(awk '/^nodejs[[:space:]]/ {print $2}' .tool-versions)

dockerfile_ruby=$(awk -F= '/^ARG RUBY_VERSION=/ {print $2}' Dockerfile)

fail=0
check() {
if [ "$2" != "$3" ]; then
echo "::error::$1 mismatch: expected '$2', got '$3'"
fail=1
fi
}

check ".tool-versions ruby vs .ruby-version" "$ruby_version" "$tool_ruby"
check "Dockerfile ARG RUBY_VERSION vs .ruby-version" "$ruby_version" "$dockerfile_ruby"
check ".tool-versions nodejs vs .node-version" "$node_version" "$tool_node"

if [ $fail -ne 0 ]; then
echo "Version alignment failed. Source of truth: .ruby-version and .node-version." >&2
exit 1
fi

echo "Versions aligned: ruby=$ruby_version, node=$node_version"
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Check version alignment
uses: ./.github/actions/check-versions

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9.0
24.15.0
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.5
4.0.3
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruby 3.3.5
node 20.9.0
ruby 4.0.3
nodejs 24.15.0
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.5
# Source of truth for Ruby is .ruby-version. The CI "check-versions" action
# enforces that this ARG default stays aligned with it.
ARG RUBY_VERSION=4.0.3
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
Expand All @@ -21,12 +22,13 @@ FROM base AS build
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential curl git libpq-dev libvips node-gyp pkg-config python-is-python3

# Install JavaScript dependencies
ARG NODE_VERSION=20.9.0
# Install JavaScript dependencies — Node version is read from .node-version
COPY .node-version /tmp/.node-version
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
RUN NODE_VERSION="$(tr -d '[:space:]' < /tmp/.node-version)" && \
curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
rm -rf /tmp/node-build-master
rm -rf /tmp/node-build-master /tmp/.node-version

# Install application gems
COPY Gemfile Gemfile.lock ./
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
source 'https://rubygems.org'

ruby '3.3.5'

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.1.1'

Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,5 @@ DEPENDENCIES
tzinfo-data
web-console

RUBY VERSION
ruby 3.3.5p100

BUNDLED WITH
4.0.5
Loading