Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Gitlab manual status #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Actually only used by the html endpoint.
## prometheus
Endpoint: `/api/adapter/prometheus`

Can be used as exporter from a prometheus scraper. Return values are: success=0, skipped=1, canceled=2, failed=10.
Can be used as exporter from a prometheus scraper. Return values are: success=0, skipped=1, canceled=2, manual=3, failed=10.

Examples:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum Status {

// sleeping
success,
manual,
failed,
canceled,
skipped;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public String shell(@RequestParam(defaultValue = "true") Boolean dots,
String stringFailures = list(pipelines, Status.failed, delimiterProjects, refs, filterStatusList);
String stringSkipped = list(pipelines, Status.skipped, delimiterProjects, refs, filterStatusList);
String stringSuccess = list(pipelines, Status.success, delimiterProjects, refs, filterStatusList);
builder.append(Joiner.on(delimiterLists).skipNulls().join(stringFailures, stringSkipped, stringSuccess));
String stringManual = list(pipelines, Status.manual, delimiterProjects, refs, filterStatusList);
builder.append(Joiner.on(delimiterLists).skipNulls().join(stringFailures, stringSkipped, stringSuccess, stringManual));
}
return builder.toString();

Expand Down Expand Up @@ -100,6 +101,9 @@ private Color getLastBuildStatus(PipelinePair pair) {
if (pair.getCurrent().getStatus() == Status.skipped) {
return Color.WHITE;
}
if (pair.getCurrent().getStatus() == Status.manual) {
return Color.CYAN;
}
return Color.MAGENTA;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ private String getLastBuildStatus(PipelinePair pair) {
if (pair.getCurrent().getStatus() == Status.failed) {
return "Failure";
}
// ccmenu does not reflect skipped, show as success since it is at least not failed
// ccmenu does not reflect skipped or manual, show as success since it is at least not failed
if (pair.getCurrent().getStatus() == Status.skipped) {
return "Success";
}
if (pair.getCurrent().getStatus() == Status.manual) {
return "Success";
}
return "Unknown";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ protected String stateToValue(PipelinePair pair) {
return "1";
case canceled:
return "2";
case manual:
return "3";
case failed:
return "10";
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package de.joblift.service.gitlabpanorama.core.aggregator;

import static de.galan.commons.time.Instants.*;
import static org.assertj.core.api.Assertions.*;

import java.time.Instant;

import org.junit.jupiter.api.Test;

import de.joblift.service.gitlabpanorama.core.models.Pipeline;
import de.joblift.service.gitlabpanorama.core.models.Project;
import de.joblift.service.gitlabpanorama.core.models.Status;
import org.junit.jupiter.api.Test;

import java.time.Instant;

import static de.galan.commons.time.Instants.instantUtc;
import static org.assertj.core.api.Assertions.assertThat;


/**
Expand Down Expand Up @@ -49,6 +48,14 @@ public void singleActiveAndCurrent() {
assertThat(pp.getCurrent()).isEqualTo(pc);
}

@Test
public void singleManual() {
Pipeline p = p(1L, Status.manual);
PipelinePair pp = new PipelinePair(p);
assertThat(pp.getActive()).isNull();
assertThat(pp.getCurrent()).isEqualTo(p);
}


@Test
public void currentFailedSucceeded() {
Expand Down Expand Up @@ -104,6 +111,15 @@ public void currentSuccessFromRetry() {
assertThat(pp.getCurrent()).isEqualTo(pc2);
}

@Test
public void currentActiveFromManual() {
Pipeline pc = p(1L, Status.manual, T1);
Pipeline pa = p(1L, Status.running, T2);
PipelinePair pp = new PipelinePair(pa, pc);
assertThat(pp.getActive()).isEqualTo(pa);
assertThat(pp.getCurrent()).isEqualTo(pc);
}


@Test
public void retrySuccess() {
Expand Down