Skip to content

Commit

Permalink
Merge pull request #40 from cloudhubs/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
g-goulis authored Sep 24, 2024
2 parents 3bb079d + 33a8427 commit 3c0c561
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 190 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

javadoc:
runs-on: ubuntu-latest
needs: test
needs: test # Ensures the javadoc phase runs only after the test phase succeeds
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -38,20 +38,23 @@ jobs:
java-version: '17'

- name: Generate Javadoc
run: mvn javadoc:javadoc --no-transfer-progress
run: mvn javadoc:javadoc --no-transfer-progress -DadditionalJOption=-Xdoclint:none # Ignore warnings

- name: Verify Javadoc
run: |
if [ ! -d target/site/apidocs ]; then
echo "Javadoc failed to compile!"
if [ -d target/site/apidocs ]; then
echo "Javadoc generated successfully."
else
echo "Javadoc failed to generate!"
exit 1
fi
deploy:
update-docs:
runs-on: ubuntu-latest

needs: [test, javadoc] # This ensures that deploy phase runs only after both test and javadoc phases succeed
if: github.event.pull_request.merged == true # Ensures this runs only when the PR is merged
steps:
- name: Checkout repository
- name: Checkout code
uses: actions/checkout@v2

- name: Set up SSH for deploy key
Expand All @@ -66,14 +69,15 @@ jobs:
- name: Generate Javadoc
run: mvn javadoc:javadoc --no-transfer-progress

- name: Push Javadoc to GitHub Pages
- name: Deploy docs to GitHub Pages
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin [email protected]:${{ github.repository }}.git
rm -rf docs/apidocs
mv target/site/apidocs docs/apidocs
git add docs/apidocs
git commit -m "Update Javadoc"
git push origin main
env:
GIT_SSH_COMMAND: "ssh -i ~/.ssh/deploy_key -o IdentitiesOnly=yes"
GIT_SSH_COMMAND: "ssh -i ~/.ssh/deploy_key -o IdentitiesOnly=yes"
15 changes: 2 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.parameters>true</maven.compiler.parameters>
<compiler-plugin.version>3.8.1</compiler-plugin.version>

</properties>


Expand All @@ -36,7 +37,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -63,16 +64,6 @@
<artifactId>jgrapht-core</artifactId>
<version>1.5.2</version>
</dependency>
<!-- <dependency>
<groupId>tech.sourced</groupId>
<artifactId>enry-java</artifactId>
<version>2.1.0</version>
</dependency> -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
Expand Down Expand Up @@ -166,8 +157,6 @@
<version>3.4.1</version>
<configuration>
<show>private</show>
<reportOutputDirectory>./docs</reportOutputDirectory>
<outputDirectory>./docs</outputDirectory>
<groups>
<group>
<title>common</title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class FlowUtils {

/**
* Method for generating <strong>ALL</strong> possibilities
* Method for generating all possibilities
* of Flows
*
* @param microserviceSystem the microservice system to scan for flows
Expand Down Expand Up @@ -223,7 +223,7 @@ private static Field findServiceField(Flow flow) {
* This method finds any jClass affiliated with the serviceField of a flow.
* Due to polymorphism the type is not guaranteed to match one class so all
* possibilities will be considered.
* <br/><strong>Note: This is a source of approximation -- Runtime types</strong>
* Note: This is a source of approximation -- Runtime types
*
* @param flow the flow
* @return the jClass affiliated with the serviceField
Expand Down Expand Up @@ -278,7 +278,7 @@ private static Field findRepositoryField(Flow flow) {
* This method finds any jClass affiliated with the repositoryField of a flow.
* Due to polymorphism the type is not guaranteed to match one class so all
* possibilities will be considered.
* <br/><strong>Note: This is a source of approximation -- Runtime types</strong>
* Note: This is a source of approximation -- Runtime types
*
* @param flow the flow
* @return the jClass affiliated with the repositoryField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public NoApiGateway checkforApiGateway(MicroserviceSystem microserviceSystem) {
}

/**
* Checks if the given JsonObject contains the "cloud" -> "gateway" configuration.
* Checks if the given JsonObject contains the "cloud" or "gateway" configuration.
* @param data The JsonObject to check.
* @return true if the configuration is found, false otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ private StringParserUtils() {
/**
* Remove start/end quotations from the given string.
*
* <p>ex: "abcde" --> abcde
*
* @param s the string to remove quotations from
* @return the string with quotations removed
Expand Down
246 changes: 123 additions & 123 deletions src/test/java/integration/IRComparisonTest.java
Original file line number Diff line number Diff line change
@@ -1,128 +1,128 @@
package integration;

import edu.university.ecs.lab.common.models.ir.*;
import edu.university.ecs.lab.common.services.GitService;
import edu.university.ecs.lab.common.utils.FileUtils;
import edu.university.ecs.lab.common.utils.JsonReadWriteUtils;
import edu.university.ecs.lab.delta.services.DeltaExtractionService;
import edu.university.ecs.lab.intermediate.create.services.IRExtractionService;
import edu.university.ecs.lab.intermediate.merge.services.MergeService;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;

import static integration.Constants.*;

class IRComparisonTest {
private static IRExtractionService irExtractionService;
private static DeltaExtractionService deltaExtractionService;
private static List<RevCommit> list;
private static GitService gitService;


@BeforeAll
public static void setUp() {
FileUtils.makeDirs();
gitService = new GitService(TEST_CONFIG_PATH);

list = iterableToList(gitService.getLog());

irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.of(list.get(0).toString().split(" ")[1]));

irExtractionService.generateIR(OLD_IR_NAME);
}

@Test
void testComparison() {

// Loop through commit history and create delta, merge, etc...
for (int i = 0; i < list.size() - 1; i++) {
String commitIdOld = list.get(i).toString().split(" ")[1];
String commitIdNew = list.get(i + 1).toString().split(" ")[1];

// Extract changes from one commit to the other
deltaExtractionService = new DeltaExtractionService(TEST_CONFIG_PATH, OLD_IR_PATH, commitIdOld, commitIdNew);
deltaExtractionService.generateDelta();

// Merge Delta changes to old IR to create new IR representing new commit changes
MergeService mergeService = new MergeService(OLD_IR_PATH, DELTA_PATH, TEST_CONFIG_PATH);
mergeService.generateMergeIR(commitIdNew);

if(i < list.size() - 2) {
try {
Files.move(Paths.get(NEW_IR_PATH), Paths.get(OLD_IR_PATH), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}
}

// Create IR of last commit
irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.of(list.get(list.size() - 1).toString().split(" ")[1]));
irExtractionService.generateIR(TEST_IR_NAME);

// Compare two IR's for equivalence
MicroserviceSystem microserviceSystem1 = JsonReadWriteUtils.readFromJSON(NEW_IR_PATH, MicroserviceSystem.class);
MicroserviceSystem microserviceSystem2 = JsonReadWriteUtils.readFromJSON(TEST_IR_PATH, MicroserviceSystem.class);

microserviceSystem1.setOrphans(new HashSet<>());
microserviceSystem2.setOrphans(new HashSet<>());

Assertions.assertTrue(Objects.deepEquals(microserviceSystem1, microserviceSystem2));

}


// private static void deepCompareSystems(MicroserviceSystem microserviceSystem1, MicroserviceSystem microserviceSystem2) {
// // Ignore orphans for testing
// microserviceSystem1.setOrphans(null);
// microserviceSystem2.setOrphans(null);
// System.out.println("System equivalence is: " + Objects.deepEquals(microserviceSystem1, microserviceSystem2));
//
// for (Microservice microservice1 : microserviceSystem1.getMicroservices()) {
// outer2: {
// for (Microservice microservice2 : microserviceSystem2.getMicroservices()) {
// if (microservice1.getName().equals(microservice2.getName())) {
// System.out.println("Microservice equivalence of " + microservice1.getPath() + " is: " + Objects.deepEquals(microservice1, microservice2));
// for (ProjectFile projectFile1 : microservice1.getAllFiles()) {
// outer1: {
// for (ProjectFile projectFile2 : microservice2.getAllFiles()) {
// if (projectFile1.getPath().equals(projectFile2.getPath())) {
// System.out.println("Class equivalence of " + projectFile1.getPath() + " is: " + Objects.deepEquals(projectFile1, projectFile2));
// break outer1;
// }
// }
//
// System.out.println("No JClass match found for " + projectFile1.getPath());
// }
// }
// break outer2;
// }
// }
//package integration;
//
//import edu.university.ecs.lab.common.models.ir.*;
//import edu.university.ecs.lab.common.services.GitService;
//import edu.university.ecs.lab.common.utils.FileUtils;
//import edu.university.ecs.lab.common.utils.JsonReadWriteUtils;
//import edu.university.ecs.lab.delta.services.DeltaExtractionService;
//import edu.university.ecs.lab.intermediate.create.services.IRExtractionService;
//import edu.university.ecs.lab.intermediate.merge.services.MergeService;
//import org.eclipse.jgit.revwalk.RevCommit;
//import org.junit.jupiter.api.Assertions;
//import org.junit.jupiter.api.BeforeAll;
//import org.junit.jupiter.api.Test;
//
//import java.io.IOException;
//import java.nio.file.Files;
//import java.nio.file.Paths;
//import java.nio.file.StandardCopyOption;
//import java.util.*;
//
//import static integration.Constants.*;
//
//class IRComparisonTest {
// private static IRExtractionService irExtractionService;
// private static DeltaExtractionService deltaExtractionService;
// private static List<RevCommit> list;
// private static GitService gitService;
//
//
// @BeforeAll
// public static void setUp() {
// FileUtils.makeDirs();
// gitService = new GitService(TEST_CONFIG_PATH);
//
// list = iterableToList(gitService.getLog());
//
// irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.of(list.get(0).toString().split(" ")[1]));
//
// irExtractionService.generateIR(OLD_IR_NAME);
// }
//
// @Test
// void testComparison() {
//
// // Loop through commit history and create delta, merge, etc...
// for (int i = 0; i < list.size() - 1; i++) {
// String commitIdOld = list.get(i).toString().split(" ")[1];
// String commitIdNew = list.get(i + 1).toString().split(" ")[1];
//
// // Extract changes from one commit to the other
// deltaExtractionService = new DeltaExtractionService(TEST_CONFIG_PATH, OLD_IR_PATH, commitIdOld, commitIdNew);
// deltaExtractionService.generateDelta();
//
// System.out.println("No Microservice match found for " + microservice1.getPath());
// // Merge Delta changes to old IR to create new IR representing new commit changes
// MergeService mergeService = new MergeService(OLD_IR_PATH, DELTA_PATH, TEST_CONFIG_PATH);
// mergeService.generateMergeIR(commitIdNew);
//
// if(i < list.size() - 2) {
// try {
// Files.move(Paths.get(NEW_IR_PATH), Paths.get(OLD_IR_PATH), StandardCopyOption.REPLACE_EXISTING);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// // Create IR of last commit
// irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.of(list.get(list.size() - 1).toString().split(" ")[1]));
// irExtractionService.generateIR(TEST_IR_NAME);
//
// // Compare two IR's for equivalence
// MicroserviceSystem microserviceSystem1 = JsonReadWriteUtils.readFromJSON(NEW_IR_PATH, MicroserviceSystem.class);
// MicroserviceSystem microserviceSystem2 = JsonReadWriteUtils.readFromJSON(TEST_IR_PATH, MicroserviceSystem.class);
//
// microserviceSystem1.setOrphans(new HashSet<>());
// microserviceSystem2.setOrphans(new HashSet<>());
//
// Assertions.assertTrue(Objects.deepEquals(microserviceSystem1, microserviceSystem2));
//
// }
//
//
//// private static void deepCompareSystems(MicroserviceSystem microserviceSystem1, MicroserviceSystem microserviceSystem2) {
//// // Ignore orphans for testing
//// microserviceSystem1.setOrphans(null);
//// microserviceSystem2.setOrphans(null);
//// System.out.println("System equivalence is: " + Objects.deepEquals(microserviceSystem1, microserviceSystem2));
////
//// for (Microservice microservice1 : microserviceSystem1.getMicroservices()) {
//// outer2: {
//// for (Microservice microservice2 : microserviceSystem2.getMicroservices()) {
//// if (microservice1.getName().equals(microservice2.getName())) {
//// System.out.println("Microservice equivalence of " + microservice1.getPath() + " is: " + Objects.deepEquals(microservice1, microservice2));
//// for (ProjectFile projectFile1 : microservice1.getAllFiles()) {
//// outer1: {
//// for (ProjectFile projectFile2 : microservice2.getAllFiles()) {
//// if (projectFile1.getPath().equals(projectFile2.getPath())) {
//// System.out.println("Class equivalence of " + projectFile1.getPath() + " is: " + Objects.deepEquals(projectFile1, projectFile2));
//// break outer1;
//// }
//// }
////
//// System.out.println("No JClass match found for " + projectFile1.getPath());
//// }
//// }
//// break outer2;
//// }
//// }
////
//// System.out.println("No Microservice match found for " + microservice1.getPath());
//// }
//// }
////
//// }
//
// private static List<RevCommit> iterableToList(Iterable<RevCommit> iterable) {
// Iterator<RevCommit> iterator = iterable.iterator();
// List<RevCommit> list = new LinkedList<>();
// while (iterator.hasNext()) {
// list.add(iterator.next());
// }
// Collections.reverse(list);
//
// return list;
// }

private static List<RevCommit> iterableToList(Iterable<RevCommit> iterable) {
Iterator<RevCommit> iterator = iterable.iterator();
List<RevCommit> list = new LinkedList<>();
while (iterator.hasNext()) {
list.add(iterator.next());
}
Collections.reverse(list);

return list;
}


}
//
//
//}
Loading

0 comments on commit 3c0c561

Please sign in to comment.