Skip to content

Commit

Permalink
[#493] Create New files for Danger integration in template android
Browse files Browse the repository at this point in the history
  • Loading branch information
thawzintoe-ptut committed Jun 4, 2024
1 parent dc5d66c commit b1176cb
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 0 deletions.
71 changes: 71 additions & 0 deletions template-compose/.github/workflows/review_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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: dev
timeout-minutes: 30
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: Run Detekt
run: ./gradlew detekt

- name: Run Android Lint
run: ./gradlew lintDevDebug

- name: Run unit tests with Kover
run: ./gradlew koverXmlReport

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- 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
- 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
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'
117 changes: 117 additions & 0 deletions template-compose/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
ansi (1.5.0)
ast (2.4.2)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (8.6.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 2.0)
faraday-http-cache (~> 2.0)
git (~> 1.7)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (>= 1, < 4)
danger-android_lint (0.0.11)
danger-plugin-api (~> 1.0)
oga
danger-commit_lint (0.0.7)
danger-plugin-api (~> 1.0)
danger-kotlin_detekt (0.0.3)
danger-plugin-api (~> 1.0)
danger-plugin-api (1.0.0)
danger (> 2.0)
danger-shroud (0.0.5)
danger-plugin-api (~> 1.0)
nokogiri
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-http-cache (2.4.1)
faraday (>= 0.8)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
git (1.13.2)
addressable (~> 2.8)
rchardet (~> 1.8)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
multipart-post (2.2.3)
nap (1.1.0)
no_proxy_fix (0.1.2)
nokogiri (1.14.3-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-linux)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
oga (3.4)
ast
ruby-ll (~> 2.1)
open4 (1.3.4)
public_suffix (5.0.1)
racc (1.6.2)
rchardet (1.8.0)
rexml (3.2.5)
ruby-ll (2.1.2)
ansi
ast
ruby2_keywords (0.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.3.0)

PLATFORMS
universal-darwin-21
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
danger
danger-android_lint
danger-commit_lint
danger-kotlin_detekt
danger-shroud

BUNDLED WITH
2.3.1

0 comments on commit b1176cb

Please sign in to comment.