Skip to content

Commit

Permalink
Build/ruby2.6 (#2)
Browse files Browse the repository at this point in the history
* build: add github actions for testing various ruby versions

* build: alias test rake test as spec

* build: remove Gemfile.lock for bundler 1.17
  • Loading branch information
sh1nj1 authored Aug 14, 2024
1 parent 53b592d commit 9673dfd
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ruby Gem

on: [push, pull_request]

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: [2.6, 2.7, 3.0, 3.1, 3.2, 3.3]

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rake test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
backup-*
.idea
.DS_Store
Gemfile.lock

*.gem

Expand Down
File renamed without changes.
37 changes: 37 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,40 @@ require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task :test => :spec

Rake::Task.tasks.each do |task|
task.enhance(['bundler:symlink_lockfile'])
end

namespace :bundler do
desc "Create a symbolic link from Gemfile.lock_for_bundler2 to Gemfile.lock if current bundler version is >= 2.0"
task :symlink_lockfile do
require 'bundler'

# Get the current Bundler version
current_version = Gem::Version.new(Bundler::VERSION)
required_version = Gem::Version.new('2.0.0')

if current_version >= required_version
lockfile = 'Gemfile.lock'
new_lockfile = 'Gemfile.lock_for_bundler2'

if File.exist?(new_lockfile)
if File.exist?(lockfile) && !File.symlink?(lockfile)
puts "Backing up existing #{lockfile} to #{lockfile}.backup"
File.rename(lockfile, "#{lockfile}.backup")
end

unless File.exist?(lockfile)
puts "Creating symbolic link from #{new_lockfile} to #{lockfile}"
File.symlink(new_lockfile, lockfile)
end
else
puts "#{new_lockfile} does not exist."
end
else
puts "Current Bundler version (#{current_version}) is less than 2.0.0, no changes made."
end
end
end
6 changes: 6 additions & 0 deletions development.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

If you use bundler >= 2.x, you can use Gemlock.file.
to create symlink for bundler 2.x use following command to create symlink for Gemfile.lock

```shell
rake bundler:symlink_lockfile
```

run without install

Expand Down
1 change: 1 addition & 0 deletions mysql_db_tool.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
spec.bindir = "bin"
spec.executables = ["mysql_backup", "mysql_restore", "gen_create_db_user"]
spec.require_paths = ["lib"]
spec.required_ruby_version = ">= 2.6"

spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", "~> 13.0"
Expand Down

0 comments on commit 9673dfd

Please sign in to comment.