Skip to content

Commit 7e2c3a8

Browse files
committed
Use minor version '4.0' for publish/deploy-doc
1 parent 55555a1 commit 7e2c3a8

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

.github/workflows/deploy-doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2020
- uses: ruby/setup-ruby@19a43a6a2428d455dbd1b85344698725179c9d8c # v1.289.0
2121
with:
22-
ruby-version: '3.4.8'
22+
ruby-version: '4.0'
2323
- run: bundle install
2424
- name: Setup Pages
2525
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: ruby/setup-ruby@19a43a6a2428d455dbd1b85344698725179c9d8c # v1.289.0
2424
with:
2525
bundler-cache: true
26-
ruby-version: 3.4.8
26+
ruby-version: '4.0'
2727
- name: Update version file with the release version
2828
run: |
2929
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require 'yaml'
2+
3+
RSpec.describe "GitHub Actions workflow Ruby version consistency" do
4+
let(:workflows_dir) { File.expand_path('../../.github/workflows', __dir__) }
5+
6+
let(:latest_matrix_version) do
7+
pr_workflow = YAML.safe_load(
8+
File.read(File.join(workflows_dir, 'pull_request.yml')),
9+
permitted_classes: [Symbol]
10+
)
11+
versions = pr_workflow.dig('jobs', 'build', 'strategy', 'matrix', 'ruby')
12+
expect(versions).not_to be_nil, "No ruby matrix found in pull_request.yml"
13+
versions.map(&:to_s).max_by { |v| Gem::Version.new(v) }
14+
end
15+
16+
let(:hardcoded_ruby_versions) do
17+
versions = {}
18+
19+
Dir[File.join(workflows_dir, '*.yml')].each do |file|
20+
workflow = YAML.safe_load(File.read(file), permitted_classes: [Symbol])
21+
basename = File.basename(file)
22+
23+
next unless workflow['jobs']
24+
25+
workflow['jobs'].each do |job_name, job|
26+
steps = job['steps'] || []
27+
steps.each do |step|
28+
next unless step.is_a?(Hash) && step.dig('with', 'ruby-version')
29+
30+
ruby_version = step['with']['ruby-version'].to_s
31+
next if ruby_version.include?('${{')
32+
33+
versions["#{basename} -> #{job_name}"] = ruby_version
34+
end
35+
end
36+
end
37+
38+
versions
39+
end
40+
41+
it "uses the same Ruby version as the latest in pull_request.yml matrix" do
42+
expect(hardcoded_ruby_versions).not_to be_empty,
43+
"No hardcoded ruby-version found in workflows"
44+
45+
mismatched = hardcoded_ruby_versions.reject { |_, v| v == latest_matrix_version }
46+
expect(mismatched).to be_empty,
47+
"Expected all hardcoded ruby-version to be '#{latest_matrix_version}' " \
48+
"(latest in pull_request.yml matrix), but found:\n" \
49+
"#{mismatched.map { |k, v| " #{k}: #{v}" }.join("\n")}"
50+
end
51+
end

0 commit comments

Comments
 (0)