Skip to content
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
52 changes: 52 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Generate Documentation

on:
push:
branches: [ main, master ]
paths:
- 'lib/**/*.rb'
- 'README.md'
- 'CHANGELOG.md'
- '.yardopts'
pull_request:
branches: [ main, master ]
paths:
- 'lib/**/*.rb'
- 'README.md'
- 'CHANGELOG.md'
- '.yardopts'

jobs:
docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

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

- name: Install dependencies
run: bundle install

- name: Generate documentation
run: bundle exec yard doc

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
destination_dir: .

- name: Upload documentation artifacts
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/
retention-days: 5
130 changes: 119 additions & 11 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,136 @@
name: Ruby
name: CI/CD Pipeline

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

permissions:
contents: read

jobs:
test:

runs-on: ubuntu-latest
name: "Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
ruby-version: ['3.0', '3.1']
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
os: [ubuntu-latest]
include:
# Test on macOS for the latest Ruby version
- ruby-version: '3.3'
os: macos-latest
# Test on Windows for the latest Ruby version
- ruby-version: '3.3'
os: windows-latest

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
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
bundler-cache: true

- name: Run linter
run: bundle exec rubocop
continue-on-error: ${{ matrix.ruby-version == '2.7' }}

- name: Run tests with coverage
run: bundle exec rspec --require spec_helper
env:
CI: true

- name: Upload coverage to Codecov
if: matrix.ruby-version == '3.3' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
file: ./coverage/lcov/lcov.info
flags: unittests
name: codecov-umbrella

security:
name: Security Audit
runs-on: ubuntu-latest

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

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Security audit dependencies
run: |
if bundle exec bundler-audit --version > /dev/null 2>&1; then
bundle exec bundler-audit --update
else
echo "Bundler-audit not available in bundle, skipping dependency security audit"
fi

- name: Security audit code
run: |
if bundle exec brakeman --version > /dev/null 2>&1; then
bundle exec brakeman --quiet --no-pager || true
else
echo "Brakeman not available in bundle, skipping code security audit"
fi

performance:
name: Performance Regression Test
runs-on: ubuntu-latest

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

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Run performance benchmarks
run: |
bundle exec ruby benchmark_comparison.rb > performance_results.txt
cat performance_results.txt

- name: Upload performance results
uses: actions/upload-artifact@v4
with:
name: performance-results
path: performance_results.txt
retention-days: 30

quality:
name: Code Quality Analysis
runs-on: ubuntu-latest

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

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Generate documentation
run: bundle exec yard doc

- name: Check documentation coverage
run: |
echo "Documentation coverage:"
bundle exec yard stats --list-undoc

- name: Run performance tests
run: bundle exec rspec spec/performance_spec.rb --format documentation
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/_yardoc/
/coverage/
/doc/
/docs/
/pkg/
/spec/reports/
/tmp/
Expand Down
110 changes: 110 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
plugins:
- rubocop-performance
- rubocop-rake

require:
- rubocop-rspec

AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
ExtraDetails: true
NewCops: enable
TargetRubyVersion: 2.7 # Support from Ruby 2.7+
Exclude:
- 'vendor/**/*'
- 'coverage/**/*'
- 'docs/**/*'

# DISABLE BROKEN COPS in RuboCop 1.77.0
Capybara/RSpec/PredicateMatcher:
Enabled: false

# Disable Gemspec cops (we keep deps in gemspec for compatibility)
Gemspec/RequiredRubyVersion:
Enabled: false
Gemspec/DuplicatedAssignment:
Enabled: false
Gemspec/DevelopmentDependencies:
Enabled: false
Gemspec/RubyVersionGlobalsUsage:
Enabled: false

# Limity długości linii
Layout/LineLength:
Max: 120
AllowedPatterns: ['^\\s*# ', '^\\s*#+', '^\\s*it .* do$']

# Długość metod
Metrics/MethodLength:
Max: 30
CountAsOne: ['array', 'hash', 'heredoc']

# Złożoność metod
Metrics/AbcSize:
Max: 30 # Increase for complex algorithms

# Cyklomatyczna złożoność
Metrics/CyclomaticComplexity:
Max: 10

# Długość klasy
Metrics/ClassLength:
Max: 300

# Module length
Metrics/ModuleLength:
Max: 200 # Allow larger modules for readability formulas

# Dokumentacja
Style/Documentation:
Enabled: false

# Frozen string literal
Style/FrozenStringLiteralComment:
Enabled: false

# Numerowane parametry
Naming/MethodParameterName:
MinNameLength: 1 # Allow single-letter params like 'n'

# Boolean parameters
Style/OptionalBooleanParameter:
Enabled: false # Allow boolean defaults for gem compatibility

# Trivial accessors
Style/TrivialAccessors:
Enabled: false # Allow custom setters with logic

# RSpec configuration
RSpec/ExampleLength:
Max: 50 # Allow longer examples for integration tests

RSpec/MultipleExpectations:
Max: 20 # Allow more expectations for complex tests

RSpec/LeakyConstantDeclaration:
Enabled: false # Allow constants in specs

RSpec/DescribeClass:
Enabled: false # Allow string descriptions

RSpec/ContextWording:
Enabled: false # Allow flexible context names

RSpec/FilePath:
Enabled: false # Allow textstat_spec.rb naming

RSpec/SpecFilePathFormat:
Enabled: false # Allow textstat_spec.rb naming

RSpec/InstanceVariable:
Enabled: false # Allow @long_test in legacy specs

RSpec/BeEql:
Enabled: false # Allow eql for precise numeric comparisons

# Disable problematic constants-in-block warnings for specs
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/**/*'
19 changes: 19 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--markup-provider=redcarpet
--markup=markdown
--title="TextStat - Ruby Text Readability Analysis"
--readme=README.md
--files=CHANGELOG.md,LICENSE.txt
--exclude=spec/
--exclude=benchmark_comparison.rb
--exclude=lib/counter.rb
--output-dir=docs
--private
--protected
--no-private
--embed-mixins
--list-undoc
--line-numbers
lib/**/*.rb
-
CHANGELOG.md
LICENSE.txt
Loading