Skip to content

Commit

Permalink
feat: add template execution (#423)
Browse files Browse the repository at this point in the history
* feat: add template execution html

* chore: update api version to 8.2.0

* chore: upgrade docker postgresql to version 12

* fix: make stop-X

* feat: add docker shell node for web-ui

* fix: exclude test classes from sonar analysis

* chore: upgrade candidate chart

* feat: use project code instead of project id

* fix: sonar bug

* fix: duplication

* chore: add tests on TemplateResource

* fix: sonar analysis

* chore: add unit tests

* chore: apply review
  • Loading branch information
Thomas GRUSON authored May 21, 2021
1 parent 496a8fc commit d167721
Show file tree
Hide file tree
Showing 18 changed files with 344 additions and 124 deletions.
2 changes: 1 addition & 1 deletion charts/candidate/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ara
version: 8.0.2-rc.2
version: 8.2.0-rc.1
home: https://github.com/Decathlon/ara
description: |
ARA helps you to fight against regressions by letting it preanalyze your non-regression tests runs,
Expand Down
4 changes: 2 additions & 2 deletions charts/candidate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ api:
image:
registry: docker.io
repository: decathlon/ara-api
tag: 8.0.3
tag: 8.2.0
imagePullPolicy: IfNotPresent
replicas: 1
annotations: {}
Expand Down Expand Up @@ -44,7 +44,7 @@ ui:
image:
registry: docker.io
repository: decathlon/ara-web-ui
tag: 8.0.3
tag: 8.4.0
imagePullPolicy: IfNotPresent
replicas: 1
annotations: {}
Expand Down
2 changes: 1 addition & 1 deletion code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ run-%: ## Run module

stop-%: ## Stop module
@echo '-- Stop $* --'
@docker-compose up $(OPT) ara-$*
@docker-compose stop $(OPT) ara-$*

#####################################
## BUILD APP ##
Expand Down
2 changes: 1 addition & 1 deletion code/api/database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-database</artifactId>
<version>8.1.0</version>
<version>8.2.0</version>

<name>ARA Database</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion code/api/generated-cucumber-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-generated-cucumber-report</artifactId>
<version>8.1.0</version>
<version>8.2.0</version>

<name>ARA Cucumber</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion code/api/jacoco-aggregation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>ara-parent</artifactId>
<groupId>com.decathlon.ara</groupId>
<version>8.1.0</version>
<version>8.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion code/api/lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-lib</artifactId>
<version>8.1.0</version>
<version>8.2.0</version>

<properties>
<java.version>14</java.version>
Expand Down
2 changes: 1 addition & 1 deletion code/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<groupId>com.decathlon.ara</groupId>
<artifactId>ara-parent</artifactId>
<packaging>pom</packaging>
<version>8.1.0</version>
<version>8.2.0</version>

<name>ARA API</name>
<description>
Expand Down
2 changes: 1 addition & 1 deletion code/api/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>com.decathlon.ara</groupId>
<artifactId>ara-server</artifactId>
<version>8.1.0</version>
<version>8.2.0</version>

<name>ARA Server</name>
<description>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.decathlon.ara.web.rest;

import com.decathlon.ara.Entities;
import com.decathlon.ara.service.ExecutionHistoryService;
import com.decathlon.ara.service.ProjectService;
import com.decathlon.ara.service.exception.NotFoundException;
import com.decathlon.ara.web.rest.util.RestConstants;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.transaction.Transactional;

@Controller
@RequestMapping(TemplateResource.PATH)
@RequiredArgsConstructor
@Transactional(Transactional.TxType.REQUIRED)
public class TemplateResource {
private static final String NAME = "template";
/**
* The full path to this Rest resource from the basename.
*/
static final String PATH = RestConstants.API_PATH + "/" + NAME + "s";

private final ExecutionHistoryService executionHistoryService;
private final ProjectService projectService;

@GetMapping("cycle-execution")
public String nrtCycle(@RequestParam("project") String projectCode,
@RequestParam String branch,
@RequestParam String cycle,
Model model) throws NotFoundException {
var projectId = projectService.toId(projectCode);
var latestExecutions = executionHistoryService.getLatestExecutionHistories(projectId);
var execution = latestExecutions.stream()
.filter(e -> branch.equals(e.getBranch()))
.filter(e -> cycle.equals(e.getName()))
.findFirst()
.orElseThrow(() -> new NotFoundException("The branch and cycle couple for this project does not exists: it has perhaps been removed.", Entities.CYCLE_DEFINITION));
model.addAttribute("execution", execution);
return "cycle-execution";
}

}
28 changes: 28 additions & 0 deletions code/api/server/src/main/resources/templates/cycle-execution.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright (C) 2021 by the ARA Contributors
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Cycle Execution</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<th:block th:insert="fragments/style :: style"/>
</head>
<body>
<div th:replace="mail/html/nrt-cycle.html :: nrt-cycle"></div>
</body>
</html>
136 changes: 136 additions & 0 deletions code/api/server/src/main/resources/templates/fragments/style.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright (C) 2021 by the ARA Contributors
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
<title>Style Fragment</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style th:fragment="style">
/* Normalisation */
body {
font-family: arial, sans-serif;
font-size: 14px;
}

/* VueJS emulation */
.Row {
display: flex;
margin: 0 -2px;
}
.Row:after {
clear: both;
}
.Col {
float: left;
margin: 0 2px;
/* display: inline-block; */
}
.span2 { /* (24-4)/7 = 2.857... truncated by Thymeleaf to 2 */
width: 11.904%; /* = 100*2.857/24 */
}
.span3 { /* (24-4)/6 = 3.333... truncated by Thymeleaf to 3 */
width: 13.887%; /* = 100*3.333/24 */
}
.span4 { /* (24-4)/5 */
width: 16.666%; /* = 100*4/24 */
}
.span5 { /* (24-4)/4 */
width: 20.833%; /* = 100*5/24 */
}
.span6 { /* (24-4)/3 = 6.666... truncated by Thymeleaf to 6 */
width: 27.775%; /* = 100*6.666/24 */
}
.span10 { /* (24-4)/2 */
width: 41.666%; /* = 100*10/24 */
}
.span20 { /* (24-4)/1 */
width: 83.333%; /* = 100*20/24 */
}
.Alert {
border-radius: 6px;
}
.Button {
border-radius: 3px;
border: 1px solid #DDDEE1;
background-color: #F7F7F7;
color: #495060;
padding: 2px 7px;
}
.Button:hover {
border-color: #57a3f3;
background-color: white;
color: #57a3f3;
}

/* common.js */
.discardReason {
display: inline-block;
border: 2px solid #ED3F14;
color: #ED3F14;
padding: 0 2px;
border-radius: 4px;
font-weight: bold;
}

/* nrt-severity-total.vue */
.tableStyle { border-spacing: 4px; width: 100%; }
.tdStyle { border-radius: 5px; line-height: 1em; text-align: center; vertical-align: top; padding: 8px; }
.tdStyle:hover { background-color: #ebF7ff !important; }
.severityStyle { font-weight: bold; font-size: 14px; padding-top: 0; padding-bottom: 0; }
.successStyle { background-color: #F5F7F9; color: #19be6b; }
.failedStyle { background-color: #ed3f14; color: white; }
.failedStyle:hover { background-color: #FF3100 !important; }
.globalStyle { color: black; }
.percentStyle { font-size: 22px; line-height: 22px; padding-bottom: 4px; font-weight: bold; }
.smallStyle { font-size: 10px; color: gray; }
.warningStyle { background-color: #ffcc30; padding: 2px 4px; margin: -2px 0 !important; color: black; border-radius: 4px; }
.failedSmallStyle { color: white; }
.okStyle { display: inline-block; margin: 0 2px; }
.koStyle { display: inline-block; margin: 0 2px; }
.thresholdStyle { display: inline-block; margin: 0 2px; }

/* job-status-result.vue */
/* JobStatus */
.PENDING { color: #FF9900; }
.RUNNING { color: #0082C3; }
.DONE { display: none; }
.UNAVAILABLE { color: #ED3F14; }
/* Result */
.ABORTED { color: #ED3F14; }
.FAILURE { color: #ED3F14; }
.NOT_BUILT { color: #ED3F14; }
.SUCCESS { display: none; }
.UNSTABLE { display: none; }

/* nrt-progress.vue */
.nrt-progress { display: block; }
.nrt-progress .Alert { margin-bottom: 4px; background: none; padding: 8px 16px; border: 1px solid transparent; }
.nrt-progress .Alert:hover { background-color: #ebF7ff !important; }
.textPassed { color: #19be6b/*light green*/; float: left; }
.textFailed { color: #ed3f14/*dark red*/; float: right; font-weight: bold; }
.textProblem { color: #ffcc30; font-weight: bold; }
.progressBar { clear: both; border-radius: 3px; }
.progressBar, .progressBar div { height: 5px; }
.progressBar.small, .progressBar.small div { height: 3px; }
.progressBar.failed { background-color: #ed3f14/*dark red*/; }
.progressBar div { background-color: #19be6b/*light green*/; float: left; }
.progressBar div + div { background-color: #ffcc30; }
</style>
</head>
<body/>
</html>
Loading

0 comments on commit d167721

Please sign in to comment.