Commit 6aae6762 authored by Maxime Lefrançois's avatar Maxime Lefrançois
Browse files

added link to html report

parent e66ea0a4
Loading
Loading
Loading
Loading
+34 −25
Original line number Diff line number Diff line
@@ -34,14 +34,9 @@ import java.nio.charset.StandardCharsets;
import javax.swing.SwingUtilities;

import org.apache.commons.io.IOUtils;
import org.apache.jena.query.QueryFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import fr.emse.ci.sparqlext.SPARQLExt;
import fr.emse.ci.sparqlext.engine.PlanFactory;
import fr.emse.ci.sparqlext.engine.RootPlan;
import fr.emse.ci.sparqlext.query.SPARQLExtQuery;
import fr.emse.gitlab.saref.SAREFPipeline.Mode;
import fr.emse.gitlab.saref.gui.MainFrame;
import fr.emse.gitlab.saref.managers.RepositoryManager;
@@ -55,7 +50,8 @@ import fr.emse.gitlab.saref.tests.TestSuites;
public class Main {

	private static final Logger LOG = LoggerFactory.getLogger(Main.class);
	private static final boolean CAN_BROWSE = Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
	private static final boolean CAN_BROWSE = Desktop.isDesktopSupported()
			&& Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);

	public static void main(String[] args) {
		if (args.length == 0 && !GraphicsEnvironment.isHeadless()) {
@@ -71,31 +67,44 @@ public class Main {
		TestSuites testSuites = pipeline.run();
		try {
			if (pipeline.mode != Mode.CLEAN) {
				System.out.println(String.format("\n\nThe SAREF Pipeline completed with %s errors and %s warnings\n", testSuites.getErrors(), testSuites.getFailures()));
				if(pipeline.ignoreSite) {
				System.out.println(String.format("\n\nThe SAREF Pipeline completed with %s errors and %s warnings\n",
						testSuites.getErrors(), testSuites.getFailures()));
				File report = new File(pipeline.targetDir, "report_output.xml");
				System.out.println("\n\n\nSAREF Pipeline report:\n" + report.getCanonicalPath());
				} else {

				File reportHTML = new File(pipeline.targetDir, "site/report.html");
				if (reportHTML.isFile()) {
					if (CAN_BROWSE)
						Desktop.getDesktop().browse(reportHTML.toURI());
					else {
						String CI_SERVER_HOST = System.getProperty("CI_SERVER_HOST");
						String CI_PROJECT_PATH = System.getProperty("CI_PROJECT_PATH");
						String CI_JOB_ID = System.getProperty("CI_JOB_ID");
						if (CI_SERVER_HOST == null || CI_PROJECT_PATH == null || CI_JOB_ID == null) {
							System.out.println("\n\n\nSAREF pipeline report:\n" + reportHTML.getCanonicalPath());
						}
						} else {
						File report = new File(pipeline.targetDir, "report_output.xml");
						System.out.println("\n\n\nSAREF Pipeline report:\n" + report.getCanonicalPath());
							String CI_GROUP = CI_PROJECT_PATH.substring(0, CI_PROJECT_PATH.indexOf("/"));
							String CI_PATH = CI_PROJECT_PATH.substring(CI_PROJECT_PATH.indexOf("/"),
									CI_PROJECT_PATH.length());
							String link = String.format("http://%s.%s/-%s/-/jobs/%s/artifacts/target/site/report.html",
									CI_GROUP, CI_SERVER_HOST, CI_PATH, CI_JOB_ID);
							System.out.println("\n\n\nSAREF pipeline report:\n" + link);
						}
					}
				}
				if (!pipeline.ignoreSite) {
					RepositoryManager target = pipeline.getSourcesManager().getTargetRepositoryManager();
					if (target != null) {
						File siteDir = new File(pipeline.targetDir, SAREF.NAME_SITE);
						File ontoDir = new File(siteDir, target.getCurrentVersion().getVersionPath());
						File documentationHTML = new File(ontoDir, String.format("%s.html", target.getRepository().getOntologyFileName()));
						File documentationHTML = new File(ontoDir,
								String.format("%s.html", target.getRepository().getOntologyFileName()));
						if (CAN_BROWSE) {
							Desktop.getDesktop().browse(documentationHTML.toURI());
						} else {
							System.out.println(String.format("\nDocumentation for %s %s: %s\n", target.getRepository().getProject(), target.getCurrentVersionName(), documentationHTML.getCanonicalPath()));
							System.out.println(String.format("\nDocumentation for %s %s: %s\n",
									target.getRepository().getProject(), target.getCurrentVersionName(),
									documentationHTML.getCanonicalPath()));
						}
					}
				}