Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the minimum supported version of Ruby from 2.7.x to 3.0.x #27

Closed
wants to merge 8 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
name: CI Build
name: Continuous Integration

on:
push:
branches:
- main
branches: [main]

pull_request:
branches: [ main ]
branches: [main]

# The default triggers for pull requests are opened, synchronize, and reopened.
# Add labeled and unlabeled to the list of triggers so that the
# check_for_semver_pr_label job is run when a label is added or removed from a
# pull request.

types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
check_for_semver_pr_label:
runs-on: ubuntu-latest

steps:
- name: Check that a semver label is present on the PR
if: github.event_name == 'pull_request'
uses: docker://agilepathway/pull-request-label-checker:latest
with:
one_of: major,minor,patch,trivial
repo_token: ${{ secrets.GITHUB_TOKEN }}

build:
continue-on-error: true
needs: [check_for_semver_pr_label]

strategy:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1', '3.2', 'head', 'jruby-head', 'truffleruby-head']
ruby:
["3.0", "3.1", "3.2", "3.3", "head", "jruby-head", "truffleruby-head"]
operating-system: [ubuntu-latest]
include:
- ruby: 3.1
- ruby: 3.0
operating-system: windows-latest
- ruby: 3.3
operating-system: windows-latest
# - ruby: jruby-head
# operating-system: windows-latest
Expand All @@ -43,7 +64,7 @@ jobs:
run: bundle exec rake

coverage:
needs: [ build ]
needs: [build]
runs-on: ubuntu-latest

name: Report test coverage to CodeClimate
Expand All @@ -55,7 +76,7 @@ jobs:
- name: Initialize Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.3
bundler-cache: true

- name: Run tests
Expand All @@ -66,4 +87,4 @@ jobs:
env:
CC_TEST_REPORTER_ID: d3bf532dce7cc5d9ae5ae10efd7708d8465d3cc6236e5e11377cbef62ed2b32f
with:
coverageLocations: ${{github.workspace}}/coverage/lcov/*.lcov:lcov
coverageLocations: ${{github.workspace}}/coverage/lcov/*.lcov:lcov
18 changes: 17 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ AllCops:
SuggestExtensions: false
# RuboCop enforces rules depending on the oldest version of Ruby which
# your project supports:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.0

Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec

# The default max line length is 80 characters
Layout/LineLength:
Expand All @@ -16,5 +19,18 @@ Layout/LineLength:
# The DSL for RSpec and the gemspec file make it very hard to limit block length:
Metrics/BlockLength:
Exclude:
- "spec/spec_helper.rb"
- "spec/**/*_spec.rb"
- "*.gemspec"

Metrics/ModuleLength:
CountAsOne: ['hash']

# When writing minitest tests, it is very hard to limit test class length:
Metrics/ClassLength:
CountAsOne: ['hash']
Exclude:
- "test/**/*_test.rb"

Style/AsciiComments:
Enabled: false
62 changes: 57 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/0b5c67e5c2a773009cd0/maintainability)](https://codeclimate.com/github/main-branch/process_executer/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/0b5c67e5c2a773009cd0/test_coverage)](https://codeclimate.com/github/main-branch/process_executer/test_coverage)

* [Features](#features)
* [ProcessExecuter::MonitoredPipe](#processexecutermonitoredpipe)
* [ProcessExecuter.spawn](#processexecuterspawn)
* [Installation](#installation)
* [Usage](#usage)
* [Development](#development)
* [Releasing](#releasing)
* [Determine Semver increment](#determine-semver-increment)
* [Contributing](#contributing)
* [License](#license)

## Features

[Full YARD documentation](https://rubydoc.info/gems/process_executer/) for this
Expand Down Expand Up @@ -92,11 +103,52 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
`rake spec` to run the tests. You can also run `bin/console` for an interactive
prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To
release a new version, update the version number in `version.rb`, and then run
`bundle exec rake release`, which will create a git tag for the version, push git
commits and the created tag, and push the `.gem` file to
[rubygems.org](https://rubygems.org).
To install this gem onto your local machine, run `bundle exec rake install`.

## Releasing

To release a new version, first determine the proper semver increment based on the
type of changes made in the release as described in [Determine Semver
increment](#determine-semver-increment).

In the root directory of the project with the `main` branch checked out, run the
following command:

```shell
create-github-release {major|minor|patch}`
```

Follow the directions given by the `create-github-release` to publish the new version
of the gem.

## Determine Semver increment

When creating a new release, determine the semver increment according to the following
rules.

* `major`: When making incompatible API changes, increment the MAJOR version.

This typically occurs when the changes introduced would break existing code that
depends on this gem. For example, removing a public method, changing a method's
signature, or altering the expected behavior of a method in a way that would
require changes in the dependent code.

* `minor`: When adding functionality in a backward-compatible manner, increment the
MINOR version.

This includes adding new features, enhancements, or deprecating existing features
(as long as the deprecation itself doesn't break compatibility).

It's also common to include substantial improvements or optimizations in this
category, as long as they don't alter the expected behavior of the existing API.

* `patch`: When making backward-compatible bug fixes, increment the PATCH version.

This is for small changes that fix issues without adding new functionality or
altering existing functionality (beyond the scope of fixing a bug).

It can also include internal changes that don't affect the API, like refactoring
code, improving performance, or updating documentation.

## Contributing

Expand Down
4 changes: 0 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ end
CLEAN << 'pkg'
CLOBBER << 'Gemfile.lock'

# Bump

require 'bump/tasks'

# RSpec

require 'rspec/core/rake_task'
Expand Down
19 changes: 8 additions & 11 deletions process_executer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.description = 'An API for executing commands in a subprocess'
spec.homepage = 'https://github.com/main-branch/process_executer'
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.7.0'
spec.required_ruby_version = '>= 3.0.0'

spec.metadata['allowed_push_host'] = 'https://rubygems.org'

Expand All @@ -31,20 +31,17 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
spec.add_development_dependency 'bump', '~> 0.10'
spec.add_development_dependency 'bundler-audit', '~> 0.9'
spec.add_development_dependency 'create_github_release', '~> 1.0'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'rubocop', '~> 1.36'
spec.add_development_dependency 'simplecov', '~> 0.21'
spec.add_development_dependency 'create_github_release', '~> 1.1'
spec.add_development_dependency 'rake', '~> 13.1'
spec.add_development_dependency 'rspec', '~> 3.12'
spec.add_development_dependency 'rubocop', '~> 1.59'
spec.add_development_dependency 'semverify', '~> 0.3'
spec.add_development_dependency 'simplecov', '~> 0.22'
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
spec.add_development_dependency 'solargraph', '~> 0.47'

unless RUBY_PLATFORM == 'java'
spec.add_development_dependency 'redcarpet', '~> 3.5'
spec.add_development_dependency 'redcarpet', '~> 3.6'
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28'
spec.add_development_dependency 'yardstick', '~> 0.9'
end
Expand Down
52 changes: 36 additions & 16 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,61 @@

SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::LcovFormatter]

# Fail the rspec run if code coverage falls below the configured threshold
# Report if the test coverage was below the configured threshold
#
# Skip this check if the NOCOV environment variable is set to TRUE
# The threshold is configured by setting the `test_coverage_threshold` variable
# in this file.
#
# Example:
#
# ```Ruby
# test_coverage_threshold = 100
# ```
#
# Coverage below the threshold will cause the rspec run to fail unless the
# `COV_NO_FAIL` environment variable is set to TRUE.
#
# ```Shell
# NOCOV=TRUE rspec
# COV_NO_FAIL=TRUE rspec
# ```
#
# Example of running the tests in an infinite loop writing failures to `fail.txt`:
#
# ```Shell
# while true; do
# NOCOV=TRUE rspec spec/process_executer/monitored_pipe_spec.rb | sed -n '/^Failures:$/, /^Finished /p' >> fail.txt
# done
# while true; do COV_NO_FAIL=TRUE rspec >> fail.txt; done
# ````
#
# The lines missing coverage will be displayed if the `COV_SHOW_UNCOVERED`
# environment variable is set to TRUE.
#
# ```Shell
# COV_SHOW_UNCOVERED=TRUE rspec
# ```
#
test_coverage_threshold = 100
SimpleCov.at_exit do
unless RSpec.configuration.dry_run?
SimpleCov.result.format!

if ENV['NOCOV'] != 'TRUE' && SimpleCov.result.covered_percent < test_coverage_threshold
warn "FAIL: RSpec Test coverage fell below #{test_coverage_threshold}%"
SimpleCov.at_exit do
SimpleCov.result.format!
# rubocop:disable Style/StderrPuts
if SimpleCov.result.covered_percent < test_coverage_threshold
$stderr.puts
$stderr.print 'FAIL: ' if fail_on_low_coverage?
$stderr.puts "RSpec Test coverage fell below #{test_coverage_threshold}%"

warn "\nThe following lines were not covered by tests:\n"
if show_lines_not_covered?
$stderr.puts "\nThe following lines were not covered by tests:\n"
SimpleCov.result.files.each do |source_file| # SimpleCov::SourceFile
source_file.missed_lines.each do |line| # SimpleCov::SourceFile::Line
puts " #{source_file.project_filename}:#{line.number}"
$stderr.puts " .#{source_file.project_filename}:#{line.number}"
end
end
warn "\n"

exit 1
end

$stderr.puts

exit 1 if fail_on_low_coverage?
end
# rubocop:enable Style/StderrPuts
end

SimpleCov.start
Expand Down