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
11 changes: 11 additions & 0 deletions .github/workflows/danger-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Danger Comment

on:
workflow_run:
workflows: [Danger]
types: [completed]

jobs:
comment:
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
secrets: inherit
26 changes: 11 additions & 15 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: PR Linter
on: [pull_request]
name: Danger

on:
pull_request:
types: [opened, reopened, edited, synchronize]

jobs:
danger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: |
# Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
secrets: inherit
with:
ruby-version: '2.7'
bundler-cache: true
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
AllCops:
NewCops: enable
Exclude:
- vendor/**/*

inherit_from: .rubocop_todo.yml

require:
- rubocop-rake
- rubocop-rspec
62 changes: 43 additions & 19 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,63 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-09-13 14:18:39 -0400 using RuboCop version 0.33.0.
# on 2026-01-02 19:41:49 UTC using RuboCop version 1.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 20
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 118

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'mongoid-compatibility.gemspec'

Metrics/BlockLength:
# Offense count: 1
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/mongoid-compatibility.rb'

# Offense count: 4
Style/Documentation:
# Offense count: 1
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'lib/mongoid/compatibility/object_id.rb'
- 'lib/mongoid/compatibility/self.rb'
- 'lib/mongoid/compatibility/version.rb'
- 'spec/mongoid/compatibility/version_spec.rb'

# Offense count: 18
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
- 'spec/mongoid/compatibility/object_id_spec.rb'
- 'spec/mongoid/compatibility/version_spec.rb'

# Offense count: 1
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 13

# Offense count: 1
Style/DoubleNegation:
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
RSpec/FilePath:
Exclude:
- 'lib/mongoid/compatibility/version.rb'
- 'spec/mongoid/compatibility/self_spec.rb'

# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
RSpec/MultipleExpectations:
Max: 5

# Offense count: 3
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'lib/mongoid-compatibility.rb'
- 'spec/**/*'
- 'test/**/*'
- 'lib/mongoid/compatibility/object_id.rb'
- 'lib/mongoid/compatibility/version.rb'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 1.1.0 (Next)
* Your contribution here.
* [#21](https://github.com/mongoid/mongoid-compatibility/pull/21): Migrate Danger to use danger-pr-comment workflow - [@dblock](https://github.com/dblock).
* [#20](https://github.com/mongoid/mongoid-compatibility/pull/20): Add gem caching to CI - [@saisrinivasan](https://github.com/SairamSrinivasan).

### 1.0.0 (2024/06/19)
Expand Down
4 changes: 3 additions & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

danger.import_dangerfile(gem: 'mongoid-danger')
danger.import_dangerfile(gem: 'danger-pr-comment')

changelog.check!
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
source 'http://rubygems.org'

gemspec

group :test do
gem 'danger', require: false
gem 'danger-changelog', require: false
gem 'danger-pr-comment', require: false
end
7 changes: 5 additions & 2 deletions mongoid-compatibility.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ Gem::Specification.new do |s|
s.add_dependency 'mongoid', '>= 2.0'

s.add_development_dependency 'appraisal', '~> 2.0'
s.add_development_dependency 'mongoid-danger', '~> 0.2'
s.add_development_dependency 'rake', '< 12'
s.add_development_dependency 'ostruct'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'rubocop', '~> 1.36.0'
s.add_development_dependency 'rubocop-rake'
s.add_development_dependency 'rubocop-rspec'
s.metadata['rubygems_mfa_required'] = 'true'
end
1 change: 1 addition & 0 deletions spec/mongoid/compatibility/object_id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
it 'valid' do
expect(Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')).to be true
end

it 'invalid' do
expect(Mongoid::Compatibility::ObjectId.legal?('asadsf')).to be false
end
Expand Down
9 changes: 9 additions & 0 deletions spec/mongoid/compatibility/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
Mongoid::Compatibility::Version.send("mongoid#{v}?")
end).to be true
end

context "current version #{Mongoid::VERSION}" do
let(:version) { Mongoid::VERSION.split('.').first.to_i }

it 'mongoidX?' do
expect(Mongoid::Compatibility::Version.send("mongoid#{version}?")).to be true
end

it 'mongoidX?_or_newer?' do
expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_newer?")).to be true
if Mongoid::Compatibility::Version.respond_to?("mongoid#{version - 1}_or_newer?")
Expand All @@ -29,25 +32,31 @@
expect(Mongoid::Compatibility::Version.send("mongoid#{version + 1}_or_newer?")).to be false
end
end

it 'mongoidX?_or_older?' do
expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_older?")).to be true
end
end

(2..9).each do |v|
context "mongoid #{v}" do
before do
stub_const('::Mongoid::VERSION', v.to_s)
stub_const("::Mongoid::Compatibility::Version::ClassMethods::V#{v}", 1)
end

it "responds to mongoid#{v}?" do
expect(Mongoid::Compatibility::Version).to respond_to("mongoid#{v}?")
end

it "mongoid#{v}?" do
expect(Mongoid::Compatibility::Version.send("mongoid#{v}?")).to be true
end

it "mongoid#{v}_or_newer?" do
expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_newer?")).to be true
end

it "mongoid#{v}_or_older?" do
expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_older?")).to be true
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'logger'
require 'rubygems'
require 'rspec'

Expand Down