Skip to content

Commit

Permalink
- define proper pipeline
Browse files Browse the repository at this point in the history
- build release app when tagged
- run danger
- report lint, detekt issues
  • Loading branch information
mikepenz committed Oct 2, 2020
1 parent 9c0c0f0 commit 272109f
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 38 deletions.
8 changes: 8 additions & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.workers.max=2
org.gradle.jvmargs=-Xmx6G
org.gradle.caching=true
org.gradle.configureondemand=true
# parallel kapt
kapt.use.worker.api=true
116 changes: 91 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,95 @@
# Thanks to https://github.com/coil-kt/coil/blob/master/.github/workflows/ci.yml

name: CI

on:
pull_request:
push:
tags:
- '*'
pull_request:

jobs:
ci:
name: Build + Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Checkout Gradle Build Cache
if: ${{ steps.self_hosted.outputs.FLAG != 'self-hosted' }}
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
!~/.gradle/wrapper/dists/**/gradle*.zip
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Build
run: ./gradlew clean build

- name: Detekt
run: ./gradlew detekt
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Validate gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Checkout Gradle Build Cache
if: ${{ steps.self_hosted.outputs.FLAG != 'self-hosted' }}
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
!~/.gradle/wrapper/dists/**/gradle*.zip
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Build Debug
run: ./gradlew clean buildDebug

- name: Run Lint
if: github.event_name == 'pull_request'
run: ./gradlew lintDebug

- name: Detekt
if: github.event_name == 'pull_request'
run: ./gradlew detekt

- name: Setup Ruby
if: github.event_name == 'pull_request'
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6.3'
bundler-cache: true

- name: Run Danger
if: github.event_name == 'pull_request'
run: |
gem install danger
bundle exec danger --dangerfile=Dangerfile --danger_id=danger-pr
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare Keystore and Local.
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "${{ secrets.KEYSTORE }}" > opensource.jks.asc
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSPHRASE }}" --batch "opensource.jks.asc" > "app/opensource.jks"
echo "${{ secrets.SIGNING_GRADLE }}" > signing.gradle.asc
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSPHRASE }}" --batch "signing.gradle.asc" > "app/signing.gradle"
echo "openSource.signing.file=signing.gradle" >> local.properties
- name: Build Release App
if: startsWith(github.ref, 'refs/tags/')
run: ./gradlew app:assembleStaging app:assembleRelease app:bundleRelease

- name: Collect artifacts
run: |
COLLECT_PWD=${PWD}
mkdir -p "artifacts"
find . -name "*.apk" -type f -exec cp {} "artifacts" \;
find . -name "*.aab" -type f -exec cp {} "artifacts" \;
- name: Archive Artifacts
uses: actions/upload-artifact@v2
with:
name: "App-Artifacts"
path: artifacts/*

- name: Release
uses: softprops/action-gh-release@91409e712cf565ce9eff10c87a8d1b11b81757ae
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-b') || contains(github.ref, '-a') }}
files: artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 0 additions & 10 deletions .github/workflows/gradle-wrapper-validation.yml

This file was deleted.

2 changes: 1 addition & 1 deletion DEV/default-detekt-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ formatting:
ImportOrdering:
active: false
Indentation:
active: true
active: false
autoCorrect: true
indentSize: 4
continuationIndentSize: 8
Expand Down
45 changes: 45 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
github.dismiss_out_of_range_messages

# Make it more obvious that a PR is a work in progress and shouldn't be merged yet.
has_wip_label = github.pr_labels.any? { |label| label.include? "Engineers at work" }
has_wip_title = github.pr_title.include? "[WIP]"

if has_wip_label || has_wip_title
warn("PR is marked as Work in Progress")
end

# Ensure the PR is not marked as DO NOT MERGE
fail("PR specifies label DO NOT MERGE") if github.pr_labels.any? { |label| label.include? "DO NOT MERGE" }

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

File.open("settings.gradle", "r") do |file_handle|
file_handle.each_line do |setting|
if setting.include? "include"
gradleModule = setting[10..-1]

message(gradleModule)

# AndroidLint
androidLintFile = String.new(gradleModule + "/build/reports/lint-results.xml")
if File.file?(androidLintFile)
android_lint.skip_gradle_task = true
android_lint.severity = "Warning"
android_lint.report_file = androidLintFile
android_lint.filtering = true
android_lint.lint(inline_mode: true)
end

# Detekt
detektFile = String.new(gradleModule + "/build/reports/detekt.xml")
if File.file?(detektFile)
kotlin_detekt.report_file = detektFile
kotlin_detekt.skip_gradle_task = true
kotlin_detekt.severity = "warning"
kotlin_detekt.filtering = true
kotlin_detekt.detekt(inline_mode: true)
end
end
end
end
10 changes: 9 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
gem "jekyll-readme-index"
# 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-kotlin_detekt'
78 changes: 78 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ansi (1.5.0)
ast (2.4.1)
claide (1.0.3)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (8.0.5)
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)
danger-android_lint (0.0.8)
danger-plugin-api (~> 1.0)
oga
danger-kotlin_detekt (0.0.3)
danger-plugin-api (~> 1.0)
danger-plugin-api (1.0.0)
danger (> 2.0)
faraday (1.0.1)
multipart-post (>= 1.2, < 3)
faraday-http-cache (2.2.0)
faraday (>= 0.8)
git (1.7.0)
rchardet (~> 1.8)
kramdown (2.3.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
multipart-post (2.1.1)
nap (1.1.0)
no_proxy_fix (0.1.2)
octokit (4.18.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
oga (3.3)
ast
ruby-ll (~> 2.1)
open4 (1.3.4)
public_suffix (4.0.6)
rchardet (1.8.0)
rexml (3.2.4)
ruby-ll (2.1.2)
ansi
ast
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.7.0)

PLATFORMS
ruby

DEPENDENCIES
danger
danger-android_lint
danger-kotlin_detekt

BUNDLED WITH
2.1.4
1 change: 0 additions & 1 deletion detekt.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ detekt {
toolVersion = "${versions.detekt}"
//input = files("src/main/kotlin")
config = files(buildscript.sourceFile.getParent().toString() + "/DEV/default-detekt-config.yml")

}

0 comments on commit 272109f

Please sign in to comment.