Permalink
Browse files

UploadGistsPlugin applied in TestDownstreamPlugin

  • Loading branch information...
wwilk committed Oct 13, 2017
1 parent 3d740ad commit ad63e78cfb10556432ab13e463b3376095c109ac
View
@@ -34,9 +34,3 @@ cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
after_success:
- ./gradlew uploadGists
after_failure:
- ./gradlew uploadGists
View
@@ -12,6 +12,3 @@ afterEvaluate {
}
apply plugin: 'org.shipkit.upgrade-dependency'
apply plugin: 'org.shipkit.upload-gists'
project.tasks.uploadGists.filesToUpload = project.fileTree("subprojects/testDownstream/build").filter {it.name.endsWith(".log")}
@@ -3,9 +3,14 @@
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.specs.Spec;
import org.shipkit.internal.gradle.release.UploadGistsPlugin;
import org.shipkit.internal.gradle.release.tasks.UploadGistsTask;
import org.shipkit.internal.gradle.util.TaskMaker;
import org.shipkit.internal.util.IncubatingWarning;
import java.io.File;
/**
* This plugin tests your library end-to-end (e2e) using downstream projects.
* It adds testDownstream task which can be configured to run tests for certain repositories
@@ -22,12 +27,30 @@
public void apply(final Project project) {
IncubatingWarning.warn("downstream-testing plugin");
TaskMaker.task(project, TEST_DOWNSTREAM_TASK, TestDownstreamTask.class, new Action<TestDownstreamTask>() {
project.getPlugins().apply(UploadGistsPlugin.class);
TestDownstreamTask testDownstreamTask = TaskMaker.task(project, TEST_DOWNSTREAM_TASK, TestDownstreamTask.class, new Action<TestDownstreamTask>() {
@Override
public void execute(TestDownstreamTask task) {
task.setDescription("Runs all downstream tests.");
}
});
final UploadGistsTask uploadGistsTask = (UploadGistsTask) project.getTasks().findByName(UploadGistsPlugin.UPLOAD_GISTS_TASK);
uploadGistsTask.setFilesToUpload(
project
.fileTree(testDownstreamTask.getLogDirectory())
.filter(new Spec<File>() {
@Override
public boolean isSatisfiedBy(File file) {
return file.getName().endsWith(".log");
}
})
);
testDownstreamTask.finalizedBy(uploadGistsTask);
}
}
@@ -78,7 +78,7 @@ private CloneGitRepositoryTask createCloneProjectToWorkDirTask(String camelCaseR
}
private void createRunTestReleaseTask(final String camelCaseRepoName, CloneGitRepositoryTask copy) {
final File buildOutputFile = new File(getProject().getBuildDir(), camelCaseRepoName + "-build.log");
final File buildOutputFile = new File(getLogDirectory(), camelCaseRepoName + "-build.log");
SilentExecTask run = getProject().getTasks().create(
"test" + capitalize(camelCaseRepoName),
SilentExecTask.class);
@@ -104,4 +104,8 @@ public void execute(Task task) {
}
});
}
protected File getLogDirectory() {
return getProject().getBuildDir();
}
}
@@ -24,11 +24,13 @@
*/
public class UploadGistsPlugin implements Plugin<Project> {
public static final String UPLOAD_GISTS_TASK = "uploadGists";
@Override
public void apply(final Project project) {
final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration();
TaskMaker.task(project, "uploadGists", UploadGistsTask.class, new Action<UploadGistsTask>() {
TaskMaker.task(project, UPLOAD_GISTS_TASK, UploadGistsTask.class, new Action<UploadGistsTask>() {
@Override
public void execute(UploadGistsTask uploadGistsTask) {
uploadGistsTask.setDescription("Uploads to Gist files provided by 'filesToUpload' task property.");
@@ -1,11 +1,9 @@
package org.shipkit.internal.gradle.downstream.test
import org.gradle.testfixtures.ProjectBuilder
import spock.lang.Specification
import org.shipkit.internal.gradle.release.tasks.UploadGistsTask
import testutil.PluginSpecification
class TestDownstreamPluginTest extends Specification {
def project = new ProjectBuilder().build()
class TestDownstreamPluginTest extends PluginSpecification {
def "should apply plugin and create testDownstream task"() {
when:
@@ -15,4 +13,19 @@ class TestDownstreamPluginTest extends Specification {
project.tasks.testDownstream
}
def "should find log files for uploadGists in log directory"() {
given:
project.setBuildDir(tmp.root)
tmp.newFile("a.log")
tmp.newFile("b.log")
tmp.newFile("c.txt")
when:
project.plugins.apply(TestDownstreamPlugin)
then:
UploadGistsTask uploadGists = project.tasks.uploadGists
uploadGists.filesToUpload.collect{ it.name } == ["a.log", "b.log"]
}
}

0 comments on commit ad63e78

Please sign in to comment.