btkelly / gnag

A Gradle plugin that helps facilitate GitHub PR checking and automatic commenting of violations.
http://gnag.watch
Apache License 2.0
125 stars 14 forks source link

Gnag tasks should take build variant into account #123

Open btkelly opened 8 years ago

btkelly commented 8 years ago

Currently there are two Gnag tasks, gnagCheck and gnagReport. Both of these tasks should be generated for each combination of product flavor and build type.

This would allow a consumer to only run the Gnag check / report on certain ones if required. The current gnagCheck and gnagReport should remain allowing the consumer to run Gnag for all variants and flavors.

stkent commented 8 years ago

Maybe this is controversial, but: should the gnag tasks maybe depend on lint tasks rather than the check task? It's not obvious to me that we should be coupling static code analysis with running the test suite.

stkent commented 8 years ago

The check task is also not separable by build variant, whereas the lint tasks are:

$ ./gradlew app:tasks --all | grep "check"
build - Assembles and tests this project. [assemble, check]
    checkApiaryManifest
    checkApiaryManifest
    checkDebugManifest
    checkDebugManifest
    checkDebugManifest
    checkReleaseManifest
    checkReleaseManifest
    checkSitManifest
    checkSitManifest
check - Runs all checks. [lint, test]
connectedCheck - Runs all device checks on currently connected devices. [connectedAndroidTest]
deviceCheck - Runs all device checks using Device Providers and Test Servers. [deviceAndroidTest]
gnagCheck - Runs Gnag checks and generates an HTML report [check]
gnagReport - Runs Gnag and generates a report to publish to GitHub and set the status of a PR [check, gnagCheck]
    checkApiaryManifest
    checkDebugManifest
    checkReleaseManifest
    checkSitManifest
    checkApiaryManifest
    checkDebugManifest
    checkReleaseManifest
    checkSitManifest
    checkApiaryManifest
    checkDebugManifest
    checkReleaseManifest
    checkSitManifest
$ ./gradlew app:tasks --all | grep "lint"
    lintVitalRelease - Runs lint on just the fatal issues in the release build.
check - Runs all checks. [lint, test]
lint - Runs lint on all variants. [:wearable:packageRelease]
lintApiary - Runs lint on the Apiary build.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build. [:wearable:packageRelease]
lintSit - Runs lint on the Sit build.
stkent commented 8 years ago

Here's some reference code that might be helpful:

https://github.com/x2on/gradle-hockeyapp-plugin/blob/master/src/main/groovy/de/felixschulze/gradle/HockeyAppPlugin.groovy#L52-L74

Obviously we would need to update the README to indicate that the gnag plugin must be applied after the Android plugin.

stkent commented 8 years ago

Also interesting to note:

$ ./gradlew app:tasks --all | grep "test"
build - Assembles and tests this project. [assemble, check]
buildDependents - Assembles and tests this project and all projects that depend on it. [build]
buildNeeded - Assembles and tests this project and all projects it depends on. [build]
mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build. [compileDebugAndroidTestSources]
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
check - Runs all checks. [lint, test]
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices. [connectedDebugAndroidTest]
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices. [assembleDebug, compileDebugAndroidTestSources]
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
test - Run unit tests for all variants. [testApiaryUnitTest, testDebugUnitTest, testReleaseUnitTest, testSitUnitTest]
testApiaryUnitTest - Run unit tests for the apiary build. [compileApiaryUnitTestSources, mockableAndroidJar]
testDebugUnitTest - Run unit tests for the debug build. [compileDebugUnitTestSources, mockableAndroidJar]
testReleaseUnitTest - Run unit tests for the release build. [compileReleaseUnitTestSources, mockableAndroidJar]
testSitUnitTest - Run unit tests for the sit build. [compileSitUnitTestSources, mockableAndroidJar]

Does this imply that check only runs unit test tasks, not connected device test tasks? 🤔

stkent commented 8 years ago

Taking a poke at this now.

stkent commented 8 years ago

See #126.