Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
quinna-h committed Aug 28, 2024
1 parent 175dd30 commit 0c3aa27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .github/scripts/version_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def update_gem(gem_to_update)
definition = Bundler::Definition.build(gemfile, gemfile_lock, nil)
dependencies = definition.dependencies

latest = Gem.latest_version_for(gem_to_update)
dependencies.each do |dep|
next if gem_to_update != dep.name # only update the gem we chose at random
# puts "Skipping #{dep.name} as it is not #{gem_to_update}"
Expand All @@ -43,13 +44,12 @@ def update_gem(gem_to_update)

puts "Gem Name: #{gem_name}"
puts "Gem Version: #{gem_version}"
puts "Gem Requirments: #{gem_requirements}"
puts "Gem Requirements: #{gem_requirements}"
puts "Gem Platforms: #{gem_platforms}"

latest = Gem.latest_version_for(gem_name)


if gem_requirements.satisfied_by?(latest)
puts "The latest (#{latest}) of #{gem_name} is satisfied by #{gem_requirements}"

bundler_args = ['lock', '--update', gem_name]
# do we have any platforms specified? If so, add them each with --add-platform
bundler_args.concat(dep.platforms.map { |platform| ['--add-platform', platform.to_s] }) if dep.platforms.any?
Expand All @@ -61,6 +61,8 @@ def update_gem(gem_to_update)
# TODO check with Marco/Tony/David for how this came to be as the PR they were added in was a while back and was just an update

puts "Updating #{gem_name} with: #{bundler_args}"
ENV['GEM'] = gem_to_update
puts "GEM=#{ENV['GEM']}"
run_bundler_command(gemfile, bundler_args)
else
puts "The latest (#{latest}) of #{gem_name} is NOT satisfied by #{gem_requirements}"
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/update-gemfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- 'appraisal/**'
- 'gemfiles/**'
workflow_dispatch:


# Ensure obsolete job is cancelled if another commit is pushed to the same branch.
concurrency:
Expand Down Expand Up @@ -52,10 +52,13 @@ jobs:
- name: Run update gemfiles if files changed
if: steps.filter.outputs.gemfile == 'true'
run: ruby .github/scripts/version_updater.rb
run: |
output = $(ruby .github/scripts/version_updater.rb)
echo "GEM=${output#GEM=}" >> $GITHUB_ENV
- name: Commit gemfile changes
if: steps.filter.outputs.gemfile == 'true'
uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a # v4.16.0
with:
commit_message: Update gemfiles/*
branch: "update-${GEM}-latest"

0 comments on commit 0c3aa27

Please sign in to comment.