Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge commits to trigger "Merge Commits" label #5

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions .github/workflows/labeling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Danger

run-name: Updating labels for current PR

on:
pull_request:
types: [opened, synchronize]

jobs:
danger:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
rubygems: 3.4.10
bundler-cache: true
- name: Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bundle exec danger --verbose
2 changes: 1 addition & 1 deletion DOCKER.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Using Docker and Docker Compose for Development and Testing
# Using Docker and Docker Compose for Developments and Testings

These instructions are designed for setting up `openstreetmap-website` for development and testing using [Docker](https://www.docker.com/). This will allow you to install the OpenStreetMap application and all its dependencies in Docker images and then run them in containers, almost with a single command.

Expand Down
32 changes: 32 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Remove all previously added labels
auto_label.remove("Big PR")
auto_label.remove("Compromised Translations")
auto_label.remove("Merge Commits")
auto_label.remove("Good PR")

# Report if number of changed lines is > 500
pr_number = github.pr_json["number"]
is_big_pr = git.lines_of_code > 500
warn("Number of updated lines of code is too large to be in one PR. Perhaps it should be separated into two or more?") if is_big_pr
auto_label.set(pr_number, "Big PR", "ffff00") if is_big_pr

# Get list of translation files (except en.yml) which are modified
modified_yml_files = git.modified_files.select do |file|
file.start_with?("config/locales") && File.extname(file) == ".yml" && File.basename(file) != "en.yml"
end

# Report if some translation file (except en.yml) is modified
unless modified_yml_files.empty?
modified_files_str = modified_yml_files.map { |file| "`#{file}`" }.join(", ")
warn("The following YAML files other than `en.yml` have been modified: #{modified_files_str}. Only `en.yml` is allowed to be changed.")
auto_label.set(pr_number, "Compromised Translations", "ff0000")
end

# Report if there are merge-commits in PR
are_merge_commits_available = git.commits.any? { |c| c.parents.count > 1 }
warn("Merge commits found in this pull request. Please, read CONTRIBUTE.md!") if are_merge_commits_available
auto_label.set(pr_number, "Merge Commits", "ffaec9") if are_merge_commits_available

# Report "Everything is fine!" if no warnings were generated
message("Everything is fine!") if !is_big_pr && modified_yml_files.empty? && !are_merge_commits_available
auto_label.set(pr_number, "Good PR", "00ff00") if !is_big_pr && modified_yml_files.empty? && !are_merge_commits_available
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ gem "multi_xml", "~> 0.6.0"
group :development do
gem "better_errors"
gem "binding_of_caller"
gem "danger"
gem "danger-auto_label"
gem "debug_inspector"
gem "i18n-tasks"
gem "listen"
Expand Down
44 changes: 44 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,40 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
concurrent-ruby (1.3.3)
config (5.5.1)
deep_merge (~> 1.2, >= 1.2.1)
connection_pool (2.4.1)
cork (0.3.0)
colored2 (~> 3.1)
crack (1.0.0)
bigdecimal
rexml
crass (1.0.6)
dalli (3.2.8)
danger (9.4.3)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 3.0)
faraday-http-cache (~> 2.0)
git (~> 1.13)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (>= 4.0)
terminal-table (>= 1, < 4)
danger-auto_label (1.3.1)
danger-plugin-api (~> 1.0)
danger-plugin-api (1.0.0)
danger (> 2.0)
dartsass-ruby (3.0.2)
sass-embedded (~> 1.54, < 1.67)
dartsass-sprockets (3.0.0)
Expand Down Expand Up @@ -237,6 +262,8 @@ GEM
faraday (2.10.0)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-net_http (3.1.0)
net-http
ffi (1.17.0)
Expand All @@ -251,6 +278,9 @@ GEM
fspath (3.1.2)
gd2-ffij (0.4.0)
ffi (>= 1.0.0)
git (1.19.1)
addressable (~> 2.8)
rchardet (~> 1.8)
globalid (1.2.1)
activesupport (>= 6.1)
google-protobuf (3.25.3)
Expand Down Expand Up @@ -306,6 +336,8 @@ GEM
kgio (2.11.4)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
libv8-node (18.19.0.0)
libxml-ruby (5.0.3)
Expand Down Expand Up @@ -339,6 +371,7 @@ GEM
multi_json (1.15.0)
multi_xml (0.6.0)
mutex_m (0.2.0)
nap (1.1.0)
net-http (0.4.1)
uri
net-imap (0.4.14)
Expand All @@ -351,6 +384,7 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
no_proxy_fix (0.1.2)
nokogiri (1.16.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
Expand All @@ -367,6 +401,9 @@ GEM
rack (>= 1.2, < 4)
snaky_hash (~> 2.0)
version_gem (~> 1.1)
octokit (9.1.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
omniauth (2.0.4)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
Expand Down Expand Up @@ -401,6 +438,7 @@ GEM
omniauth-rails_csrf_protection (1.0.2)
actionpack (>= 4.2)
omniauth (~> 2.0)
open4 (1.3.4)
openstreetmap-deadlock_retry (1.3.1)
parallel (1.25.1)
parser (3.3.4.0)
Expand Down Expand Up @@ -477,6 +515,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rchardet (1.8.0)
rdoc (6.7.0)
psych (>= 4.0.0)
regexp_parser (2.9.2)
Expand Down Expand Up @@ -532,6 +571,9 @@ GEM
sass-embedded (1.64.2)
google-protobuf (~> 3.23)
rake (>= 13.0.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
selenium-webdriver (4.22.0)
base64 (~> 0.2)
logger (~> 1.4)
Expand Down Expand Up @@ -624,6 +666,8 @@ DEPENDENCIES
config
connection_pool
dalli
danger
danger-auto_label
dartsass-sprockets
debug_inspector
delayed_job_active_record
Expand Down