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

Use GitHub Actions for linting and testing as well as update gemspec #71

Merged
merged 10 commits into from
Mar 9, 2024
Merged
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
3 changes: 2 additions & 1 deletion .document
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
README.rdoc
# Documentation listing for RDoc
README.md
lib/**/*.rb
bin/*
features/**/*.feature
Expand Down
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Top-level setting to indicate this is the root .editorconfig file
root = true

# Default settings for all files
[*]
# Enforce LF (\n) as the line ending across all files for consistency
end_of_line = lf
# Ensure every file ends with a newline
insert_final_newline = true
charset = utf-8
# Use spaces for indentation (as opposed to tabs)
indent_style = space
# Set the width of a single indentation level to 2 spaces
indent_size = 2
trim_trailing_whitespace = true

# Specific settings for Markdown files
[*.md]
# Disable trimming of trailing whitespace in Markdown files,
# important for Markdown syntax where trailing spaces can be meaningful
trim_trailing_whitespace = false
30 changes: 30 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Linting

on:
pull_request:
push:
branches:
- master

permissions:
contents: read

jobs:
linting:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Lint YAML
run: yamllint .

- name: Set up Ruby and install dependencies
uses: ruby/setup-ruby@v1
with:
# uses .ruby-version implicitly
bundler-cache: true

- name: Lint Ruby code
run: bundle exec rubocop
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tests

on:
pull_request:
push:
branches:
- master

permissions:
contents: read

jobs:
tests:
strategy:
matrix:
# test a range of Ruby to ensure gem works
# keep ruby until EOL. Read more on https://endoflife.date/ruby
ruby-version:
- '3.0'
- '3.1'
- '3.2'
- '3.3'
- head
# test distributions up to 4 years
runner:
- ubuntu-22.04
- ubuntu-20.04
fail-fast: false # allow contributors understand failure builds

runs-on: ${{ matrix.runner }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby and install dependencies
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Run tests
run: bundle exec rake spec
19 changes: 3 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
## MAC OS
## macOS
.DS_Store

## TEXTMATE
*.tmproj
tmtags

## EMACS
*~
\#*
.\#*

## VIM
*.swp

## PROJECT::GENERAL
## Project specific
coverage
rdoc
pkg

## PROJECT::SPECIFIC
*.rbc
Gemfile.lock
vendor/
140 changes: 140 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# merge the default 'Exclude' key with ours
inherit_mode:
merge:
- Exclude

require:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe later we can add rubocop-performance

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

- rubocop-rspec
- rubocop-minitest
- rubocop-packaging

AllCops:
NewCops: enable
StyleGuideBaseURL: https://rubystyle.guide
TargetRubyVersion: 3.0
SuggestExtensions: false # reduce noise. consider add rubocop-benchmark

Exclude:
- bin/**/*
- tmp/**/*

Bundler/OrderedGems:
Include:
- '*.gemspec'

# Allow no documentation.
Style/Documentation:
Enabled: false

# Enforce single quotes in the gem
Style/StringLiterals:
Enabled: true
EnforcedStyle: single_quotes
Comment on lines +30 to +32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default, is your intention here to be explicit on these style decisions?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I agree that we should use as many defaults as possible. For some rules that have a large "surface", I would mark them explicitly.


Style/HashSyntax:
EnforcedStyle: no_mixed_keys # consistent hash syntax
EnforcedShorthandSyntax: consistent # enforce explicit hash syntax

# Enforce dots on the next line for multi-line method calls
Layout/DotPosition:
EnforcedStyle: trailing

# Project maximum code line length
Layout/LineLength:
Max: 120
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default value. Recommend removing things that are default to reduce config size.


Layout/FirstArrayElementIndentation:
Enabled: true
EnforcedStyle: consistent

Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented

Style/SymbolArray:
EnforcedStyle: brackets # Prefer brackets

Style/WordArray:
EnforcedStyle: brackets # Prefer brackets

Style/FrozenStringLiteralComment:
Enabled: false

# Exclude test files from BlockComments check
Style/BlockComments:
Exclude:
- 'test/**/*'

Metrics/ClassLength:
Max: 500

Metrics/BlockLength:
Max: 50
Exclude:
# allows longer block for RSpec
- spec/**/*.rb

Metrics/AbcSize:
Max: 110

Metrics/BlockNesting:
Max: 5

Metrics/CyclomaticComplexity:
Max: 40

Metrics/MethodLength:
Max: 100

Metrics/ModuleLength:
Max: 250
Exclude:
# allows longer block for RSpec
- spec/**/*.rb
- lib/ffi-icu/lib.rb

Metrics/PerceivedComplexity:
Max: 50

RSpec/ExampleLength:
Max: 20

RSpec/MultipleExpectations:
Max: 10

RSpec/NestedGroups:
Max: 5

RSpec/FilePath:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false

RSpec/ContextWording:
Enabled: false

RSpec/NamedSubject:
Enabled: false

RSpec/MessageSpies:
Enabled: false

RSpec/NoExpectationExample:
Enabled: false

RSpec/MultipleDescribes:
Enabled: false

RSpec/DescribeClass:
Enabled: false

RSpec/PredicateMatcher:
Enabled: false

Naming/MethodParameterName:
Enabled: false

Naming/FileName:
Exclude:
- lib/ffi-icu.rb
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.3
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
extends: default

locale: en_US.UTF-8

# ignored directories
ignore: |
.git/

rules:
octal-values: enable

document-start: disable
document-end: disable

# allow 120 characters in a line
line-length:
max: 120
level: error

indentation:
spaces: 2
indent-sequences: true

# allow one space indent
comments:
level: error
min-spaces-from-content: 1

# disallow boolean values to avoid surprise
truthy:
level: error

# github workflows uses `on` as trigger
ignore: |
.github/workflows/*.yml
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## [Unreleased](https://github.com/erickguan/ffi-icu/compare/v0.5.3...master) ##

### Added


### Changed

- Required Ruby 3.0 and up.

### Fixed


### Removed

9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
source 'https://rubygems.org'

gemspec

group :development, :test do
gem 'rake', '>= 12.3.3'
gem 'rspec', '~> 3.9'
gem 'rubocop', '~> 1.60'
gem 'rubocop-minitest', '~> 0.34.5'
gem 'rubocop-packaging', '~> 0.5.2'
gem 'rubocop-rspec', '~> 2.27'
end
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2010-2015 Jari Bakken
Copyright (c) 2010-2024 Jari Bakken

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
Loading