Skip to content

Commit

Permalink
Merge pull request #3 from bartkamphorst/add-gh-actions
Browse files Browse the repository at this point in the history
Create github actions workflow for CI using ruby 2.7.
Update bundler to ~> 2.0.
Replace ::File.exists? (plural) with ::File.exist? (singular).
  • Loading branch information
bartkamphorst committed Aug 8, 2023
2 parents 3f6127c + 38322f4 commit 5ee9993
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 18 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7']

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
- name: Coveralls
uses: coverallsapp/github-action@v2
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
source 'https://rubygems.org'

gem 'simplecov', :require => false, :group => :test
gem 'coveralls', :require => false, :group => :test

# Specify your gem's dependencies in tarchiver.gemspec
gemspec
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/bartkamphorst/tarchiver.svg?branch=master)](https://travis-ci.org/bartkamphorst/tarchiver)
[![Coverage Status](https://coveralls.io/repos/bartkamphorst/tarchiver/badge.svg?branch=master&service=github)](https://coveralls.io/github/bartkamphorst/tarchiver?branch=master)
[![Build Status](https://github.com/bartkamphorst/tarchiver/actions/workflows/ruby.yml/badge.svg)](https://github.com/bartkamphorst/tarchiver/actions/workflows/ruby.yml)
[![Coverage Status](https://coveralls.io/repos/github/bartkamphorst/tarchiver/badge.svg)](https://coveralls.io/github/bartkamphorst/tarchiver)
[![Gem Version](https://badge.fury.io/rb/tarchiver.png)](http://badge.fury.io/rb/tarchiver)

# Tarchiver
Expand Down
6 changes: 3 additions & 3 deletions lib/tarchiver/archiver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def self.archive(archive_input, output_directory='.', opts={})
puts messages[:completed_archiving] if options[:verbose]

# Return
::File.exists?(compressed_archive_path) ? compressed_archive_path : Tarchiver::Helpers.terminate(nil, options)
::File.exist?(compressed_archive_path) ? compressed_archive_path : Tarchiver::Helpers.terminate(nil, options)
end # archive

def self.unarchive(archive, output_directory='.', opts={})
Expand Down Expand Up @@ -76,7 +76,7 @@ def self.unarchive(archive, output_directory='.', opts={})
end
end
end
::File.delete(archive) if ::File.exists?(archive) && options[:delete_input_on_success]
::File.delete(archive) if ::File.exist?(archive) && options[:delete_input_on_success]
output_directory
rescue => error
puts "#{messages[:failed_archiving]}\n#{error.message}" if options[:verbose]
Expand All @@ -86,4 +86,4 @@ def self.unarchive(archive, output_directory='.', opts={})

end # Archiver

end # Tarchiver
end # Tarchiver
4 changes: 2 additions & 2 deletions lib/tarchiver/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def self.determine_archive_type(archive)
end

def self.cleanup(archive_input, tar_path, options)
::File.delete(tar_path) if tar_path && ::File.exists?(tar_path)
::File.delete(tar_path) if tar_path && ::File.exist?(tar_path)
FileUtils.rm_rf(archive_input) if options[:delete_input_on_success]
end

Expand All @@ -64,4 +64,4 @@ def self.terminate(error=nil, options)
end

end # Helpers
end # Tarchiver
end # Tarchiver
10 changes: 5 additions & 5 deletions spec/archiver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
opts = options.merge({delete_input_on_success: true})
dir = archive_dir
archive_path = Tarchiver::Archiver.archive(dir, @tmp_dir, opts)
expect(::File.exists?(dir)).to be false
expect(::File.exist?(dir)).to be false
end

end
Expand Down Expand Up @@ -155,16 +155,16 @@
it 'cleans up the tarball' do
archive_path = Tarchiver::Archiver.archive(archive_dir, @tmp_dir, default_options)
tar_path = ::File.join(::File.dirname(archive_path), 'test_dir.tar')
expect(::File.exists?(tar_path)).to be false
expect(::File.exist?(tar_path)).to be false
end

it 'cleans up everything' do
opts = default_options.merge({delete_input_on_success: true})
dir = archive_dir
archive_path = Tarchiver::Archiver.archive(dir, @tmp_dir, opts)
tar_path = ::File.join(File.dirname(archive_path), 'test_dir.tar')
expect(::File.exists?(dir)).to be false
expect(::File.exists?(tar_path)).to be false
expect(::File.exist?(dir)).to be false
expect(::File.exist?(tar_path)).to be false
end

end
Expand Down Expand Up @@ -224,4 +224,4 @@
FileUtils.remove_entry_secure(@tmp_dir)
end

end
end
5 changes: 1 addition & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
require 'simplecov'
SimpleCov.start

require 'coveralls'
Coveralls.wear!

require 'tarchiver'
require 'tmpdir'

def inspect_archive(archive_path)
Gem::Package::TarReader.new(File.open(archive_path)) { |tar| return tar.map(&:full_name) }
end
end
2 changes: 1 addition & 1 deletion tarchiver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", ">= 12.3.3"
spec.add_development_dependency "rspec"

Expand Down

0 comments on commit 5ee9993

Please sign in to comment.