Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Clean build output for regular builds #698

Merged
merged 17 commits into from Apr 26, 2018
Merged

Clean build output for regular builds #698

merged 17 commits into from Apr 26, 2018

Conversation

epeee
Copy link
Contributor

@epeee epeee commented Apr 11, 2018

a very first draft for #664 in order to get early feedback.

/**
* If the exception should be thrown if the release is not needed.
*/
public boolean isExplosive() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this one is public api, do we have to keep it and mark it deprecated? or can we remove it an create a 2.1.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep it and deprecate it. Can you create a static utility method like "deprecated(String message)" so that when we ship a new major version, we can wrap up all deprecations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, let's do so.

Copy link
Member

@mockitoguy mockitoguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice progress! Please remember to update the documentation and the templates (initShipkit task).

I love the idea of using StopExecutionException!

/**
* If the exception should be thrown if the release is not needed.
*/
public boolean isExplosive() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep it and deprecate it. Can you create a static utility method like "deprecated(String message)" so that when we ship a new major version, we can wrap up all deprecations?

"Checking if release is needed", asList("./gradlew", ReleaseNeededPlugin.ASSERT_RELEASE_NEEDED_TASK), ExecCommandFactory.stopExecution()));
"Checking if release is needed", asList("./gradlew", ReleaseNeededPlugin.RELEASE_NEEDED), execResult -> {
if (new File(project.getBuildDir(), ReleaseNeeded.RELEASE_NEEDED_FILENAME).exists()) {
throw new StopExecutionException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really cunning idea. Nice!

LOG.lifecycle(message);
File releaseNeededFile = new File(task.getProject().getBuildDir(), RELEASE_NEEDED_FILENAME);

if (releaseNeededFile.exists()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! We need to delete the file.

Can you make it the first thing that happens in this task?

}

if (releaseNeeded) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use IOUtil.writeFile() and save 8 lines of code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 , thx for this hint!

@@ -28,11 +33,24 @@ boolean releaseNeeded(ReleaseNeededTask task, EnvVariables envVariables) {
boolean releaseNeeded = releaseNeed.needed;
String message = releaseNeed.explanation;

if (!releaseNeeded && task.isExplosive()) {
throw new GradleException(message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility, please keep the behavior.

//Task that throws an exception when release is not needed is very useful for CI workflows
//Travis CI job will stop executing further commands if assertReleaseNeeded fails.
//See the example projects how we have set up the 'assertReleaseNeeded' task in CI pipeline.
releaseNeededTask(project, ASSERT_RELEASE_NEEDED_TASK, conf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility, please keep the task. I suggest to emit deprecated message when the task is executed, including information how to fix the deprecation.

@epeee
Copy link
Contributor Author

epeee commented Apr 14, 2018

@mockitoguy thx for your feedback.
The only part which I was not able to cover is the templates (initShipkit task) part. Maybe I have overlooked something but I could not find any parts which would require a change. Did I miss something?

@epeee epeee changed the title WIP: Clean build output for regular builds Clean build output for regular builds Apr 16, 2018
@mockitoguy
Copy link
Member

I'll complete the review today! Thanks!

Copy link
Member

@mockitoguy mockitoguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added changes on top of your PR and we're ready. Check them out and push at will!

 - stop execution if file is not present
@epeee
Copy link
Contributor Author

epeee commented Apr 25, 2018

I just did some local testing using shipkit-example project:

./gradlew ciPerformRelease
  Building version '0.16.14' (value loaded from 'version.properties' file).
  [INCUBATING] upgrade-dependency plugin is incubating and may change in any version.
:ciPerformRelease
  Checking if release is needed:
    ./gradlew releaseNeeded
[releaseNeeded] Starting a Gradle Daemon, 1 busy and 1 stopped Daemons could not be reused, use --status for details
[releaseNeeded]   Building version '0.16.14' (value loaded from 'version.properties' file).
[releaseNeeded]   [INCUBATING] upgrade-dependency plugin is incubating and may change in any version.
[releaseNeeded] :identifyGitBranch
[releaseNeeded]   Executing:
[releaseNeeded]     git rev-parse --abbrev-ref HEAD
[releaseNeeded]   Identified current branch: release/ep
[releaseNeeded] :api:downloadPreviousReleaseArtifacts
[releaseNeeded]   Downloading remote artifact
[releaseNeeded]   - from https://bintray.com/shipkit/examples/download_file?file_path=org/mockito/shipkit-example/api/0.16.13/api-0.16.13-sources.jar
[releaseNeeded]   - and saving it to /home/ep/tmp/shipkit-example/subprojects/api/build/previous-release-artifacts/api-0.16.13-sources.jar
[releaseNeeded] :api:createDependencyInfoFile
[releaseNeeded] :api:sourcesJar UP-TO-DATE
[releaseNeeded] :api:comparePublications
[releaseNeeded] :api:comparePublications - about to compare publications
[releaseNeeded] :api:comparePublications - META-INF/dependency-info.md files equal: true
[releaseNeeded] :api:comparePublications - source jars equal: true
[releaseNeeded] :api:comparePublications - You can find detailed publication comparison results in file /home/ep/tmp/shipkit-example/subprojects/api/build/publications-comparison.txt.
[releaseNeeded] :impl:downloadPreviousReleaseArtifacts
[releaseNeeded]   Downloading remote artifact
[releaseNeeded]   - from https://bintray.com/shipkit/examples/download_file?file_path=org/mockito/shipkit-example/impl/0.16.13/impl-0.16.13-sources.jar
[releaseNeeded]   - and saving it to /home/ep/tmp/shipkit-example/subprojects/impl/build/previous-release-artifacts/impl-0.16.13-sources.jar
[releaseNeeded] :api:compileJava UP-TO-DATE
[releaseNeeded] :api:processResources NO-SOURCE
[releaseNeeded] :api:classes UP-TO-DATE
[releaseNeeded] :api:jar UP-TO-DATE
[releaseNeeded] :impl:createDependencyInfoFile
[releaseNeeded] :impl:sourcesJar UP-TO-DATE
[releaseNeeded] :impl:comparePublications
[releaseNeeded] :impl:comparePublications - about to compare publications
[releaseNeeded] :impl:comparePublications - META-INF/dependency-info.md files equal: true
[releaseNeeded] :impl:comparePublications - source jars equal: true
[releaseNeeded] :impl:comparePublications - You can find detailed publication comparison results in file /home/ep/tmp/shipkit-example/subprojects/impl/build/publications-comparison.txt.
[releaseNeeded] :releaseNeeded
[releaseNeeded]   Commit message to inspect for keywords '[ci skip-release]' and '[ci skip-compare-publications]': <unknown commit message>
[releaseNeeded]   Current branch 'release/ep' matches 'master|release/.+': true
[releaseNeeded] 
[releaseNeeded]   Compared 2 publication(s). No changes since previous release!
[releaseNeeded] 
[releaseNeeded] Release is considered _not_ needed when:
[releaseNeeded]  - 'SKIP_RELEASE' environment variable is present (currently: false)
[releaseNeeded]  - commit message contains '[ci skip-release]' (currently: false)
[releaseNeeded]  - we are building a "pull request" (currently: false)
[releaseNeeded] Release is needed when all above is false and: 
[releaseNeeded]  - we are building on a branch that matches regex 'master|release/.+' (currently: true)
[releaseNeeded]  - and one of the following criteria is true:
[releaseNeeded]    - there are changes in the binaries when compared to previous version (currently: false)
[releaseNeeded]    - commit message contains '[ci skip-compare-publications]' (currently: false)
[releaseNeeded]    - 'skipComparePublications' property on task releaseNeeded is true (currently: false)
[releaseNeeded] 
[releaseNeeded]  Skipping release because publications are identical.
[releaseNeeded] 
[releaseNeeded] BUILD SUCCESSFUL
[releaseNeeded] 
[releaseNeeded] Total time: 10.369 secs
  External process [releaseNeeded] completed.

BUILD SUCCESSFUL

Total time: 12.484 secs

@epeee epeee merged commit daf1edc into master Apr 26, 2018
@epeee epeee deleted the ep4 branch April 26, 2018 04:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants