diff --git a/.github/workflows/danger-comment.yml b/.github/workflows/danger-comment.yml index 50f3f72..eb84459 100644 --- a/.github/workflows/danger-comment.yml +++ b/.github/workflows/danger-comment.yml @@ -117,6 +117,6 @@ jobs: } // Fail if there are errors - if (report.errors && report.errors.length > 0) { + if (hasItems(report.errors)) { core.setFailed('Danger found errors'); } diff --git a/CHANGELOG.md b/CHANGELOG.md index 9adad5c..f747b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 0.2.2 (Next) * Your contribution here. +* [#16](https://github.com/ruby-grape/danger/pull/16): Report workflow postreview fixes - [@numbata](https://github.com/numbata). * [#15](https://github.com/ruby-grape/danger/pull/15): Extract danger reporting infrastructure into reusable workflows and gem - [@numbata](https://github.com/numbata). ### 0.2.1 (2024/02/01) diff --git a/Dangerfile b/Dangerfile index ee6cd4b..cce43c1 100644 --- a/Dangerfile +++ b/Dangerfile @@ -8,19 +8,17 @@ require 'English' # to get automatic reporting with their own custom checks. # Register at_exit hook to export report when Dangerfile finishes +dangerfile_instance = self if defined?(Danger::Dangerfile) && is_a?(Danger::Dangerfile) at_exit do # Only skip if there's an actual exception (not SystemExit from danger calling exit) next if $ERROR_INFO && !$ERROR_INFO.is_a?(SystemExit) + next unless dangerfile_instance - # Find the Dangerfile instance and get its current status_report - ObjectSpace.each_object(Danger::Dangerfile) do |df| - reporter = RubyGrapeDanger::Reporter.new(df.status_report) - reporter.export_json( - ENV.fetch('DANGER_REPORT_PATH', nil), - ENV.fetch('GITHUB_EVENT_PATH', nil) - ) - break - end + reporter = RubyGrapeDanger::Reporter.new(dangerfile_instance.status_report) + reporter.export_json( + ENV.fetch('DANGER_REPORT_PATH', nil), + ENV.fetch('GITHUB_EVENT_PATH', nil) + ) end # -------------------------------------------------------------------------------------------------------------------- diff --git a/README.md b/README.md index 1608b96..9d9df15 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ - [Commit via a Pull Request](#commit-via-a-pull-request) - [Reusable Workflows](#reusable-workflows) - [Architecture](#architecture) - - [Benefits of Reusable Workflows](#benefits-of-reusable-workflows) - [How It Works](#how-it-works) - [Examples](#examples) - [License](#license) @@ -60,7 +59,7 @@ on: jobs: danger: - uses: ruby-grape/ruby-grape-danger/.github/workflows/danger-run.yml@main + uses: ruby-grape/danger/.github/workflows/danger-run.yml@main ``` Create `.github/workflows/danger-comment.yml`: @@ -75,7 +74,7 @@ on: jobs: comment: - uses: ruby-grape/ruby-grape-danger/.github/workflows/danger-comment.yml@main + uses: ruby-grape/danger/.github/workflows/danger-comment.yml@main ``` ### Commit via a Pull Request @@ -100,19 +99,12 @@ The workflows are separated into two stages: - Formats and posts results as a PR comment - Updates existing comment on subsequent runs -### Benefits of Reusable Workflows - -✅ **DRY**: Define workflows once in `ruby-grape-danger`, reuse everywhere -✅ **Consistent**: All Grape projects use the same reporting format and behavior -✅ **Maintainable**: Fix a bug in the workflows once, all projects benefit automatically -✅ **Scalable**: Add new checks to any project's Dangerfile without touching workflows - ### How It Works When you reference the reusable workflows: ```yaml -uses: ruby-grape/ruby-grape-danger/.github/workflows/danger-run.yml@main +uses: ruby-grape/danger/.github/workflows/danger-run.yml@main ``` GitHub Actions: diff --git a/ruby-grape-danger.gemspec b/ruby-grape-danger.gemspec index ea0d78c..6cf4e86 100644 --- a/ruby-grape-danger.gemspec +++ b/ruby-grape-danger.gemspec @@ -18,6 +18,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake' s.add_development_dependency 'rspec' s.add_runtime_dependency 'danger', '~> 9' - s.add_runtime_dependency 'danger-changelog', '~> 0.7' + s.add_runtime_dependency 'danger-changelog', '~> 0.8' s.add_runtime_dependency 'danger-toc', '~> 0.2' end