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

[#493] Integrate Danger to the generated project #579

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
11 changes: 1 addition & 10 deletions .github/workflows/review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
thawzintoe-ptut marked this conversation as resolved.
Show resolved Hide resolved

- name: Cache gems
uses: actions/cache@v2
Expand All @@ -62,16 +63,6 @@ jobs:
restore-keys: |
${{ runner.os }}-gems-

- name: Install Bundle and check environment versions
run: |
echo 'Install Bundle'
bundle config path vendor/bundle
bundle install
echo 'Check environment setup versions'
ruby --version
gem --version
bundler --version

- name: Run Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 1 addition & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'danger'
gem "danger-checkstyle_format"
gem 'danger-android_lint'
gem 'danger-commit_lint'
gem 'danger-kotlin_detekt'
gem 'danger-shroud'
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Review pull request

on:
pull_request:
types: [ opened, reopened, ready_for_review, synchronize ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
review_pull_request:
if: github.event.pull_request.draft == false
name: Review pull request
runs-on: ubuntu-latest
environment: staging
timeout-minutes: 30
thawzintoe-ptut marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 100

- name: Cache Gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches/modules-*
~/.gradle/caches/jars-*
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Cache gems
uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-

- name: Install Bundle and check environment versions
run: |
echo 'Install Bundle'
bundle config path vendor/bundle
bundle install
echo 'Check environment setup versions'
ruby --version
gem --version
bundler --version
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above


- name: Run Danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec danger
38 changes: 38 additions & 0 deletions template-compose/Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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?

# Check commits lint and warn on all checks (instead of failing)
commit_lint.check warn: :all, disable: [:subject_length]

# Detekt output check
detekt_dir = "**/build/reports/detekt/detekt-result.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

# Android Lint output check
lint_dir = "**/**/build/reports/lint/lint-result.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

# Show Danger test coverage report from Kover for templates
# Report coverage of modified files, warn if total project coverage is under 80%
# or if any modified file's coverage is under 95%

kover_file_template = "app/build/reports/kover/report.xml"
markdown "## Kover report for $project:"
shroud.reportKover "$project: Unit Tests", kover_file_template, 80, 95, false
thawzintoe-ptut marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions template-compose/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'danger'
gem 'danger-android_lint'
gem 'danger-commit_lint'
gem 'danger-kotlin_detekt'
gem 'danger-shroud'
File renamed without changes.
Loading