Skip to content

Commit df6e2cb

Browse files
authored
Merge pull request #52 from dblock/update-danger-workflow
Update Danger workflow to use reusable workflow
2 parents a035d2a + ac5980e commit df6e2cb

File tree

11 files changed

+133
-175
lines changed

11 files changed

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

.github/workflows/danger.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
1-
---
21
name: danger
2+
33
on:
44
pull_request:
55
types: [opened, reopened, edited, synchronize]
6+
67
jobs:
78
danger:
8-
runs-on: ubuntu-20.04
9-
steps:
10-
- uses: actions/checkout@v3
11-
with:
12-
fetch-depth: 0
13-
- name: Set up Ruby
14-
uses: ruby/setup-ruby@v1
15-
with:
16-
ruby-version: 2.7
17-
bundler-cache: true
18-
- name: Run Danger
19-
run: |
20-
# the personal token is public, this is ok, base64 encode to avoid tripping Github
21-
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
22-
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
9+
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@main
10+
secrets: inherit
11+
with:
12+
ruby-version: '3.1'
13+
bundler-cache: true

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: ruby/setup-ruby@v1
2222
with:
2323
ruby-version: ${{ matrix.entry.ruby }}
24-
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
24+
- run: bundle install --jobs=3 --retry=3
2525
- run: bundle exec rake spec
2626
continue-on-error: ${{ matrix.entry.allowed-failure }}
2727
- name: Specs for when the i18n gem is not available

.rubocop.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
require:
2-
- rubocop-rake
3-
- rubocop-rspec
4-
51
AllCops:
62
TargetRubyVersion: 2.7
73
NewCops: enable
@@ -15,7 +11,7 @@ Metrics/BlockLength:
1511
RSpec/SpecFilePathFormat:
1612
Enabled: false
1713

18-
RSpec/FilePath:
14+
Style/LineLength:
1915
Enabled: false
2016

2117
Style/HashEachMethods:
@@ -27,4 +23,32 @@ Style/HashTransformKeys:
2723
Style/HashTransformValues:
2824
Enabled: true
2925

26+
Naming/FileName:
27+
Enabled: false
28+
29+
Style/Documentation:
30+
Enabled: false
31+
32+
Naming/MethodParameterName:
33+
Enabled: false
34+
35+
RSpec/NestedGroups:
36+
Enabled: false
37+
38+
RSpec/ExampleLength:
39+
Enabled: false
40+
41+
RSpec/MultipleExpectations:
42+
Enabled: false
43+
44+
Lint/ConstantDefinitionInBlock:
45+
Enabled: false
46+
47+
RSpec/LeakyConstantDeclaration:
48+
Enabled: false
49+
3050
inherit_from: .rubocop_todo.yml
51+
52+
plugins:
53+
- rubocop-rake
54+
- rubocop-rspec

.rubocop_todo.yml

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,7 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-02-14 01:34:25 UTC using RuboCop version 1.45.1.
3+
# on 2025-12-30 16:44:41 UTC using RuboCop version 1.82.1.
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.
8-
9-
# Offense count: 4
10-
# Configuration parameters: AllowedMethods.
11-
# AllowedMethods: enums
12-
Lint/ConstantDefinitionInBlock:
13-
Exclude:
14-
- 'spec/ruby-enum/enum_spec.rb'
15-
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:
21-
Exclude:
22-
- 'lib/ruby-enum.rb'
23-
24-
# Offense count: 6
25-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
26-
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
27-
Naming/MethodParameterName:
28-
Exclude:
29-
- 'lib/ruby-enum/enum.rb'
30-
31-
# Offense count: 3
32-
# Configuration parameters: CountAsOne.
33-
RSpec/ExampleLength:
34-
Max: 11
35-
36-
# Offense count: 4
37-
RSpec/LeakyConstantDeclaration:
38-
Exclude:
39-
- 'spec/ruby-enum/enum_spec.rb'
40-
41-
# Offense count: 6
42-
RSpec/MultipleExpectations:
43-
Max: 11
44-
45-
# Offense count: 18
46-
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
47-
# SupportedStyles: always, named_only
48-
RSpec/NamedSubject:
49-
Exclude:
50-
- 'spec/ruby-enum/enum_spec.rb'
51-
52-
# Offense count: 1
53-
# Configuration parameters: AllowedGroups.
54-
RSpec/NestedGroups:
55-
Max: 4
56-
57-
# Offense count: 4
58-
# Configuration parameters: AllowedConstants.
59-
Style/Documentation:
60-
Exclude:
61-
- 'spec/**/*'
62-
- 'test/**/*'
63-
- 'lib/ruby-enum/enum.rb'
64-
- 'lib/ruby-enum/errors/base.rb'
65-
- 'lib/ruby-enum/errors/uninitialized_constant_error.rb'
66-
67-
# Offense count: 1
68-
# This cop supports safe autocorrection (--autocorrect).
69-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
70-
# URISchemes: http, https
71-
Layout/LineLength:
72-
Max: 148

Dangerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# frozen_string_literal: true
22

3+
danger.import_dangerfile(gem: 'danger-pr-comment')
4+
35
changelog.check!
46
toc.check!

Gemfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ gem 'rake'
88

99
group :development, :test do
1010
gem 'danger'
11-
gem 'danger-changelog', '0.6.1'
12-
gem 'danger-toc', '0.2.0'
13-
gem 'rspec', '~> 3.0'
14-
gem 'rubocop', '~> 1.0'
11+
gem 'danger-changelog'
12+
gem 'danger-pr-comment'
13+
gem 'danger-toc'
14+
gem 'rspec'
15+
gem 'rubocop', '1.82.1'
1516
gem 'rubocop-rake'
1617
gem 'rubocop-rspec'
1718
end

lib/ruby-enum/errors/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def compose_message(key, attributes = {})
2626
"\nSummary:\n #{@summary}" + "\nResolution:\n #{@resolution}"
2727
end
2828

29-
private
30-
3129
BASE_KEY = 'ruby.enum.errors.messages' # :nodoc:
3230

31+
private
32+
3333
# Given the key of the specific error and the options hash, translate the
3434
# message.
3535
#

spec/ruby-enum/enum/case_spec.rb

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,56 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe Ruby::Enum::Case do
6-
test_enum =
7-
Class.new do
8-
include Ruby::Enum
9-
include Ruby::Enum::Case
10-
11-
define :RED, :red
12-
define :GREEN, :green
13-
define :BLUE, :blue
14-
end
5+
module Case
6+
class Colors
7+
include Ruby::Enum
8+
include Ruby::Enum::Case
9+
10+
define :RED, :red
11+
define :GREEN, :green
12+
define :BLUE, :blue
13+
end
14+
end
1515

16+
RSpec.describe Ruby::Enum::Case do
1617
describe '.case' do
1718
context 'when all cases are defined' do
18-
subject { test_enum.case(test_enum::RED, cases) }
19+
subject { Case::Colors.case(Case::Colors::RED, cases) }
1920

2021
let(:cases) do
2122
{
22-
[test_enum::RED, test_enum::GREEN] => -> { 'red or green' },
23-
test_enum::BLUE => -> { 'blue' }
23+
[Case::Colors::RED, Case::Colors::GREEN] => -> { 'red or green' },
24+
Case::Colors::BLUE => -> { 'blue' }
2425
}
2526
end
2627

2728
it { is_expected.to eq('red or green') }
2829

2930
context 'when the value is nil' do
30-
subject { test_enum.case(nil, cases) }
31+
subject { Case::Colors.case(nil, cases) }
3132

3233
it { is_expected.to be_nil }
3334
end
3435

3536
context 'when the value is empty' do
36-
subject { test_enum.case('', cases) }
37+
subject { Case::Colors.case('', cases) }
3738

3839
it { is_expected.to be_nil }
3940
end
4041

4142
context 'when the value is the value of the enum' do
42-
subject { test_enum.case(:red, cases) }
43+
subject { Case::Colors.case(:red, cases) }
4344

4445
it { is_expected.to eq('red or green') }
4546
end
4647

4748
context 'when the value is used inside the lambda' do
48-
subject { test_enum.case(test_enum::RED, cases) }
49+
subject { Case::Colors.case(Case::Colors::RED, cases) }
4950

5051
let(:cases) do
5152
{
52-
[test_enum::RED, test_enum::GREEN] => ->(color) { "is #{color}" },
53-
test_enum::BLUE => -> { 'blue' }
53+
[Case::Colors::RED, Case::Colors::GREEN] => ->(color) { "is #{color}" },
54+
Case::Colors::BLUE => -> { 'blue' }
5455
}
5556
end
5657

@@ -60,12 +61,12 @@
6061

6162
context 'when there are mutliple matches' do
6263
subject do
63-
test_enum.case(
64-
test_enum::RED,
64+
Case::Colors.case(
65+
Case::Colors::RED,
6566
{
66-
[test_enum::RED, test_enum::GREEN] => -> { 'red or green' },
67-
test_enum::RED => -> { 'red' },
68-
test_enum::BLUE => -> { 'blue' }
67+
[Case::Colors::RED, Case::Colors::GREEN] => -> { 'red or green' },
68+
Case::Colors::RED => -> { 'red' },
69+
Case::Colors::BLUE => -> { 'blue' }
6970
}
7071
)
7172
end
@@ -76,9 +77,9 @@
7677
context 'when not all cases are defined' do
7778
it 'raises an error' do
7879
expect do
79-
test_enum.case(
80-
test_enum::RED,
81-
{ [test_enum::RED, test_enum::GREEN] => -> { 'red or green' } }
80+
Case::Colors.case(
81+
Case::Colors::RED,
82+
{ [Case::Colors::RED, Case::Colors::GREEN] => -> { 'red or green' } }
8283
)
8384
end.to raise_error(Ruby::Enum::Case::ClassMethods::NotAllCasesHandledError)
8485
end
@@ -87,10 +88,10 @@
8788
context 'when not all cases are defined but :else is specified (default case)' do
8889
it 'does not raise an error' do
8990
expect do
90-
result = test_enum.case(
91-
test_enum::BLUE,
91+
result = Case::Colors.case(
92+
Case::Colors::BLUE,
9293
{
93-
[test_enum::RED, test_enum::GREEN] => -> { 'red or green' },
94+
[Case::Colors::RED, Case::Colors::GREEN] => -> { 'red or green' },
9495
else: -> { 'blue' }
9596
}
9697
)
@@ -103,11 +104,11 @@
103104
context 'when a superfluous case is defined' do
104105
it 'raises an error' do
105106
expect do
106-
test_enum.case(
107-
test_enum::RED,
107+
Case::Colors.case(
108+
Case::Colors::RED,
108109
{
109-
[test_enum::RED, test_enum::GREEN] => -> { 'red or green' },
110-
test_enum::BLUE => -> { 'blue' },
110+
[Case::Colors::RED, Case::Colors::GREEN] => -> { 'red or green' },
111+
Case::Colors::BLUE => -> { 'blue' },
111112
:something => -> { 'green' }
112113
}
113114
)

0 commit comments

Comments
 (0)