Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/danger-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
15 changes: 7 additions & 8 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ 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)
reporter = RubyGrapeDanger::Reporter.new(dangerfile_instance.status_report)
reporter.export_json(
ENV.fetch('DANGER_REPORT_PATH', nil),
ENV.fetch('GITHUB_EVENT_PATH', nil)
)
break
end
break
end

# --------------------------------------------------------------------------------------------------------------------
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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`:
Expand All @@ -75,7 +75,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
Expand All @@ -100,19 +100,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:
Expand Down
2 changes: 1 addition & 1 deletion ruby-grape-danger.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading