Skip to content

Commit

Permalink
Merge pull request #942 from mikepenz/develop
Browse files Browse the repository at this point in the history
dev -> main
  • Loading branch information
mikepenz authored Nov 9, 2020
2 parents 38c551a + 07265a6 commit af14b47
Show file tree
Hide file tree
Showing 21 changed files with 527 additions and 88 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
28 changes: 28 additions & 0 deletions .github/config/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"feature"
]
},
{
"title": "## 🐛 Fixes",
"labels": [
"fix"
]
},
{
"title": "## 🧪 Tests",
"labels": [
"test"
]
},
{
"title": "## 💬 Other",
"labels": [
"other"
]
}
]
}
179 changes: 148 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,152 @@
# Thanks to https://github.com/coil-kt/coil/blob/master/.github/workflows/ci.yml

name: CI

on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
passphrase:
description: 'Passphrase required for secrets'
required: true
version:
description: 'Version to build'
required: true
pull_request:

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

# Ensure .gradle/caches is empty before writing to it.
# This helps us stay within Github's cache size limits.
- name: Clean Cache
run: rm -rf ~/.gradle/caches

# Restore the cache.
# Intentionally don't set 'restore-keys' so the cache never contains redundant dependencies.
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/build.gradle') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} }}

- name: Build
run: ./gradlew clean build

- name: Test
run: ./gradlew test

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

- 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 app:assembleDebug

- 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 Secrets
if: github.event_name == 'workflow_dispatch'
run: |
echo "::add-mask::$INPUT_PASSPHRASE"
BINTRAY_API_KEY=$(echo "${{ secrets.BINTRAY_API_KEY }}" | gpg -d --passphrase "$INPUT_PASSPHRASE" --batch)
echo "::add-mask::$BINTRAY_API_KEY"
echo "BINTRAY_API_KEY=$BINTRAY_API_KEY" >> $GITHUB_ENV
BINTRAY_GPG_PASS=$(echo "${{ secrets.BINTRAY_GPG_PASS }}" | gpg -d --passphrase "$INPUT_PASSPHRASE" --batch)
echo "::add-mask::$BINTRAY_GPG_PASS"
echo "BINTRAY_GPG_PASS=$BINTRAY_GPG_PASS" >> $GITHUB_ENV
NEXUS_PASSWORD=$(echo "${{ secrets.NEXUS_PASSWORD }}" | gpg -d --passphrase "$INPUT_PASSPHRASE" --batch)
echo "::add-mask::$NEXUS_PASSWORD"
echo "NEXUS_PASSWORD=$NEXUS_PASSWORD" >> $GITHUB_ENV
env:
INPUT_VERSION: ${{ github.event.inputs.version }}

- name: Prepare Keystore and Local.
if: github.event_name == 'workflow_dispatch'
run: |
echo "::add-mask::$INPUT_PASSPHRASE"
echo "${{ secrets.KEYSTORE }}" > opensource.jks.asc
gpg -d --passphrase "$INPUT_PASSPHRASE" --batch "opensource.jks.asc" > "app/opensource.jks"
echo "${{ secrets.SIGNING_GRADLE }}" > signing.gradle.asc
gpg -d --passphrase "$INPUT_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: Relase bintray
if: startsWith(github.ref, 'refs/tags/')
run: |
./gradlew build -x test -x lint
./gradlew library-core:bintrayUpload -x test -x lint -Plibrary_core_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-binding:bintrayUpload -x test -x lint -Plibrary_extensions_binding_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-diff:bintrayUpload -x test -x lint -Plibrary_extensions_diff_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-drag:bintrayUpload -x test -x lint -Plibrary_extensions_drag_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-expandable:bintrayUpload -x test -x lint -Plibrary_extensions_expandable_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-paged:bintrayUpload -x test -x lint -Plibrary_extensions_paged_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-scroll:bintrayUpload -x test -x lint -Plibrary_extensions_scroll_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-swipe:bintrayUpload -x test -x lint -Plibrary_extensions_swipe_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-ui:bintrayUpload -x test -x lint -Plibrary_extensions_ui_only --no-configure-on-demand --no-parallel
./gradlew library-extensions-utils:bintrayUpload -x test -x lint -Plibrary_extensions_utils_only --no-configure-on-demand --no-parallel
env:
BINTRAY_USER: ${{ secrets.BINTRAY_USER }}
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}

- 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: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
if: startsWith(github.ref, 'refs/tags/')
with:
configuration: ".github/config/configuration.json"
ignorePreReleases: ${{ !contains(github.ref, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release
uses: softprops/action-gh-release@91409e712cf565ce9eff10c87a8d1b11b81757ae
if: startsWith(github.ref, 'refs/tags/')
with:
body: ${{steps.github_release.outputs.changelog}}
prerelease: ${{ contains(github.event.inputs.version, '-rc') || contains(github.event.inputs.version, '-b') || contains(github.event.inputs.version, '-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
48 changes: 48 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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, setting.length-12]

# AndroidLint
androidLintFile = String.new(gradleModule + "/build/reports/lint-results.xml")
androidLintDebugFile = String.new(gradleModule + "/build/reports/lint-results-debug.xml")
if File.file?(androidLintFile) || File.file?(androidLintDebugFile)
android_lint.skip_gradle_task = true
android_lint.severity = "Warning"
if File.file?(androidLintFile)
android_lint.report_file = androidLintFile
else
android_lint.report_file = androidLintDebugFile
end
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.6)
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
Loading

0 comments on commit af14b47

Please sign in to comment.