Merge pull request #4988 from nenad-vujicic/issue_4912_pr_labeling
Added workflow for PR labeling using Danger
This commit is contained in:
commit
b0ffe17cec
4 changed files with 101 additions and 0 deletions
25
.github/workflows/labeling.yml
vendored
Normal file
25
.github/workflows/labeling.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
name: Danger
|
||||||
|
|
||||||
|
run-name: Updating labels for current PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
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.1
|
||||||
|
rubygems: 3.4.10
|
||||||
|
bundler-cache: true
|
||||||
|
- name: Danger
|
||||||
|
env:
|
||||||
|
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
bundle exec danger --verbose
|
32
Dangerfile
Normal file
32
Dangerfile
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# Get PR number
|
||||||
|
pr_number = github.pr_json["number"]
|
||||||
|
|
||||||
|
# Report if number of changed lines is > 500
|
||||||
|
if 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?")
|
||||||
|
auto_label.set(pr_number, "Big PR", "FBCA04")
|
||||||
|
else
|
||||||
|
auto_label.remove("Big PR")
|
||||||
|
end
|
||||||
|
|
||||||
|
# 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
|
||||||
|
if modified_yml_files.empty?
|
||||||
|
auto_label.remove("Inappropriate Translations")
|
||||||
|
else
|
||||||
|
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. Translations are updated via Translatewiki, see CONTRIBUTING.md.")
|
||||||
|
auto_label.set(pr_number, "Inappropriate Translations", "B60205")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Report if there are merge-commits in PR
|
||||||
|
if git.commits.any? { |c| c.parents.count > 1 }
|
||||||
|
warn("Merge commits are found in PR. Please rebase to get rid of the merge commits in this PR, see CONTRIBUTING.md.")
|
||||||
|
auto_label.set(pr_number, "Merge Commits", "D93F0B")
|
||||||
|
else
|
||||||
|
auto_label.remove("Merge Commits")
|
||||||
|
end
|
2
Gemfile
2
Gemfile
|
@ -148,6 +148,8 @@ gem "zeitwerk", "< 2.7"
|
||||||
group :development do
|
group :development do
|
||||||
gem "better_errors"
|
gem "better_errors"
|
||||||
gem "binding_of_caller"
|
gem "binding_of_caller"
|
||||||
|
gem "danger"
|
||||||
|
gem "danger-auto_label"
|
||||||
gem "debug_inspector"
|
gem "debug_inspector"
|
||||||
gem "i18n-tasks"
|
gem "i18n-tasks"
|
||||||
gem "listen"
|
gem "listen"
|
||||||
|
|
42
Gemfile.lock
42
Gemfile.lock
|
@ -150,16 +150,40 @@ GEM
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
childprocess (5.1.0)
|
childprocess (5.1.0)
|
||||||
logger (~> 1.5)
|
logger (~> 1.5)
|
||||||
|
claide (1.1.0)
|
||||||
|
claide-plugins (0.9.2)
|
||||||
|
cork
|
||||||
|
nap
|
||||||
|
open4 (~> 1.3)
|
||||||
|
colored2 (3.1.2)
|
||||||
concurrent-ruby (1.3.4)
|
concurrent-ruby (1.3.4)
|
||||||
config (5.5.2)
|
config (5.5.2)
|
||||||
deep_merge (~> 1.2, >= 1.2.1)
|
deep_merge (~> 1.2, >= 1.2.1)
|
||||||
ostruct
|
ostruct
|
||||||
connection_pool (2.4.1)
|
connection_pool (2.4.1)
|
||||||
|
cork (0.3.0)
|
||||||
|
colored2 (~> 3.1)
|
||||||
crack (1.0.0)
|
crack (1.0.0)
|
||||||
bigdecimal
|
bigdecimal
|
||||||
rexml
|
rexml
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
dalli (3.2.8)
|
dalli (3.2.8)
|
||||||
|
danger (9.5.0)
|
||||||
|
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)
|
||||||
|
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)
|
dartsass-ruby (3.0.2)
|
||||||
sass-embedded (~> 1.54, < 1.67)
|
sass-embedded (~> 1.54, < 1.67)
|
||||||
dartsass-sprockets (3.0.0)
|
dartsass-sprockets (3.0.0)
|
||||||
|
@ -240,6 +264,8 @@ GEM
|
||||||
faraday-net_http (>= 2.0, < 3.4)
|
faraday-net_http (>= 2.0, < 3.4)
|
||||||
json
|
json
|
||||||
logger
|
logger
|
||||||
|
faraday-http-cache (2.5.1)
|
||||||
|
faraday (>= 0.8)
|
||||||
faraday-net_http (3.3.0)
|
faraday-net_http (3.3.0)
|
||||||
net-http
|
net-http
|
||||||
ffi (1.17.0)
|
ffi (1.17.0)
|
||||||
|
@ -254,6 +280,9 @@ GEM
|
||||||
fspath (3.1.2)
|
fspath (3.1.2)
|
||||||
gd2-ffij (0.4.0)
|
gd2-ffij (0.4.0)
|
||||||
ffi (>= 1.0.0)
|
ffi (>= 1.0.0)
|
||||||
|
git (1.19.1)
|
||||||
|
addressable (~> 2.8)
|
||||||
|
rchardet (~> 1.8)
|
||||||
globalid (1.2.1)
|
globalid (1.2.1)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
google-protobuf (3.25.5)
|
google-protobuf (3.25.5)
|
||||||
|
@ -311,6 +340,8 @@ GEM
|
||||||
kgio (2.11.4)
|
kgio (2.11.4)
|
||||||
kramdown (2.4.0)
|
kramdown (2.4.0)
|
||||||
rexml
|
rexml
|
||||||
|
kramdown-parser-gfm (1.1.0)
|
||||||
|
kramdown (~> 2.0)
|
||||||
language_server-protocol (3.17.0.3)
|
language_server-protocol (3.17.0.3)
|
||||||
libv8-node (18.19.0.0)
|
libv8-node (18.19.0.0)
|
||||||
libxml-ruby (5.0.3)
|
libxml-ruby (5.0.3)
|
||||||
|
@ -344,6 +375,7 @@ GEM
|
||||||
multi_json (1.15.0)
|
multi_json (1.15.0)
|
||||||
multi_xml (0.7.1)
|
multi_xml (0.7.1)
|
||||||
bigdecimal (~> 3.1)
|
bigdecimal (~> 3.1)
|
||||||
|
nap (1.1.0)
|
||||||
net-http (0.4.1)
|
net-http (0.4.1)
|
||||||
uri
|
uri
|
||||||
net-imap (0.4.17)
|
net-imap (0.4.17)
|
||||||
|
@ -372,6 +404,9 @@ GEM
|
||||||
rack (>= 1.2, < 4)
|
rack (>= 1.2, < 4)
|
||||||
snaky_hash (~> 2.0)
|
snaky_hash (~> 2.0)
|
||||||
version_gem (~> 1.1)
|
version_gem (~> 1.1)
|
||||||
|
octokit (9.1.0)
|
||||||
|
faraday (>= 1, < 3)
|
||||||
|
sawyer (~> 0.9)
|
||||||
omniauth (2.0.4)
|
omniauth (2.0.4)
|
||||||
hashie (>= 3.4.6)
|
hashie (>= 3.4.6)
|
||||||
rack (>= 1.6.2, < 3)
|
rack (>= 1.6.2, < 3)
|
||||||
|
@ -407,6 +442,7 @@ GEM
|
||||||
omniauth-rails_csrf_protection (1.0.2)
|
omniauth-rails_csrf_protection (1.0.2)
|
||||||
actionpack (>= 4.2)
|
actionpack (>= 4.2)
|
||||||
omniauth (~> 2.0)
|
omniauth (~> 2.0)
|
||||||
|
open4 (1.3.4)
|
||||||
openstreetmap-deadlock_retry (1.3.1)
|
openstreetmap-deadlock_retry (1.3.1)
|
||||||
ostruct (0.6.0)
|
ostruct (0.6.0)
|
||||||
overcommit (0.64.0)
|
overcommit (0.64.0)
|
||||||
|
@ -488,6 +524,7 @@ GEM
|
||||||
rb-fsevent (0.11.2)
|
rb-fsevent (0.11.2)
|
||||||
rb-inotify (0.11.1)
|
rb-inotify (0.11.1)
|
||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
|
rchardet (1.8.0)
|
||||||
rdoc (6.7.0)
|
rdoc (6.7.0)
|
||||||
psych (>= 4.0.0)
|
psych (>= 4.0.0)
|
||||||
regexp_parser (2.9.2)
|
regexp_parser (2.9.2)
|
||||||
|
@ -542,6 +579,9 @@ GEM
|
||||||
sass-embedded (1.64.2)
|
sass-embedded (1.64.2)
|
||||||
google-protobuf (~> 3.23)
|
google-protobuf (~> 3.23)
|
||||||
rake (>= 13.0.0)
|
rake (>= 13.0.0)
|
||||||
|
sawyer (0.9.2)
|
||||||
|
addressable (>= 2.3.5)
|
||||||
|
faraday (>= 0.17.3, < 3)
|
||||||
securerandom (0.3.1)
|
securerandom (0.3.1)
|
||||||
selenium-webdriver (4.23.0)
|
selenium-webdriver (4.23.0)
|
||||||
base64 (~> 0.2)
|
base64 (~> 0.2)
|
||||||
|
@ -634,6 +674,8 @@ DEPENDENCIES
|
||||||
config
|
config
|
||||||
connection_pool
|
connection_pool
|
||||||
dalli
|
dalli
|
||||||
|
danger
|
||||||
|
danger-auto_label
|
||||||
dartsass-sprockets
|
dartsass-sprockets
|
||||||
debug
|
debug
|
||||||
debug_inspector
|
debug_inspector
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue