Skip to content

Commit

Permalink
Merging refactor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vahila committed Jul 16, 2024
2 parents fb80e89 + 0589685 commit 313d60d
Show file tree
Hide file tree
Showing 121 changed files with 3,279 additions and 1,563 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ work

# Binaries and downloaded resources
src/main/resources/matlab-script-generator.zip
src/main/resources/run_matlab_command.*
src/main/resources/**/run-matlab-command*
src/main/resources/license.txt

**/.DS_Store
139 changes: 73 additions & 66 deletions CONFIGDOC.md

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<relativePath />
</parent>
<artifactId>matlab</artifactId>
<version>2.12.1-SNAPSHOT</version>
<version>2.13.2-SNAPSHOT</version>
<packaging>hpi</packaging>
<developers>
<developer>
Expand Down Expand Up @@ -140,7 +140,13 @@
<artifactId>jcabi-xml</artifactId>
<version>0.23.1</version>
</dependency>

<!-- Mockito -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -347,4 +353,4 @@
</plugins>
</pluginManagement>
</build>
</project>
</project>
11 changes: 3 additions & 8 deletions src/main/java/com/mathworks/ci/BuildArtifactAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@

public class BuildArtifactAction implements Action {
private Run<?, ?> build;
private FilePath workspace;
private int totalCount;
private int skipCount;
private int failCount;
private static final String ROOT_ELEMENT = "taskDetails";
private static final String BUILD_ARTIFACT_FILE = "buildArtifact.json";

public BuildArtifactAction(Run<?, ?> build, FilePath workspace) {
public BuildArtifactAction(Run<?, ?> build) {
this.build = build;
this.workspace = workspace;

// Setting the counts of task when Action is created.
try{
Expand Down Expand Up @@ -62,7 +60,7 @@ public String getUrlName() {

public List<BuildArtifactData> getBuildArtifact() throws ParseException, InterruptedException, IOException {
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
FilePath fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" + BUILD_ARTIFACT_FILE));
FilePath fl = new FilePath(new File(build.getRootDir().getAbsolutePath(), BUILD_ARTIFACT_FILE));
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
Object obj = new JSONParser().parse(reader);
JSONObject jo = (JSONObject) obj;
Expand Down Expand Up @@ -130,13 +128,10 @@ public void setOwner(Run owner) {
this.build = owner;
}

public FilePath getWorkspace() {
return this.workspace;
}

private void setCounts() throws InterruptedException, ParseException {
List<BuildArtifactData> artifactData = new ArrayList<BuildArtifactData>();
FilePath fl = new FilePath(new File(build.getRootDir().getAbsolutePath() + "/" + BUILD_ARTIFACT_FILE));
FilePath fl = new FilePath(new File(build.getRootDir(), BUILD_ARTIFACT_FILE));
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(fl.toURI())), "UTF-8")) {
Object obj = new JSONParser().parse(reader);
JSONObject jo = (JSONObject) obj;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/mathworks/ci/BuildConsoleAnnotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ private static byte[][] createBuildNotes() {
} catch (IOException e) {
throw new RuntimeException(e);
}

}

@Override
Expand Down Expand Up @@ -80,4 +79,4 @@ public OutputStream decorateLogger(Run build, OutputStream logger) throws IOExce
return new BuildConsoleAnnotator(logger, Charsets.UTF_8, buildNotes);
}
}
}
}
187 changes: 0 additions & 187 deletions src/main/java/com/mathworks/ci/MatlabBuildStepExecution.java

This file was deleted.

52 changes: 24 additions & 28 deletions src/main/java/com/mathworks/ci/MatlabBuilderConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,43 @@
*/

public class MatlabBuilderConstants {
static final double BASE_MATLAB_VERSION_RUNTESTS_SUPPORT = 8.1;
static final double BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT = 8.6;
static final double BASE_MATLAB_VERSION_BATCH_SUPPORT = 9.5;
static final double BASE_MATLAB_VERSION_COBERTURA_SUPPORT = 9.3;
static final double BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT = 9.5;
static final double BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT = 9.6;
public static final double BASE_MATLAB_VERSION_RUNTESTS_SUPPORT = 8.1;
public static final double BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT = 8.6;
public static final double BASE_MATLAB_VERSION_BATCH_SUPPORT = 9.5;
public static final double BASE_MATLAB_VERSION_COBERTURA_SUPPORT = 9.3;
public static final double BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT = 9.5;
public static final double BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT = 9.6;

static final String MATLAB_RUNNER_TARGET_FILE = "Builder.matlab.runner.target.file.name";
static final String MATLAB_TESTS_RUNNER_TARGET_FILE = "runMatlabTests.m";
static final String MATLAB_RUNNER_RESOURCE = "com/mathworks/ci/MatlabBuilder/runMatlabTests.m";
static final String AUTOMATIC_OPTION = "RunTestsAutomaticallyOption";
public static final String MATLAB_RUNNER_TARGET_FILE = "Builder.matlab.runner.target.file.name";
public static final String MATLAB_TESTS_RUNNER_TARGET_FILE = "runMatlabTests.m";
public static final String MATLAB_RUNNER_RESOURCE = "com/mathworks/ci/MatlabBuilder/runMatlabTests.m";
public static final String AUTOMATIC_OPTION = "RunTestsAutomaticallyOption";

// Input parameter names (Passed to runMatlabTests.m as name-value pair arguments)
static final String PDF_REPORT = "'PDFReport'";
static final String TAP_RESULTS = "'TAPResults'";
static final String JUNIT_RESULTS = "'JUnitResults'";
static final String STM_RESULTS = "'SimulinkTestResults'";
static final String COBERTURA_CODE_COVERAGE = "'CoberturaCodeCoverage'";
static final String COBERTURA_MODEL_COVERAGE = "'CoberturaModelCoverage'";
public static final String PDF_REPORT = "'PDFReport'";
public static final String TAP_RESULTS = "'TAPResults'";
public static final String JUNIT_RESULTS = "'JUnitResults'";
public static final String STM_RESULTS = "'SimulinkTestResults'";
public static final String COBERTURA_CODE_COVERAGE = "'CoberturaCodeCoverage'";
public static final String COBERTURA_MODEL_COVERAGE = "'CoberturaModelCoverage'";

//Matlab Script generator package
static final String MATLAB_SCRIPT_GENERATOR = "matlab-script-generator.zip";
public static final String MATLAB_SCRIPT_GENERATOR = "matlab-script-generator.zip";

//Test runner file prefix
static final String MATLAB_TEST_RUNNER_FILE_PREFIX = "runner_";
public static final String MATLAB_TEST_RUNNER_FILE_PREFIX = "runner_";

//Temporary MATLAB folder name in workspace
static final String TEMP_MATLAB_FOLDER_NAME = ".matlab";
public static final String TEMP_MATLAB_FOLDER_NAME = ".matlab";

static final String NEW_LINE = System.getProperty("line.separator");
public static final String NEW_LINE = System.getProperty("line.separator");

//MATLAB Runner Script
static final String TEST_RUNNER_SCRIPT = String.join(NEW_LINE,
"tmpDir=tempname;",
"mkdir(tmpDir);",
"addpath(tmpDir);",
"zipURL='${ZIP_FILE}';",
"unzip(zipURL,tmpDir);",
public static final String TEST_RUNNER_SCRIPT = String.join(NEW_LINE,
"addpath('${TEMP_FOLDER}');",
"testScript = genscript(${PARAMS});",
"disp('Running MATLAB script with content:');",
"disp(testScript.Contents);",
"testScript.writeToFile(fullfile(tmpDir,'runnerScript.m'));",
"fprintf('___________________________________\\n\\n');");
"fprintf('___________________________________\\n\\n');",
"run(testScript);");
}
Loading

0 comments on commit 313d60d

Please sign in to comment.