Skip to content

Commit

Permalink
Update project to new build and documentation standards (#22)
Browse files Browse the repository at this point in the history
* Add CI build with Github Actions

* Add a Github codeowners file

* Update dependencies

* Update rubocop configuration

* Fix new Rubocop offenses

* Use semverify instead of bump

* Update Rakefile to standard for my projects

* Update spec_helper to standard for my projects

* Update YARD documentation to new standards

* Update README.md project badges

* Document the arg passed to the initialization block

* Remove bundler as a direct dev dependency
  • Loading branch information
jcouball committed Dec 11, 2023
1 parent dbedfe6 commit 9c7e76e
Show file tree
Hide file tree
Showing 10 changed files with 510 additions and 170 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1,4 @@
# Defines who must review pull requests.
# See https://help.github.com/articles/about-codeowners/ for details.

* @jcouball @main-branch/github_pages_rake_tasks-codeowners
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
@@ -0,0 +1,64 @@
name: CI Build

on:
push:
branches: [ main ]

pull_request:
branches: [ main ]

jobs:
build:
continue-on-error: true

strategy:
matrix:
ruby: ['3.0', '3.2', head, jruby-head]
operating-system: [ubuntu-latest]
include:
- ruby: '3.0'
operating-system: windows-latest
- ruby: jruby-head
operating-system: windows-latest

name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run rake
run: bundle exec rake

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

name: Report test coverage to CodeClimate

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true

- name: Run tests
run: bundle exec rake spec

- name: Report test coverage
uses: paambaati/codeclimate-action@v3.2.0
env:
CC_TEST_REPORTER_ID: 997ddf9df5b99897b448d7a7a13e332d57f0e29754d9b9d1414aaee611759422
with:
coverageLocations: ${{github.workspace}}/coverage/lcov/*.lcov:lcov
28 changes: 23 additions & 5 deletions .rubocop.yml
@@ -1,22 +1,40 @@
AllCops:
NewCops: enable
# Output extra information for each offense to make it easier to diagnose:
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
# Rubocop enforces rules depending on the oldest version of Ruby which
SuggestExtensions: false
# RuboCop enforces rules depending on the oldest version of Ruby which
# your project supports:
TargetRubyVersion: 2.5
TargetRubyVersion: 3.0

# The default max line length for this project
Metrics/LineLength:
Max: 100
Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec

# The default max line length is 80 characters
Layout/LineLength:
Max: 120

# 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

# All Ruby files are required to have a Copyright notice.
# Run `rubocop -a` to automatically add missing copyright notices.
Style/Copyright:
Expand Down
29 changes: 20 additions & 9 deletions README.md
@@ -1,9 +1,11 @@
# Publish Documentation to GitHub Pages

[![Gem Version](https://badge.fury.io/rb/github_pages_rake_tasks.svg)](https://badge.fury.io/rb/github_pages_rake_tasks)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/jcouball/github_pages_rake_tasks.svg?branch=master)](https://travis-ci.com/jcouball/github_pages_rake_tasks)
[![Documentation](https://img.shields.io/badge/Documentation-OK-green.svg)](https://jcouball.github.io/github_pages_rake_tasks/)
[![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/github_pages_rake_tasks/)
[![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/github_pages_rake_tasks/file/CHANGELOG.md)
[![Build Status](https://github.com/main-branch/github_pages_rake_tasks/workflows/CI%20Build/badge.svg?branch=main)](https://github.com/main-branch/github_pages_rake_tasks/actions?query=workflow%3ACI%20Build)
[![Maintainability](https://api.codeclimate.com/v1/badges/a67ad0b61d3687e33181/maintainability)](https://codeclimate.com/github/main-branch/github_pages_rake_tasks/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/a67ad0b61d3687e33181/test_coverage)](https://codeclimate.com/github/main-branch/github_pages_rake_tasks/test_coverage)

The `github_pages_rake_tasks` gem creates a rake task that pushes files
from a local documentation directory to a remote Git repository branch.
Expand All @@ -20,15 +22,21 @@ This task is useful for publishing `rdoc` or `yard` documentation using

Add this line to your application's Gemfile:

gem 'github_pages_rake_tasks'
```Shell
gem 'github_pages_rake_tasks'
```

And then execute:

$ bundle
```Shell
bundle
```

Or install it directly with the `gem` command line:

$ gem install github_pages_rake_tasks
```Shell
gem install github_pages_rake_tasks
```

## Usage

Expand All @@ -50,15 +58,18 @@ GitHubPagesRakeTasks::PublishTask.new do |task|
end
```

An instance of [GithubPagesRakeTasks::State](https://rubydoc.info/gems/github_pages_rake_tasks/GithubPagesRakeTasks/State)
is passed to the initialization block (named `task` in the example above).

See [the full usage documentation](https://github.com/pages/jcouball/guthub_pages_rake_tasks) for more details.

## Development

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
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing
Expand Down
91 changes: 68 additions & 23 deletions Rakefile
@@ -1,41 +1,86 @@
# Copyright (c) 2019 James Couball
# frozen_string_literal: true

require 'bundler/gem_tasks'
CLOBBER << 'Gemfile.lock'
desc 'Run the same tasks that the CI build will run'
if RUBY_PLATFORM == 'java'
task default: %w[spec rubocop bundle:audit build]
else
task default: %w[spec rubocop yard yard:audit yard:coverage bundle:audit build]
end

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
CLEAN << '.rspec_status'
CLEAN << 'coverage'
# Bundler Audit

require 'bundler/audit/task'
Bundler::Audit::Task.new

require 'bump/tasks'
# Bundler Gem Build

require 'bundler'
require 'bundler/gem_tasks'

begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end

CLEAN << 'pkg'
CLEAN << 'Gemfile.lock'

# RSpec

require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new do
if RUBY_PLATFORM == 'java'
ENV['JAVA_OPTS'] = '-Djdk.io.File.enableADS=true'
ENV['JRUBY_OPTS'] = '--debug'
ENV['NOCOV'] = 'TRUE'
end
end

CLEAN << 'coverage'
CLEAN << '.rspec_status'
CLEAN << 'rspec-report.xml'

# Rubocop

require 'rubocop/rake_task'

RuboCop::RakeTask.new do |t|
t.options = %w[--format progress --format json --out rubocop-report.json]
t.options = %w[
--format progress
--format json --out rubocop-report.json
]
end

CLEAN << 'rubocop-report.json'

require 'yard'
YARD::Rake::YardocTask.new
CLEAN << '.yardoc'
CLEAN << 'doc'
unless RUBY_PLATFORM == 'java'
# YARD

require 'yardstick/rake/verify'
require 'yaml'
Yardstick::Rake::Verify.new('yardstick:verify')
require 'yard'
YARD::Rake::YardocTask.new do |t|
t.files = %w[lib/**/*.rb examples/**/*]
end

require 'yardstick/rake/measurement'
Yardstick::Rake::Measurement.new('yardstick:measure')
CLEAN << 'measurements'
CLEAN << '.yardoc'
CLEAN << 'doc'

desc 'Run yardstick to check yard docs'
task :yardstick do
sh "yardstick 'lib/**/*.rb'"
end
# Yardstick

desc 'Run yardstick to show missing YARD doc elements'
task :'yard:audit' do
sh "yardstick 'lib/**/*.rb'"
end

task default: [:spec, 'bundle:audit', :rubocop, :yard, :build]
# Yardstick coverage

require 'yardstick/rake/verify'

Yardstick::Rake::Verify.new(:'yard:coverage') do |verify|
verify.threshold = 100
end
end
29 changes: 14 additions & 15 deletions github_pages_rake_tasks.gemspec
Expand Up @@ -23,14 +23,14 @@ Gem::Specification.new do |spec|

spec.homepage = 'https://github.com/jcouball/github_pages_rake_tasks'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.0.0'

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
spec.metadata['changelog_uri'] = spec.homepage
end
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
spec.metadata['rubygems_mfa_required'] = 'true'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
spec.metadata['changelog_uri'] = spec.homepage

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -41,14 +41,13 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_development_dependency 'bump', '~> 0.8'
spec.add_development_dependency 'bundler', '~> 2.0'
spec.add_development_dependency 'bundler-audit', '~> 0.6'
spec.add_development_dependency 'rake', '~> 12.3'
spec.add_development_dependency 'rspec', '~> 3.8'
spec.add_development_dependency 'rubocop', '~> 0.70'
spec.add_development_dependency 'simplecov', '~> 0.16'
spec.add_development_dependency 'simplecov-lcov', '~> 0.7'
spec.add_development_dependency 'bundler-audit', '~> 0.9'
spec.add_development_dependency 'rake', '~> 13.1'
spec.add_development_dependency 'rspec', '~> 3.12'
spec.add_development_dependency 'rubocop', '~> 1.58'
spec.add_development_dependency 'semverify', '0.3.0'
spec.add_development_dependency 'simplecov', '~> 0.22'
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
spec.add_development_dependency 'yard', '~> 0.9'
spec.add_development_dependency 'yardstick', '~> 0.9'
end
3 changes: 0 additions & 3 deletions lib/github_pages_rake_tasks/interface.rb
Expand Up @@ -70,8 +70,5 @@ def initialize
#
# @return [String] the output of the command
#
def `(cmd)
super
end
end
end

0 comments on commit 9c7e76e

Please sign in to comment.