Skip to content

Commit

Permalink
More work
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Nov 14, 2023
1 parent 132a1d1 commit dd33960
Show file tree
Hide file tree
Showing 33 changed files with 525 additions and 42 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
91b7797090e2ac1f51e2fb268458442f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d596fd8a5faffa8540c08d083f6d41afe42fcece
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.stuartwdouglas.hacbs-test.simple</groupId>
<artifactId>simple-jdk17</artifactId>
<version>0.1.2</version>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>
<build />
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08ec474b353ff180282668bf5e81cd76
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7a10727c99f5257a25fd6590a9dce5847c7b82bc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>io.github.stuartwdouglas.hacbs-test.simple</groupId>
<artifactId>simple-jdk17</artifactId>
<versioning>
<release>0.1.2</release>
<versions>
<version>0.1.2</version>
</versions>
<lastUpdated>20230807050400</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
85d3068fd5a413da484a2789a7e9bd87
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ef470d8d906a7d371f9876b2311b100caf7688f8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.microprofile.openapi.annotations.media.Schema;

public record ArtifactSummaryDTO(@Schema(required = true) long built, @Schema(required = true) long missing, @Schema(required = true) long failed, @Schema(required = true) long total) {

public record ArtifactSummaryDTO(@Schema(required = true) long built, @Schema(required = true) long missing,
@Schema(required = true) long failed, @Schema(required = true) long total) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.redhat.hacbs.management.dto;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

import com.redhat.hacbs.management.model.BuildAttempt;

public record BuildAttemptDTO(
@Schema(required = true) long id,
String jdk,
String mavenVersion,
String gradleVersion,
String sbtVersion,
String antVersion,
String tool,
String builderImage,

String preBuildImage,
String hermeticBuilderImage,
String outputImage,
String outputImageDigest,
String commandLine,
String preBuildScript,
String postBuildScript,
String enforceVersion,
boolean disableSubModules,
int additionalMemory,
String repositories,
String allowedDifferences,

String buildLogsUrl,
String buildPipelineUrl,

//List<AdditionalDownload> additionalDownloads,

boolean successful,
boolean passedVerification,

//StoredDependencyBuild dependencyBuild,

//List<BuildFile> storedBuildResults,
String upstreamDifferences) {

public static BuildAttemptDTO of(BuildAttempt i) {
return new BuildAttemptDTO(
i.id,
i.jdk,
i.mavenVersion,
i.gradleVersion,
i.sbtVersion,
i.antVersion,
i.tool,
i.builderImage,
i.preBuildImage,
i.hermeticBuilderImage,
i.outputImage,
i.outputImageDigest,
i.commandLine,
i.preBuildScript,
i.postBuildScript,
i.enforceVersion,
i.disableSubModules,
i.additionalMemory,
i.repositories,
i.allowedDifferences,
i.buildLogsUrl,
i.buildPipelineUrl,
i.successful,
i.passedVerification,
i.upstreamDifferences);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.redhat.hacbs.management.dto;

import java.util.List;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

import com.redhat.hacbs.management.model.MavenArtifact;
import com.redhat.hacbs.management.model.StoredDependencyBuild;

public record BuildDTO(
@Schema(required = true) long id,
@Schema(required = true) String name,
String scmRepo,
String tag,
String commit,
String contextPath,
boolean succeeded,
boolean contaminated,
List<String> artifacts,
BuildAttemptDTO successfulBuild,
List<BuildAttemptDTO> buildAttempts) {
public static BuildDTO of(StoredDependencyBuild build) {
BuildAttemptDTO success = build.buildAttempts.stream().filter(s -> s.successful).findFirst().map(BuildAttemptDTO::of)
.orElse(null);
List<BuildAttemptDTO> others = build.buildAttempts.stream().filter(s -> success == null || s.id != success.id())
.map(BuildAttemptDTO::of).toList();
return new BuildDTO(
build.id,
build.buildIdentifier.dependencyBuildName,
build.buildIdentifier.repository.url,
build.buildIdentifier.tag,
build.buildIdentifier.hash,
build.buildIdentifier.contextPath,
build.succeeded,
build.contaminated,
build.producedArtifacts.stream().map(MavenArtifact::gav).toList(),
success,
others);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import org.eclipse.microprofile.openapi.annotations.media.Schema;

public record BuildListDTO(@Schema(required = true) String name, String scmRepo, String tag, boolean succeeded,
boolean contaminated, String artifacts, boolean inQueue) {
public record BuildListDTO(
@Schema(required = true) long id,
@Schema(required = true) String name,
String scmRepo, String tag,
boolean succeeded,
boolean contaminated,
String artifacts,
boolean inQueue) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.eclipse.microprofile.openapi.annotations.media.Schema;

public record BuildStatusDTO(@Schema(required = true) long totalBuilds, @Schema(required = true) long successfulBuilds,
public record BuildSummaryDTO(@Schema(required = true) long totalBuilds, @Schema(required = true) long successfulBuilds,
@Schema(required = true) long contaminatedBuilds, @Schema(required = true) long runningBuilds,
@Schema(required = true) long failingBuilds) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.redhat.hacbs.management.resources;

import com.redhat.hacbs.management.dto.ArtifactSummaryDTO;
import com.redhat.hacbs.management.model.StoredArtifactBuild;
import com.redhat.hacbs.resources.model.v1alpha1.ModelConstants;
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

import com.redhat.hacbs.management.dto.ArtifactSummaryDTO;
import com.redhat.hacbs.management.model.StoredArtifactBuild;
import com.redhat.hacbs.resources.model.v1alpha1.ModelConstants;

@Path("/artifact/summary")
public class ArtifactSummaryResource {

Expand All @@ -18,7 +19,8 @@ public class ArtifactSummaryResource {
public ArtifactSummaryDTO summary() {
long missing = StoredArtifactBuild.count("status", ModelConstants.ARTIFACT_BUILD_MISSING);
long failed = StoredArtifactBuild.count("status", ModelConstants.ARTIFACT_BUILD_FAILED);
long build = (long) entityManager.createQuery("select count(*) from StoredDependencyBuild s inner join s.producedArtifacts").getSingleResult();
long build = (long) entityManager
.createQuery("select count(*) from StoredDependencyBuild s inner join s.producedArtifacts").getSingleResult();
return new ArtifactSummaryDTO(build, missing, failed, build + missing + failed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;

import org.eclipse.microprofile.openapi.annotations.Operation;

import com.redhat.hacbs.management.dto.BuildDTO;
import com.redhat.hacbs.management.dto.BuildListDTO;
import com.redhat.hacbs.management.dto.PageParameters;
import com.redhat.hacbs.management.model.StoredArtifactBuild;
Expand All @@ -18,8 +23,8 @@
import io.quarkus.panache.common.Page;
import io.quarkus.panache.common.Sort;

@Path("/builds")
public class DependencyBuildsResource {
@Path("/builds/history")
public class BuildHistoryResource {

@Inject
EntityManager entityManager;
Expand All @@ -43,11 +48,22 @@ public PageParameters<BuildListDTO> all(@QueryParam("page") int page, @QueryPara
}
String artifactList = StoredArtifactBuild.<StoredArtifactBuild> find("buildIdentifier", build.buildIdentifier)
.page(0, 5).stream().map(s -> s.mavenArtifact.gav()).collect(Collectors.joining(","));
ret.add(new BuildListDTO(build.buildIdentifier.dependencyBuildName, build.buildIdentifier.repository.url,
ret.add(new BuildListDTO(build.id, build.buildIdentifier.dependencyBuildName, build.buildIdentifier.repository.url,
build.buildIdentifier.tag, build.succeeded, build.contaminated, artifactList, inQueue));
}

return new PageParameters<>(ret, StoredDependencyBuild.count(), page, perPage);
}

@GET
@Path("{id}")
@Operation(operationId = "get-build")
public BuildDTO get(@PathParam("id") long id) {
StoredDependencyBuild build = StoredDependencyBuild.findById(id);
if (build == null) {
throw new NotFoundException();
}
return BuildDTO.of(build);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;

import com.redhat.hacbs.management.dto.BuildStatusDTO;
import com.redhat.hacbs.management.dto.BuildSummaryDTO;
import com.redhat.hacbs.management.model.StoredDependencyBuild;
import com.redhat.hacbs.management.watcher.BuildOrchestrator;

@Path("/builds/status")
public class BuildStatusResource {
public class BuildSummaryResource {

@Inject
BuildOrchestrator orchestrator;

@GET
public BuildStatusDTO all(@QueryParam("page") int page, @QueryParam("perPage") int perPage) {
public BuildSummaryDTO all(@QueryParam("page") int page, @QueryParam("perPage") int perPage) {
long all = StoredDependencyBuild.count();
long successful = StoredDependencyBuild.count("succeeded", true);
long contaminated = StoredDependencyBuild.count("contaminated", true);
long failing = all - successful - contaminated;
int running = orchestrator.getRunningBuilds();
return new BuildStatusDTO(all + running, successful, contaminated, running, failing);
return new BuildSummaryDTO(all + running, successful, contaminated, running, failing);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import {
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
import { Label } from '@patternfly/react-core';
import {DependencyBuildsResourceService, BuildListDTO, BuildQueueResourceService} from "../../services/openapi";
import {BuildHistoryResourceService, BuildListDTO, BuildQueueResourceService} from "../../services/openapi";
import {Dispatch, ReactEventHandler, SetStateAction, SyntheticEvent, useEffect, useState} from "react";
import {CheckCircleIcon, EllipsisVIcon, ErrorCircleOIcon, IceCreamIcon} from "@patternfly/react-icons";
import {Link} from "react-router-dom";


const columnNames = {
Expand All @@ -38,7 +39,7 @@ const BuildList: React.FunctionComponent = () => {

useEffect(() => {
setState('loading');
DependencyBuildsResourceService.getApiBuilds(page, perPage).then()
BuildHistoryResourceService.getApiBuildsHistory(page, perPage).then()
.then((res) => {
console.log(res);
setState('success');
Expand Down Expand Up @@ -201,7 +202,7 @@ const BuildRow: React.FunctionComponent<BuildActionsType> = (initialBuild):JSX.E
{icon(build)}
</Td>
<Td dataLabel={columnNames.name} modifier="truncate">
{build.name}
<Link to={`/builds/build/${build.id}`}>{build.name}</Link>
</Td>
<Td dataLabel={columnNames.repo} modifier="truncate">
{build.scmRepo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
import { Label } from '@patternfly/react-core';
import {DependencyBuildsResourceService, BuildQueueListDTO, BuildQueueResourceService} from "../../services/openapi";
import {BuildQueueListDTO, BuildQueueResourceService} from "../../services/openapi";
import {useEffect, useState} from "react";
import {CheckCircleIcon, ErrorCircleOIcon, ExclamationIcon} from "@patternfly/react-icons";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as React from 'react';
import {useEffect, useState} from 'react';
import {BuildStatusDTO, BuildStatusResourceService} from "../../services/openapi";
import {BuildSummaryDTO, BuildSummaryResourceService} from "../../services/openapi";
import {ChartDonut} from '@patternfly/react-charts';

const BuildStatusPieChart: React.FunctionComponent = () => {
const initial: BuildStatusDTO = {contaminatedBuilds: 0, totalBuilds: 0, runningBuilds: 0, failingBuilds: 0, successfulBuilds: 0}
const initial: BuildSummaryDTO = {contaminatedBuilds: 0, totalBuilds: 0, runningBuilds: 0, failingBuilds: 0, successfulBuilds: 0}
const [status, setStatus] = useState(initial);
const [error, setError] = useState(false);
const [state, setState] = useState('');

useEffect(() => {
setState('loading');
BuildStatusResourceService.getApiBuildsStatus().then()
BuildSummaryResourceService.getApiBuildsStatus().then()
.then((res) => {
setState('success');
setStatus(res);
Expand Down
Loading

0 comments on commit dd33960

Please sign in to comment.