Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.immutables.value.Value;

import javax.annotation.Nullable;
import java.io.Serial;
import java.io.Serializable;

@Value.Immutable
Expand All @@ -37,6 +38,7 @@
@JsonDeserialize(as = ImmutableGithubTriggerExclusiveMode.class)
public interface GithubTriggerExclusiveMode extends Serializable {

@Serial
long serialVersionUID = 1L;

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaInject;
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaString;
import com.walmartlabs.concord.runtime.v2.model.ExclusiveMode;
import com.walmartlabs.concord.runtime.v2.model.GithubTriggerExclusiveMode;
import com.walmartlabs.concord.runtime.v2.model.Trigger;

import java.util.List;
Expand Down Expand Up @@ -111,7 +112,7 @@ interface GithubTriggerParams extends DefaultTriggerParams {
GithubTriggerConditions conditions();

@JsonProperty("exclusive")
ExclusiveMode exclusive();
GithubTriggerExclusiveMode exclusive();

interface GithubTriggerConditions {
@JsonProperty(value = "type", required = true)
Expand Down Expand Up @@ -174,6 +175,9 @@ interface GenericTriggerParams extends DefaultTriggerParams {

@JsonProperty("conditions")
Map<String, Object> conditions();

@JsonProperty("exclusive")
ExclusiveMode exclusive();
}
}

Expand All @@ -187,8 +191,5 @@ interface DefaultTriggerParams {

@JsonProperty("arguments")
Map<String, Object> arguments();

@JsonProperty("exclusive")
ExclusiveMode exclusive();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,26 @@ public void test019() throws Exception {
assertTrue(p1.configuration().debug());
}

@Test // GitHub trigger exclusive grouping
void test020() throws Exception {
ProcessDefinition pd = load("020.yml");

List<Trigger> triggers = pd.triggers();
assertNotNull(triggers);

assertEquals(2, triggers.size());

Trigger t = triggers.get(0);
assertEquals("github", t.name());
var exclusive = assertInstanceOf(GithubTriggerExclusiveMode.class, t.configuration().get("exclusive"));
assertEquals("branch", exclusive.groupByProperty());

t = triggers.get(1);
assertEquals("github", t.name());
exclusive = assertInstanceOf(GithubTriggerExclusiveMode.class, t.configuration().get("exclusive"));
assertEquals("event.pull_request.html_url", exclusive.groupByProperty());
}

@Test
void test021() throws Exception {
ProcessDefinition pd = load("021.yml");
Expand Down
19 changes: 19 additions & 0 deletions runtime/v2/model/src/test/resources/020.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

triggers:
- github:
version: 2
useInitiator: true
entryPoint: onPush
conditions:
type: "push"
exclusive:
groupBy: branch

- github:
version: 2
useInitiator: true
entryPoint: onPush2
conditions:
type: push2
exclusive:
groupBy: "event.pull_request.html_url"
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public static OffsetDateTime getStartAt(Payload p) {
return null;
}

if (v instanceof String) {
if (v instanceof String iso) {
OffsetDateTime t;
try {
t = DateTimeUtils.fromIsoString((String) v);
t = DateTimeUtils.fromIsoString(iso);
} catch (DateTimeParseException e) {
throw new ProcessException(p.getProcessKey(), "Invalid '" + k + "' format, expected an ISO-8601 value, got: " + v);
}
Expand Down
Loading