Skip to content

Commit

Permalink
Allow configuration of executable check goals
Browse files Browse the repository at this point in the history
  • Loading branch information
DaGeRe committed Nov 4, 2023
1 parent 7e6777a commit d9ddd1d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ExecutionConfig implements FolderConfig, Serializable {
private long timeout = 5 * 60 * 1000;
private String cleanGoal;
private String testGoal;
private List<String> executableCheckGoals;
private List<String> includes = new LinkedList<>();
private List<String> excludes = new LinkedList<>();
private List<String> includeByRule = new LinkedList<>();
Expand Down Expand Up @@ -200,6 +201,15 @@ public String getTestGoal() {
public void setTestGoal(final String testGoal) {
this.testGoal = testGoal;
}

public List<String> getExecutableCheckGoals() {
return executableCheckGoals;
}

@JsonInclude(Include.NON_EMPTY)
public void setExecutableCheckGoals(List<String> executableCheckGoals) {
this.executableCheckGoals = executableCheckGoals;
}

@JsonInclude(Include.NON_EMPTY)
public List<String> getIncludes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class ExecutionConfigMixin {
+ "If you want to run integration tests in maven e.g. by calling failsafe, also specify it here. ")
protected String testGoal;

@Option(names = { "-executableCheckGoals",
"--executableCheckGoals" }, split = ";", description = "Goals that should be used for checking whether a commit is executable *currently only for gradle* (by default testClasses and assemble for non-android projects, assemble for android projects)")
protected String[] executableCheckGoals;

@Option(names = { "-cleanGoal", "--cleanGoal" }, description = "Clean goal that is called before the test execution *in Gradle*; defaults to cleanTest.")
protected String cleanGoal;

Expand Down Expand Up @@ -183,6 +187,14 @@ public String getTestGoal() {
return testGoal;
}

public void setExecutableCheckGoals(String[] executableCheckGoals) {
this.executableCheckGoals = executableCheckGoals;
}

public String[] getExecutableCheckGoals() {
return executableCheckGoals;
}

public void setCleanGoal(String cleanGoal) {
this.cleanGoal = cleanGoal;
}
Expand Down Expand Up @@ -424,18 +436,18 @@ public void setAndroidGradleTasks(String[] androidGradleTasks) {
}

public String getAndroidGradleVersion() {
return androidGradleVersion;
return androidGradleVersion;
}

public void setAndroidGradleVersion(String androidGradleVersion) {
this.androidGradleVersion = androidGradleVersion;
this.androidGradleVersion = androidGradleVersion;
}

public String getAndroidTestPackageName() {
return androidTestPackageName;
}

public void setAndroidTestPackageName(String androidTestPackageName) {
public void setAndroidTestPackageName(String androidTestPackageName) {
this.androidTestPackageName = androidTestPackageName;
}

Expand All @@ -454,6 +466,12 @@ public ExecutionConfig getExecutionConfig() {
config.setEndcommit(getEndcommit());
config.setLinearizeHistory(linearizeHistory);
config.setTestGoal(getTestGoal());
if (getExecutableCheckGoals() != null) {
for (String executableCheckGoal : getExecutableCheckGoals()) {
config.getExecutableCheckGoals().add(executableCheckGoal);
}
}

config.setCleanGoal(getCleanGoal());

if (getIncludes() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package de.dagere.peass.execution.gradle;

import java.io.File;
import java.util.Arrays;

import de.dagere.kopeme.parsing.GradleParseHelper;
import de.dagere.peass.config.MeasurementConfig;
import de.dagere.peass.execution.maven.BuildfileRunningTester;
import de.dagere.peass.execution.processutils.ProcessSuccessTester;
import de.dagere.peass.execution.utils.CommandConcatenator;
import de.dagere.peass.execution.utils.EnvironmentVariables;
import de.dagere.peass.execution.utils.ProjectModules;
import de.dagere.peass.execution.utils.TestExecutor;
Expand Down Expand Up @@ -45,11 +47,17 @@ public boolean isCommitRunning(final String commit, GradleTestExecutor executor)

executor.replaceAllBuildfiles(modules);

final String[] basicVars = new String[] {EnvironmentVariables.fetchGradleCall(), "--no-daemon"};
final String[] vars;
if (!isAndroid) {
vars = new String[] { EnvironmentVariables.fetchGradleCall(), "--no-daemon", measurementConfig.getExecutionConfig().getCleanGoal(), "testClasses", "assemble" };
if (measurementConfig.getExecutionConfig().getExecutableCheckGoals().isEmpty()) {
String[] temp = CommandConcatenator.concatenateCommandArrays(basicVars, new String[] {measurementConfig.getExecutionConfig().getCleanGoal() });
vars = CommandConcatenator.concatenateCommandArrays(temp, measurementConfig.getExecutionConfig().getExecutableCheckGoals().toArray(new String[0]));
} else {
vars = CommandConcatenator.concatenateCommandArrays(basicVars, new String[] {measurementConfig.getExecutionConfig().getCleanGoal(), "testClasses", "assemble"});
}
} else {
vars = new String[] { EnvironmentVariables.fetchGradleCall(), "--no-daemon", "assemble" };
vars = CommandConcatenator.concatenateCommandArrays(basicVars, new String[] {"assemble"});
}

ProcessSuccessTester processSuccessTester = new ProcessSuccessTester(folders, measurementConfig, env);
Expand Down

0 comments on commit d9ddd1d

Please sign in to comment.