Skip to content

Commit 1018247

Browse files
authored
Merge pull request #21 from dblock/migrate-danger-pr-comment
Migrate Danger to use danger-pr-comment workflow
2 parents f3b7eac + 3887302 commit 1018247

11 files changed

Lines changed: 96 additions & 37 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Danger Comment
2+
3+
on:
4+
workflow_run:
5+
workflows: [Danger]
6+
types: [completed]
7+
8+
jobs:
9+
comment:
10+
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
11+
secrets: inherit

.github/workflows/danger.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
name: PR Linter
2-
on: [pull_request]
1+
name: Danger
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, edited, synchronize]
6+
37
jobs:
48
danger:
5-
runs-on: ubuntu-latest
6-
steps:
7-
- uses: actions/checkout@v3
8-
with:
9-
fetch-depth: 0
10-
- uses: ruby/setup-ruby@v1
11-
with:
12-
ruby-version: 2.7
13-
bundler-cache: true
14-
- run: |
15-
# Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub
16-
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
17-
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
9+
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
10+
secrets: inherit
11+
with:
12+
ruby-version: '2.7'
13+
bundler-cache: true

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
AllCops:
2+
NewCops: enable
23
Exclude:
34
- vendor/**/*
45

56
inherit_from: .rubocop_todo.yml
7+
8+
require:
9+
- rubocop-rake
10+
- rubocop-rspec

.rubocop_todo.yml

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

9-
# Offense count: 20
10-
# Configuration parameters: AllowURI, URISchemes.
11-
Metrics/LineLength:
12-
Max: 118
13-
9+
# Offense count: 1
10+
# Configuration parameters: Include.
11+
# Include: **/*.gemspec
1412
Gemspec/RequiredRubyVersion:
1513
Exclude:
1614
- 'mongoid-compatibility.gemspec'
1715

18-
Metrics/BlockLength:
16+
# Offense count: 1
17+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
18+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
19+
# 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
20+
Naming/FileName:
1921
Exclude:
20-
- 'spec/**/*'
21-
- 'test/**/*'
22+
- 'lib/mongoid-compatibility.rb'
2223

23-
# Offense count: 4
24-
Style/Documentation:
24+
# Offense count: 1
25+
# Configuration parameters: Prefixes, AllowedPatterns.
26+
# Prefixes: when, with, without
27+
RSpec/ContextWording:
2528
Exclude:
26-
- 'lib/mongoid/compatibility/object_id.rb'
27-
- 'lib/mongoid/compatibility/self.rb'
28-
- 'lib/mongoid/compatibility/version.rb'
29+
- 'spec/mongoid/compatibility/version_spec.rb'
30+
31+
# Offense count: 18
32+
# This cop supports unsafe autocorrection (--autocorrect-all).
33+
# Configuration parameters: SkipBlocks, EnforcedStyle.
34+
# SupportedStyles: described_class, explicit
35+
RSpec/DescribedClass:
36+
Exclude:
37+
- 'spec/mongoid/compatibility/object_id_spec.rb'
38+
- 'spec/mongoid/compatibility/version_spec.rb'
39+
40+
# Offense count: 1
41+
# Configuration parameters: CountAsOne.
42+
RSpec/ExampleLength:
43+
Max: 13
2944

3045
# Offense count: 1
31-
Style/DoubleNegation:
46+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
47+
# Include: **/*_spec*rb*, **/spec/**/*
48+
RSpec/FilePath:
3249
Exclude:
33-
- 'lib/mongoid/compatibility/version.rb'
50+
- 'spec/mongoid/compatibility/self_spec.rb'
3451

3552
# Offense count: 1
36-
# Configuration parameters: Exclude.
37-
Style/FileName:
53+
RSpec/MultipleExpectations:
54+
Max: 5
55+
56+
# Offense count: 3
57+
# Configuration parameters: AllowedConstants.
58+
Style/Documentation:
3859
Exclude:
39-
- 'lib/mongoid-compatibility.rb'
60+
- 'spec/**/*'
61+
- 'test/**/*'
62+
- 'lib/mongoid/compatibility/object_id.rb'
63+
- 'lib/mongoid/compatibility/version.rb'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### 1.1.0 (Next)
22
* Your contribution here.
3+
* [#21](https://github.com/mongoid/mongoid-compatibility/pull/21): Migrate Danger to use danger-pr-comment workflow - [@dblock](https://github.com/dblock).
34
* [#20](https://github.com/mongoid/mongoid-compatibility/pull/20): Add gem caching to CI - [@saisrinivasan](https://github.com/SairamSrinivasan).
45

56
### 1.0.0 (2024/06/19)

Dangerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# frozen_string_literal: true
22

3-
danger.import_dangerfile(gem: 'mongoid-danger')
3+
danger.import_dangerfile(gem: 'danger-pr-comment')
4+
5+
changelog.check!

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
source 'http://rubygems.org'
44

55
gemspec
6+
7+
group :test do
8+
gem 'danger', require: false
9+
gem 'danger-changelog', require: false
10+
gem 'danger-pr-comment', require: false
11+
end

mongoid-compatibility.gemspec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ Gem::Specification.new do |s|
1919
s.add_dependency 'mongoid', '>= 2.0'
2020

2121
s.add_development_dependency 'appraisal', '~> 2.0'
22-
s.add_development_dependency 'mongoid-danger', '~> 0.2'
23-
s.add_development_dependency 'rake', '< 12'
22+
s.add_development_dependency 'ostruct'
23+
s.add_development_dependency 'rake'
2424
s.add_development_dependency 'rspec'
2525
s.add_development_dependency 'rubocop', '~> 1.36.0'
26+
s.add_development_dependency 'rubocop-rake'
27+
s.add_development_dependency 'rubocop-rspec'
28+
s.metadata['rubygems_mfa_required'] = 'true'
2629
end

spec/mongoid/compatibility/object_id_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
it 'valid' do
77
expect(Mongoid::Compatibility::ObjectId.legal?('4e4d66343b39b68407000001')).to be true
88
end
9+
910
it 'invalid' do
1011
expect(Mongoid::Compatibility::ObjectId.legal?('asadsf')).to be false
1112
end

spec/mongoid/compatibility/version_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
Mongoid::Compatibility::Version.send("mongoid#{v}?")
1010
end).to be true
1111
end
12+
1213
context "current version #{Mongoid::VERSION}" do
1314
let(:version) { Mongoid::VERSION.split('.').first.to_i }
15+
1416
it 'mongoidX?' do
1517
expect(Mongoid::Compatibility::Version.send("mongoid#{version}?")).to be true
1618
end
19+
1720
it 'mongoidX?_or_newer?' do
1821
expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_newer?")).to be true
1922
if Mongoid::Compatibility::Version.respond_to?("mongoid#{version - 1}_or_newer?")
@@ -29,25 +32,31 @@
2932
expect(Mongoid::Compatibility::Version.send("mongoid#{version + 1}_or_newer?")).to be false
3033
end
3134
end
35+
3236
it 'mongoidX?_or_older?' do
3337
expect(Mongoid::Compatibility::Version.send("mongoid#{version}_or_older?")).to be true
3438
end
3539
end
40+
3641
(2..9).each do |v|
3742
context "mongoid #{v}" do
3843
before do
3944
stub_const('::Mongoid::VERSION', v.to_s)
4045
stub_const("::Mongoid::Compatibility::Version::ClassMethods::V#{v}", 1)
4146
end
47+
4248
it "responds to mongoid#{v}?" do
4349
expect(Mongoid::Compatibility::Version).to respond_to("mongoid#{v}?")
4450
end
51+
4552
it "mongoid#{v}?" do
4653
expect(Mongoid::Compatibility::Version.send("mongoid#{v}?")).to be true
4754
end
55+
4856
it "mongoid#{v}_or_newer?" do
4957
expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_newer?")).to be true
5058
end
59+
5160
it "mongoid#{v}_or_older?" do
5261
expect(Mongoid::Compatibility::Version.send("mongoid#{v}_or_older?")).to be true
5362
end

0 commit comments

Comments
 (0)