Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,41 @@ jobs:
name: Ruby lint (standardrb)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- run: bundle exec standardrb

rspec:
name: RSpec
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- run: bundle exec rspec
- uses: actions/upload-artifact@v7
if: always()
with:
name: coverage-report
path: coverage/

reuse:
name: REUSE Compliance Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: fsfe/reuse-action@v1.1
- uses: actions/checkout@v7
- uses: fsfe/reuse-action@v6

xrefcheck:
name: xrefcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- uses: serokell/xrefcheck-action@v1

danger:
Expand All @@ -44,7 +60,7 @@ jobs:
issues: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
# Gem build artifacts
/pkg/
/*.gem

# Test coverage report
/coverage/
7 changes: 7 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2026 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: MPL-2.0

--require spec_helper
--format documentation
--color
6 changes: 0 additions & 6 deletions .xrefcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@ exclusions:
# Notion requires authentication; xrefcheck cannot verify these links.
ignoreExternalRefsTo:
- "https://app.notion.com/.*"
# TODO: remove once this repo goes public. While it's private, GitHub
# returns 404 (not 403) for any of its own pages (issues, PRs, Actions
# runs, etc.) to an unauthenticated request, indistinguishable from a
# genuinely broken link. Once public, this exclusion would silently
# hide real broken links instead.
- "https://github\\.com/serokell/danger(/.*)?"
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!--
- SPDX-FileCopyrightText: 2026 Serokell <https://serokell.io>
-
- SPDX-License-Identifier: CC0-1.0
-->

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Fixed

- `check_merge_request` no longer calls the GitHub-only `mr_title`/`mr_body`
methods against a GitHub PR, which raised instead of reading the PR's
title/body (#6).
- Fixed a typo in `check_merge_request`'s `ticket_links.scan` error message
("expecs" → "expects") (#6).
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ Our pull request template contains a [checklist](.github/pull_request_template.m
of acceptance criteria for your pull request. Please read it before you start
contributing and make sure your contributions adhere to this checklist.

### Running tests and lints

```sh
bundle install
bundle exec rspec # run the test suite
bundle exec standardrb # lint
bundle exec reuse lint # REUSE/SPDX compliance
xrefcheck # check for broken links between files
```

All four run in CI on every pull request. `xrefcheck` isn't a Ruby
gem; see [serokell/xrefcheck](https://github.com/serokell/xrefcheck)
for installation instructions.

`bundle exec rspec` also produces a test coverage report via
[SimpleCov](https://github.com/simplecov-ruby/simplecov), written to
`coverage/index.html`, and fails the run if coverage drops below 90%.

## Legal

We want to make sure that our projects come with correct licensing information
Expand Down
8 changes: 6 additions & 2 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ check_commits_style
check_premerge_commits
check_merge_request
check_merge_commits
check_license_headers
check_license_headers(
license_headers_default_config.with(ignore_paths: ["spec/fixtures/"])
)
check_trailing_whitespace(
trailing_whitespace_default_config.with(ignore_paths: ["LICENSE", "LICENSES/"])
trailing_whitespace_default_config.with(
ignore_paths: ["LICENSE", "LICENSES/", "spec/fixtures/"]
)
)
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ group :development do
gem "ruby-lsp"
gem "standard"
end

group :test do
gem "rspec"
gem "simplecov", require: false
end
12 changes: 12 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ path = ".github/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 Serokell <https://serokell.io>"
SPDX-License-Identifier = "CC0-1.0"

[[annotations]]
path = "spec/fixtures/pull_request_event.json"
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 Serokell <https://serokell.io>"
SPDX-License-Identifier = "CC0-1.0"

[[annotations]]
path = "spec/fixtures/no_license_header.md"
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 Serokell <https://serokell.io>"
SPDX-License-Identifier = "MPL-2.0"
2 changes: 1 addition & 1 deletion lib/serokell_danger/checks/merge-request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def check_merge_request(config = merge_request_default_config)
case where.to_sym
when :title then title
when :body then body
else raise ArgumentError, "`ticket_links.scan` expecs :title and/or :body, got #{where.inspect}."
else raise ArgumentError, "`ticket_links.scan` expects :title and/or :body, got #{where.inspect}."
end
end.join("\n")

Expand Down
11 changes: 8 additions & 3 deletions lib/serokell_danger/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def gitlab?
end

def mr_title
plugin.mr_title.to_s
githost_switch(:pr_title, :mr_title).to_s
end
alias_method :pr_title, :mr_title

def mr_body
plugin.mr_body.to_s
githost_switch(:pr_body, :mr_body).to_s
end
alias_method :pr_body, :mr_body

def mr_json
plugin.mr_json
githost_switch(:pr_json, :mr_json)
end
alias_method :pr_json, :mr_json

Expand Down Expand Up @@ -106,6 +106,11 @@ def respond_to_missing?(name, include_private = false)

private

def githost_switch(on_github, on_gitlab, *args, **kwargs, &block)
return plugin.public_send(on_github, *args, **kwargs, &block) if github? && plugin.respond_to?(on_github)
plugin.public_send(on_gitlab, *args, **kwargs, &block)
end

def json_field(gitlab_key, github_key)
json = mr_json
key = gitlab? ? gitlab_key : github_key
Expand Down
7 changes: 7 additions & 0 deletions spec/fixtures/NoFinalNewline.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- SPDX-FileCopyrightText: 2026 Serokell <https://serokell.io/>
--
-- SPDX-License-Identifier: MPL-2.0
module NoFinalNewline (main) where

main :: IO ()
main = putStrLn "Hello, world!"
8 changes: 8 additions & 0 deletions spec/fixtures/TrailingWhitespaceExtraFinalNewlines.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- SPDX-FileCopyrightText: 2026 Serokell <https://serokell.io/>
--
-- SPDX-License-Identifier: MPL-2.0
module TrailingWhitespaceExtraFinalNewlines (main) where

main :: IO ()
main = putStrLn "Hello, world!"

1 change: 1 addition & 0 deletions spec/fixtures/no_license_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This fixture has no license header at all and should be silently skipped.
7 changes: 7 additions & 0 deletions spec/fixtures/outdated_license_year.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
- SPDX-FileCopyrightText: 2023 Serokell <https://serokell.io>
-
- SPDX-License-Identifier: MPL-2.0
-->

This fixture has an outdated license year and should be flagged by the test.
7 changes: 7 additions & 0 deletions spec/fixtures/outdated_year_and_wrong_holder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
- SPDX-FileCopyrightText: 2023 example <https://example.com>
-
- SPDX-License-Identifier: MPL-2.0
-->

This fixture has both an outdated license year and the wrong copyright holder.
6 changes: 6 additions & 0 deletions spec/fixtures/pull_request_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"number": 42,
"repository": {
"clone_url": "https://github.com/serokell/danger.git"
}
}
7 changes: 7 additions & 0 deletions spec/fixtures/wrong_copyright_holder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
- SPDX-FileCopyrightText: 2026 example <https://example.com>
-
- SPDX-License-Identifier: MPL-2.0
-->

This fixture has the wrong copyright holder.
Loading