Skip to content

Commit

Permalink
[TEST] Try to cause the error of ktlint and detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
s2g090123 committed Apr 21, 2024
1 parent dad3105 commit c668971
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 45 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/danger_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,26 @@ on:
- '*'

jobs:
pr:
runs-on: ubuntu-latest

steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'

- name: Danger Checks
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gem install bundler
bundle install
bundle exec danger --dangerfile ./dangerfiles/DangerPR --danger_id=pr --new-comment --remove-previous-comments
ktlint:
runs-on: ubuntu-latest
needs: [pr]

steps:
- name: Checkout code
Expand Down Expand Up @@ -37,10 +55,11 @@ jobs:
run: |
gem install bundler
bundle install
bundle exec danger
bundle exec danger --dangerfile ./dangerfiles/DangerKtlint --danger_id=ktlint --new-comment --remove-previous-comments
detekt:
runs-on: ubuntu-latest
needs: [pr]

steps:
- name: Checkout code
Expand Down Expand Up @@ -70,10 +89,11 @@ jobs:
run: |
gem install bundler
bundle install
bundle exec danger
bundle exec danger --dangerfile ./dangerfiles/DangerDeteKt --danger_id=detekt --new-comment --remove-previous-comments
androidLint:
runs-on: ubuntu-latest
needs: [pr]

steps:
- name: Checkout code
Expand Down Expand Up @@ -103,4 +123,4 @@ jobs:
run: |
gem install bundler
bundle install
bundle exec danger
bundle exec danger --dangerfile ./dangerfiles/DangerAndroidLint --danger_id=androidlint --new-comment --remove-previous-comments
42 changes: 0 additions & 42 deletions Dangerfile

This file was deleted.

6 changes: 6 additions & 0 deletions dangerfiles/DangerAndroidLint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lint_dir = '**/build/reports/lint-results-debug.xml'
Dir[lint_dir].each do |file_name|
android_lint.skip_gradle_task = true
android_lint.report_file = file_name
android_lint.lint(inline_mode: true)
end
6 changes: 6 additions & 0 deletions dangerfiles/DangerDeteKt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
detekt_dir = "**/build/reports/detekt/detekt.xml"
Dir[detekt_dir].each do |file_name|
kotlin_detekt.skip_gradle_task = true
kotlin_detekt.report_file = file_name
kotlin_detekt.detekt(inline_mode: true)
end
12 changes: 12 additions & 0 deletions dangerfiles/DangerKtlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ktlint_dir = [
"**/build/reports/ktlint/ktlintAndroidTestSourceSetCheck/ktlintAndroidTestSourceSetCheck.json",
"**/build/reports/ktlint/ktlintMainSourceSetCheck/ktlintMainSourceSetCheck.json",
"**/build/reports/ktlint/ktlintTestSourceSetCheck/ktlintTestSourceSetCheck.json"
]
ktlint_dir.each do |dir|
Dir[dir].each do |file_name|
ktlint.skip_lint = true
ktlint.report_file = file_name
ktlint.lint(inline_mode: true)
end
end
13 changes: 13 additions & 0 deletions dangerfiles/DangerPR
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
message "Thanks @#{github.pr_author}!"

# Make it more obvious that a PR is a work in progress and shouldn't be merged yet
warn("PR is classed as Work in Progress") if github.pr_title.include? "WIP"

# Warn when there is a big PR
warn("Big PR") if git.lines_of_code > 500

# Warn to encourage a PR description
warn("Please provide a summary in the PR description to make it easier to review") if github.pr_body.length == 0

# Warn to encourage that labels should have been used on the PR
warn("Please add labels to this PR") if github.pr_labels.empty?

0 comments on commit c668971

Please sign in to comment.