Skip to content

Commit

Permalink
Get the Action UI working
Browse files Browse the repository at this point in the history
  • Loading branch information
dbutenhof committed Mar 20, 2024
1 parent 339f208 commit e83d514
Show file tree
Hide file tree
Showing 16 changed files with 365 additions and 77 deletions.
80 changes: 74 additions & 6 deletions docs/site/content/en/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2330,9 +2330,18 @@ components:
config:
type: object
oneOf:
- $ref: '#/components/schemas/HttpAction'
- $ref: '#/components/schemas/GithubIssueCommentAction'
- $ref: '#/components/schemas/GithubIssueCreateAction'
- $ref: '#/components/schemas/GithubIssueCommentActionConfig'
- $ref: '#/components/schemas/GithubIssueCommentActionConfig'
- $ref: '#/components/schemas/GithubIssueCreateActionConfig'
- $ref: '#/components/schemas/HttpActionConfig'
- $ref: '#/components/schemas/SlackChannelMessageActionConfig'
discriminator:
propertyName: type
mapping:
github-issue-comment: '#/components/schemas/GithubIssueCommentActionConfig'
github-issue-create: '#/components/schemas/GithubIssueCreateActionConfig'
http: '#/components/schemas/HttpActionConfig'
slack-channel-message: '#/components/schemas/SlackChannelMessageActionConfig'
secrets:
type: object
allOf:
Expand Down Expand Up @@ -2360,6 +2369,14 @@ components:
type: string
type:
type: string
ActionType:
description: Type of Action
enum:
- HTTP
- GITHUB_ISSUE_COMMENT
- GITHUB_ISSUE_CREATE
- SLACK_MESSAGE
type: string
BetterOrWorse:
description: Result of running an Experiment
enum:
Expand Down Expand Up @@ -3021,34 +3038,69 @@ components:
type: object
allOf:
- $ref: '#/components/schemas/FixThresholdConfig'
GithubIssueCommentAction:
GithubIssueCommentActionConfig:
required:
- type
- issueUrl
- owner
- repo
- issue
- formatter
type: object
properties:
type:
description: Action type
type: string
issueUrl:
description: GitHub issue URL
type: string
owner:
description: GitHub repo owner
type: string
repo:
description: GitHub repo name
type: string
issue:
description: GitHub issue number
type: string
formatter:
description: Object markdown formatter
type: string
GithubIssueCreateAction:
GithubIssueCreateActionConfig:
required:
- type
- owner
- repo
- title
- formatter
type: object
properties:
type:
description: Action type
type: string
owner:
description: GitHub repo owner
type: string
repo:
description: GitHub repo name
type: string
title:
description: GitHub issue title
type: string
formatter:
description: Object markdown formatter
type: string
HttpAction:
HttpActionConfig:
required:
- type
- url
type: object
properties:
type:
description: Action type
type: string
url:
description: HTTP address
type: string
IndexedLabelValueMap:
type: object
Expand Down Expand Up @@ -3876,6 +3928,22 @@ components:
type: string
modified:
type: boolean
SlackChannelMessageActionConfig:
required:
- type
- channel
- formatter
type: object
properties:
type:
description: Action type
type: string
channel:
description: Slack channel
type: string
formatter:
description: Object markdown formatter
type: string
SortDirection:
enum:
- Ascending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.hyperfoil.tools.horreum.api.data.ActionConfig.GithubIssueCommentActionConfig;
import io.hyperfoil.tools.horreum.api.data.ActionConfig.GithubIssueCreateActionConfig;
import io.hyperfoil.tools.horreum.api.data.ActionConfig.HttpActionConfig;
import io.hyperfoil.tools.horreum.api.data.ActionConfig.SlackChannelMessageActionConfig;
import io.hyperfoil.tools.horreum.api.data.ActionConfig.ActionType;
import jakarta.validation.constraints.NotNull;

import org.eclipse.microprofile.openapi.annotations.media.DiscriminatorMapping;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;


public class Action {

public static class HttpAction {
public String url;
}
public static class GithubIssueCommentAction {
public String issueUrl;
public String owner;
public String repo;
public String issue;
public String formatter;
}
public static class GithubIssueCreateAction {
public String owner;
public String repo;
public String title;
public String formatter;
}
public static class Secret {
public String token;
public boolean modified;
Expand All @@ -43,14 +34,19 @@ public static class Secret {
public String type;

@NotNull
@JsonProperty( required = true )
@Schema(type = SchemaType.OBJECT,
oneOf = {
Action.HttpAction.class,
Action.GithubIssueCommentAction.class,
Action.GithubIssueCreateAction.class
}
)
@JsonProperty(required = true)
@Schema(type = SchemaType.OBJECT, discriminatorProperty = "type", discriminatorMapping = {
@DiscriminatorMapping(schema = GithubIssueCommentActionConfig.class, value = "github-issue-comment"),
@DiscriminatorMapping(schema = GithubIssueCreateActionConfig.class, value = "github-issue-create"),
@DiscriminatorMapping(schema = HttpActionConfig.class, value = "http"),
@DiscriminatorMapping(schema = SlackChannelMessageActionConfig.class, value = "slack-channel-message"),
}, oneOf = {
GithubIssueCommentActionConfig.class,
GithubIssueCommentActionConfig.class,
GithubIssueCreateActionConfig.class,
HttpActionConfig.class,
SlackChannelMessageActionConfig.class,
})
public ObjectNode config;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.hyperfoil.tools.horreum.api.data.ActionConfig;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.core.type.TypeReference;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.Arrays;

@Schema(type = SchemaType.STRING, required = true, description = "Type of Action")
public enum ActionType {
HTTP("http", new TypeReference<HttpActionConfig>() {
}),
GITHUB_ISSUE_COMMENT("github-issue-comment", new TypeReference<GithubIssueCommentActionConfig>() {
}),
GITHUB_ISSUE_CREATE("github-issue-create", new TypeReference<GithubIssueCreateActionConfig>() {
}),
SLACK_MESSAGE("slack-channel-message", new TypeReference<SlackChannelMessageActionConfig>() {
});

private static final ActionType[] VALUES = values();

private final String name;
private final TypeReference<? extends BaseActionConfig> typeReference;

private <T extends BaseActionConfig> ActionType(String name, TypeReference<T> typeReference) {
this.typeReference = typeReference;
this.name = name;
}

public <T extends BaseActionConfig> TypeReference<T> getTypeReference() {
return (TypeReference<T>) typeReference;
}

@JsonCreator
public static ActionType fromString(String str) {
return Arrays.stream(VALUES).filter(v -> v.name.equals(str)).findAny()
.orElseThrow(() -> new IllegalArgumentException("Unknown action: " + str));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.hyperfoil.tools.horreum.api.data.ActionConfig;

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

public abstract class BaseActionConfig {

@Schema(type = SchemaType.STRING, required = true, description = "Action type")
public String type;

public BaseActionConfig() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.hyperfoil.tools.horreum.api.data.ActionConfig;

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

public class GithubIssueCommentActionConfig extends BaseActionConfig {

@Schema(type = SchemaType.STRING, required = true, description = "GitHub issue URL")
public String issueUrl;

@Schema(type = SchemaType.STRING, required = true, description = "GitHub repo owner")
public String owner;

@Schema(type = SchemaType.STRING, required = true, description = "GitHub repo name")
public String repo;

@Schema(type = SchemaType.STRING, required = true, description = "GitHub issue number")
public String issue;

@Schema(type = SchemaType.STRING, required = true, description = "Object markdown formatter")
public String formatter;

public GithubIssueCommentActionConfig() {
this.type = ActionType.GITHUB_ISSUE_COMMENT.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.hyperfoil.tools.horreum.api.data.ActionConfig;

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

public class GithubIssueCreateActionConfig extends BaseActionConfig {

@Schema(type = SchemaType.STRING, required = true, description = "GitHub repo owner")
public String owner;

@Schema(type = SchemaType.STRING, required = true, description = "GitHub repo name")
public String repo;

@Schema(type = SchemaType.STRING, required = true, description = "GitHub issue title")
public String title;

@Schema(type = SchemaType.STRING, required = true, description = "Object markdown formatter")
public String formatter;

public GithubIssueCreateActionConfig() {
this.type = ActionType.GITHUB_ISSUE_CREATE.toString();
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.hyperfoil.tools.horreum.api.data.ActionConfig;

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

public class HttpActionConfig extends BaseActionConfig {
@Schema(type = SchemaType.STRING, required = true, description = "HTTP address")
public String url;

public HttpActionConfig() {
this.type = ActionType.HTTP.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.hyperfoil.tools.horreum.api.data.ActionConfig;

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

public class SlackChannelMessageActionConfig extends BaseActionConfig {

@Schema(type = SchemaType.STRING, required = true, description = "Slack channel")
public String channel;

@Schema(type = SchemaType.STRING, required = true, description = "Object markdown formatter")
public String formatter;

public SlackChannelMessageActionConfig() {
this.type = ActionType.SLACK_MESSAGE.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.hyperfoil.tools.horreum.api.data.Test;
import io.hyperfoil.tools.horreum.entity.data.DatasetDAO;
import io.hyperfoil.tools.horreum.entity.data.TestDAO;

import org.eclipse.microprofile.config.inject.ConfigProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.persistence.*;
import jakarta.transaction.TransactionManager;
Expand All @@ -51,6 +52,8 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;


@ApplicationScoped
public class TestServiceImpl implements TestService {
private static final Logger log = Logger.getLogger(TestServiceImpl.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
quarkus.test.enable-callbacks-for-integration-tests=true
quarkus.http.test-port=8081
Loading

0 comments on commit e83d514

Please sign in to comment.