Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit 90a8da4

Browse files
authored
Report workflow postreview fixes (#16)
* Simplify the `at_exit` hook * Reuse helper on comment posting * Change a bit README.md file * Use danger-changelog tokenless version * Update docs * Remove useless `break` call
1 parent b037869 commit 90a8da4

File tree

5 files changed

+13
-22
lines changed

5 files changed

+13
-22
lines changed

.github/workflows/danger-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,6 @@ jobs:
117117
}
118118
119119
// Fail if there are errors
120-
if (report.errors && report.errors.length > 0) {
120+
if (hasItems(report.errors)) {
121121
core.setFailed('Danger found errors');
122122
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### 0.2.2 (Next)
44

55
* Your contribution here.
6+
* [#16](https://github.com/ruby-grape/danger/pull/16): Report workflow postreview fixes - [@numbata](https://github.com/numbata).
67
* [#15](https://github.com/ruby-grape/danger/pull/15): Extract danger reporting infrastructure into reusable workflows and gem - [@numbata](https://github.com/numbata).
78

89
### 0.2.1 (2024/02/01)

Dangerfile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ require 'English'
88
# to get automatic reporting with their own custom checks.
99

1010
# Register at_exit hook to export report when Dangerfile finishes
11+
dangerfile_instance = self if defined?(Danger::Dangerfile) && is_a?(Danger::Dangerfile)
1112
at_exit do
1213
# Only skip if there's an actual exception (not SystemExit from danger calling exit)
1314
next if $ERROR_INFO && !$ERROR_INFO.is_a?(SystemExit)
15+
next unless dangerfile_instance
1416

15-
# Find the Dangerfile instance and get its current status_report
16-
ObjectSpace.each_object(Danger::Dangerfile) do |df|
17-
reporter = RubyGrapeDanger::Reporter.new(df.status_report)
18-
reporter.export_json(
19-
ENV.fetch('DANGER_REPORT_PATH', nil),
20-
ENV.fetch('GITHUB_EVENT_PATH', nil)
21-
)
22-
break
23-
end
17+
reporter = RubyGrapeDanger::Reporter.new(dangerfile_instance.status_report)
18+
reporter.export_json(
19+
ENV.fetch('DANGER_REPORT_PATH', nil),
20+
ENV.fetch('GITHUB_EVENT_PATH', nil)
21+
)
2422
end
2523

2624
# --------------------------------------------------------------------------------------------------------------------

README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
- [Commit via a Pull Request](#commit-via-a-pull-request)
1414
- [Reusable Workflows](#reusable-workflows)
1515
- [Architecture](#architecture)
16-
- [Benefits of Reusable Workflows](#benefits-of-reusable-workflows)
1716
- [How It Works](#how-it-works)
1817
- [Examples](#examples)
1918
- [License](#license)
@@ -60,7 +59,7 @@ on:
6059

6160
jobs:
6261
danger:
63-
uses: ruby-grape/ruby-grape-danger/.github/workflows/danger-run.yml@main
62+
uses: ruby-grape/danger/.github/workflows/danger-run.yml@main
6463
```
6564
6665
Create `.github/workflows/danger-comment.yml`:
@@ -75,7 +74,7 @@ on:
7574
7675
jobs:
7776
comment:
78-
uses: ruby-grape/ruby-grape-danger/.github/workflows/danger-comment.yml@main
77+
uses: ruby-grape/danger/.github/workflows/danger-comment.yml@main
7978
```
8079

8180
### Commit via a Pull Request
@@ -100,19 +99,12 @@ The workflows are separated into two stages:
10099
- Formats and posts results as a PR comment
101100
- Updates existing comment on subsequent runs
102101

103-
### Benefits of Reusable Workflows
104-
105-
✅ **DRY**: Define workflows once in `ruby-grape-danger`, reuse everywhere
106-
✅ **Consistent**: All Grape projects use the same reporting format and behavior
107-
✅ **Maintainable**: Fix a bug in the workflows once, all projects benefit automatically
108-
✅ **Scalable**: Add new checks to any project's Dangerfile without touching workflows
109-
110102
### How It Works
111103

112104
When you reference the reusable workflows:
113105

114106
```yaml
115-
uses: ruby-grape/ruby-grape-danger/.github/workflows/danger-run.yml@main
107+
uses: ruby-grape/danger/.github/workflows/danger-run.yml@main
116108
```
117109

118110
GitHub Actions:

ruby-grape-danger.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
1818
s.add_development_dependency 'rake'
1919
s.add_development_dependency 'rspec'
2020
s.add_runtime_dependency 'danger', '~> 9'
21-
s.add_runtime_dependency 'danger-changelog', '~> 0.7'
21+
s.add_runtime_dependency 'danger-changelog', '~> 0.8'
2222
s.add_runtime_dependency 'danger-toc', '~> 0.2'
2323
end

0 commit comments

Comments
 (0)