All Projects → worker8 → AndroidLintReporter

worker8 / AndroidLintReporter

Licence: other
Gradle Plugin to report Android Lint and Detekt result back to Github Pull Request

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to AndroidLintReporter

Retropiler
PoC of Java8 Standard Library for Android for API version >= 15
Stars: ✭ 159 (+622.73%)
Mutual labels:  gradle-plugin
Jarfilterplugin
Help exclude classes before building the JAR into Android DEX archives.
Stars: ✭ 189 (+759.09%)
Mutual labels:  gradle-plugin
Moko Widgets
Multiplatform UI DSL with screen management in common code for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 227 (+931.82%)
Mutual labels:  gradle-plugin
Dexguard
Android app防dex2jar的gradle插件
Stars: ✭ 174 (+690.91%)
Mutual labels:  gradle-plugin
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (+709.09%)
Mutual labels:  gradle-plugin
Gradle Swagger Generator Plugin
Gradle plugin for OpenAPI YAML validation, code generation and API document publishing
Stars: ✭ 197 (+795.45%)
Mutual labels:  gradle-plugin
Shipkit
Toolkit for shipping it used by Mockito library
Stars: ✭ 157 (+613.64%)
Mutual labels:  gradle-plugin
Coveralls Gradle Plugin
👨‍🔧 gradle plugin for coveralls
Stars: ✭ 250 (+1036.36%)
Mutual labels:  gradle-plugin
Gradle Testsets Plugin
A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
Stars: ✭ 182 (+727.27%)
Mutual labels:  gradle-plugin
Badass Jlink Plugin
Create a custom runtime image of your modular application
Stars: ✭ 216 (+881.82%)
Mutual labels:  gradle-plugin
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (+695.45%)
Mutual labels:  gradle-plugin
Gradle Launch4j
A gradle-plugin to create windows executables with launch4j
Stars: ✭ 177 (+704.55%)
Mutual labels:  gradle-plugin
Gradle Errorprone Plugin
Gradle plugin to use the error-prone compiler for Java
Stars: ✭ 202 (+818.18%)
Mutual labels:  gradle-plugin
Vue Kotlin
Libraries and tools supporting the use of Vue.js in Kotlin.
Stars: ✭ 162 (+636.36%)
Mutual labels:  gradle-plugin
Gradle Android Git Version
A gradle plugin to calculate Android-friendly version names and codes from git tags
Stars: ✭ 227 (+931.82%)
Mutual labels:  gradle-plugin
Versioning
Gradle plug-in to generate version information from the SCM branch (Git or Svn)
Stars: ✭ 157 (+613.64%)
Mutual labels:  gradle-plugin
Gradle Baseline
A set of Gradle plugins that configure default code quality tools for developers.
Stars: ✭ 191 (+768.18%)
Mutual labels:  gradle-plugin
Avito Android
Infrastructure of Avito android
Stars: ✭ 253 (+1050%)
Mutual labels:  gradle-plugin
Gradle Cargo Plugin
Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Stars: ✭ 238 (+981.82%)
Mutual labels:  gradle-plugin
Javafx Gradle Plugin
Gradle plugin that makes it easy to work with JavaFX 11+
Stars: ✭ 214 (+872.73%)
Mutual labels:  gradle-plugin

AndroidLintReporter License: MIT

Android Lint Reporter Logo

This is a Gradle Plugin to report Android Lint and Detekt result back to Github Pull Request. This is targeted for someone who's doing Android Development and using Github who wants to run Android Lint and Detekt on their pull request. (Currently, this plugin assumes the usage of both Android Lint and Detekt)

Here is how it works using Github Actions (it can be used in other CI as well).

( 1 ) When a Pull Request is created, a Github Actions will be triggered:


( 2 ) This will produce this lint report, and it will be reported back in the Pull Request:
  • then you can fix the lint warnings and push again

How to Setup

There are a couple of steps needed to set up everything.

1. Github Actions

First, we need to set up a Github Action trigger to run Detekt and Android Lint.

Add a file in .github/workflows/run-lint.yml (you can name it anything) in the root of your project:

name: Android Pull Request & Master CI

on:
  pull_request:
    branches:
      - 'master'
  push:
    branches:
      - 'master'

jobs:
  lint:
    name: Run Lint
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1
      - name: setup JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Run detekt
        run: ./gradlew detekt
        continue-on-error: true
      - name: Run Android Lint
        run: ./gradlew lint
      - name: Run Android Lint Reporter to report Lint and Detekt result to PR 
        env:
          PR_NUMBER: ${{ github.event.number }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          ./gradlew report -PgithubPullRequestId=$PR_NUMBER -PgithubToken=$GITHUB_TOKEN
How to get Github Token
  1. Go to Github's Settings --> Developer settings --> Generate new token.
Screen Shot 2020-03-19 at 16 13 44
  1. Go to Personal Access Token, and click Generate new token:
  • Check for Repo (all) and workflow
Screen Shot 2020-03-19 at 16 14 18
  1. It's better to make a bot account and use the token of the bot account

How to add GITHUB_TOKEN

After generating the token, paste it under Settings --> Secrets:

image

2. Add repositories and classpath:

  • build.gradle:

Groovy

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.com.worker8.android_lint_reporter:android_lint_reporter:<latest_version>"
  }
}

Kotlin

buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("gradle.plugin.com.worker8.android_lint_reporter:android_lint_reporter:<latest_version>")
  }
}

Note: latest_version can be found here: https://plugins.gradle.org/plugin/com.worker8.android_lint_reporter

3. Add the plugin dependency:

  • app/build.gradle:

Groovy

plugins {
    id "com.worker8.android_lint_reporter"
}
android_lint_reporter {
    lintFilePath = "./app/build/reports/lint-results.xml"
    detektFilePath = ".app/build/reports/detekt_reports.xml"
    githubOwner = "worker8"
    githubRepositoryName = "AndroidLintReporter"
    showLog = true // optional - default to false, show extra information, will slow things down
}

Kotlin

plugins {
    id("com.worker8.android_lint_reporter")
}
android_lint_reporter {
    lintFilePath = "./app/build/reports/lint-results.xml"
    detektFilePath = ".app/build/reports/detekt_reports.xml"
    githubOwner = "worker8"
    githubRepositoryName = "AndroidLintReporter"
    showLog = true // optional - default to false, show extra information, will slow things down
}

4. You are ready!

Try making a pull request, and you should see the Github Actions running under "Check" tab. When it's done, you should see your lint report being posted back to your pull request.

Development

For those who is interested to contribute or fork it. Here's a blog post I wrote explaining the source code of this repo: https://bloggie.io/@_junrong/the-making-of-android-lint-reporter

Suggested IDE for development:

Download Intellij Community Edition for free and open this project.

Setup Github Personal Access Token(PAT)

Prepare a file local.properties based on local.properties.TEMPLATE in the root directory of this project, with the following content:

github_token=<replace with your Github Personal Access Token (PAT)>
github_owner=<replace with your Github Owner Name>
github_repository=<replace with your Github Repository Name>

You can test your Github API using your PAT using cURL:

curl -H "Authorization: token <github_token>" -H "Content-Type: application/json" --data '{"body":"test123abc"}' -X POST https://api.github.com/repos/<github_token>/<GITHUB_PROJECT>/issues/<PR_OR_ISSUE_NUMBER>/comments

run Functional Test The gist of this plugin is located in the class of AndroidLintReporterPlugin.kt. After setting everything up, you can run the test using this command:

./gradlew functionalTest

To deploy:

  1. Download secrets from https://plugins.gradle.org/ after logging in.
  2. up version in build.gradle.kts
  3. then run ./gradlew publishPlugin

Changelog

Refer to https://github.com/worker8/AndroidLintReporter/releases

License

Copyright 2020 Tan Jun Rong

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].