Skip to content

Commit 3d8bbe4

Browse files
authored
runtime-v2: add github exclusive trigger to schema (#977)
1 parent fbaf873 commit 3d8bbe4

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

runtime/v2/model/src/main/java/com/walmartlabs/concord/runtime/v2/model/GithubTriggerExclusiveMode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.immutables.value.Value;
2929

3030
import javax.annotation.Nullable;
31+
import java.io.Serial;
3132
import java.io.Serializable;
3233

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

41+
@Serial
4042
long serialVersionUID = 1L;
4143

4244
@Nullable

runtime/v2/model/src/main/java/com/walmartlabs/concord/runtime/v2/schema/TriggerMixIn.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaInject;
2525
import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaString;
2626
import com.walmartlabs.concord.runtime.v2.model.ExclusiveMode;
27+
import com.walmartlabs.concord.runtime.v2.model.GithubTriggerExclusiveMode;
2728
import com.walmartlabs.concord.runtime.v2.model.Trigger;
2829

2930
import java.util.List;
@@ -111,7 +112,7 @@ interface GithubTriggerParams extends DefaultTriggerParams {
111112
GithubTriggerConditions conditions();
112113

113114
@JsonProperty("exclusive")
114-
ExclusiveMode exclusive();
115+
GithubTriggerExclusiveMode exclusive();
115116

116117
interface GithubTriggerConditions {
117118
@JsonProperty(value = "type", required = true)
@@ -174,6 +175,9 @@ interface GenericTriggerParams extends DefaultTriggerParams {
174175

175176
@JsonProperty("conditions")
176177
Map<String, Object> conditions();
178+
179+
@JsonProperty("exclusive")
180+
ExclusiveMode exclusive();
177181
}
178182
}
179183

@@ -187,8 +191,5 @@ interface DefaultTriggerParams {
187191

188192
@JsonProperty("arguments")
189193
Map<String, Object> arguments();
190-
191-
@JsonProperty("exclusive")
192-
ExclusiveMode exclusive();
193194
}
194195
}

runtime/v2/model/src/test/java/com/walmartlabs/concord/project/runtime/v2/parser/YamlOkParserTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,26 @@ public void test019() throws Exception {
570570
assertTrue(p1.configuration().debug());
571571
}
572572

573+
@Test // GitHub trigger exclusive grouping
574+
void test020() throws Exception {
575+
ProcessDefinition pd = load("020.yml");
576+
577+
List<Trigger> triggers = pd.triggers();
578+
assertNotNull(triggers);
579+
580+
assertEquals(2, triggers.size());
581+
582+
Trigger t = triggers.get(0);
583+
assertEquals("github", t.name());
584+
var exclusive = assertInstanceOf(GithubTriggerExclusiveMode.class, t.configuration().get("exclusive"));
585+
assertEquals("branch", exclusive.groupByProperty());
586+
587+
t = triggers.get(1);
588+
assertEquals("github", t.name());
589+
exclusive = assertInstanceOf(GithubTriggerExclusiveMode.class, t.configuration().get("exclusive"));
590+
assertEquals("event.pull_request.html_url", exclusive.groupByProperty());
591+
}
592+
573593
@Test
574594
void test021() throws Exception {
575595
ProcessDefinition pd = load("021.yml");
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
triggers:
3+
- github:
4+
version: 2
5+
useInitiator: true
6+
entryPoint: onPush
7+
conditions:
8+
type: "push"
9+
exclusive:
10+
groupBy: branch
11+
12+
- github:
13+
version: 2
14+
useInitiator: true
15+
entryPoint: onPush2
16+
conditions:
17+
type: push2
18+
exclusive:
19+
groupBy: "event.pull_request.html_url"

server/impl/src/main/java/com/walmartlabs/concord/server/process/PayloadUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public static OffsetDateTime getStartAt(Payload p) {
6565
return null;
6666
}
6767

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

0 commit comments

Comments
 (0)