Skip to content

Commit

Permalink
fix: (#380) Consume status for /{workflowId}/runs api as string inste…
Browse files Browse the repository at this point in the history
…ad of Enum

- Closes #380
  • Loading branch information
sumanmaity1234 committed Jul 12, 2023
1 parent a973ba7 commit 3bc1442
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fileignoreconfig:
- filename: backend/src/main/java/de/otto/platform/gitactionboard/adapters/service/PeriodicScanScheduler.java
checksum: 5a3e3aa35f695587a15c0528a0adc84f5d11a4bc59c2212de66ee136814535e0
- filename: backend/src/main/java/de/otto/platform/gitactionboard/adapters/service/job/GithubJobDetailsService.java
checksum: a23c83af2c089741e34638d39f2031cefcf5769aaec5b1f8f0f2ff31b6b73249
checksum: f1987ab3bd116d07c32ba0271d2f2a2104fe46184ec5c6e207a05e1c6f403342
- filename: backend/src/main/java/de/otto/platform/gitactionboard/adapters/service/notifications/TeamsNotificationMessagePayload.java
checksum: d4bafd4580b23f4a8e830c749df73f85ad5fa9952d4c8ffadd9e38cf0cda4580
- filename: backend/src/main/java/de/otto/platform/gitactionboard/adapters/service/scan/secrets/GithubSecretsScanDetailsService.java
Expand Down Expand Up @@ -56,7 +56,7 @@ fileignoreconfig:
- filename: backend/src/test/java/de/otto/platform/gitactionboard/adapters/service/PeriodicScanSchedulerTest.java
checksum: 7f39196e1a6cfd1926146f7a1712ac3b6d9adbffde1b5de93a7845c3c5c17e59
- filename: backend/src/test/java/de/otto/platform/gitactionboard/adapters/service/job/GithubJobDetailsServiceTest.java
checksum: 55b1069a7de8cc62efa94c2a74d4486abce8fa28806e6e1ae3b74c5f2e6e3de9
checksum: 7a5828f97162e20214c6251d22e1d0045be24226ec6863292fb7829ad94575e5
- filename: backend/src/test/java/de/otto/platform/gitactionboard/adapters/service/notifications/TeamsNotificationMessagePayloadTest.java
checksum: efdf67477b04bf07df791fcdad4735da5d76502c6e28a4fbf9cef5267ed75a87
- filename: backend/src/test/java/de/otto/platform/gitactionboard/adapters/service/scan/secrets/GithubSecretsScanDetailsServiceTest.java
Expand Down Expand Up @@ -108,7 +108,7 @@ fileignoreconfig:
- filename: frontend/mock-data/data.json
checksum: 4baf61952ab3261089ae57c7a91f920e4cb8c67425d99861b7cbff6a1eaec60e
- filename: frontend/package-lock.json
checksum: e71f0cc27ee372ee27ac308527b72ce61b8069056d8fa2514db88718fcc0e87b
checksum: 27875505fe73e802d71d52da0cac676e6b27d6fe537a54d80fc6ebaae87e2a0a
- filename: frontend/src/components/Dashboard.vue
checksum: 55c522358eb8c8cdd66b948f52d837d7f092c9416df3a2b01284a805c1900b0e
- filename: frontend/src/components/GridCell.vue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private List<WorkflowsJobDetails> getPreviousJobDetails(
WorkflowRunDetails previousWorkflowRun,
String accessToken) {

if (COMPLETED.equals(currentWorkflowRun.getStatus())) {
if (WorkflowRunDetails.COMPLETED.equals(currentWorkflowRun.getStatus())) {
return currentJobs;
}
return fetchPreviousJobs(workflow, currentJobs, previousWorkflowRun, accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class WorkflowsRunDetailsResponse {
@Value
@Builder(toBuilder = true)
public static class WorkflowRunDetails {
public static final String COMPLETED = "completed";

long id;

@NonNull RunStatus status;
@NonNull String status;

RunConclusion conclusion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ private static Stream<Arguments> getPermutationOfWorkflowRunStatusAndPreviousCon

return Stream.of(QUEUED, IN_PROGRESS)
.flatMap(
status -> runConclusions.stream().map(conclusion -> Arguments.of(status, conclusion)));
status ->
runConclusions.stream().map(conclusion -> Arguments.of(status.name(), conclusion)));
}

private static Stream<Arguments> getSuccessPermutationArguments() {
return Stream.of(QUEUED, IN_PROGRESS)
.flatMap(
status ->
Stream.of(SUCCESS, SKIPPED).map(conclusion -> Arguments.of(status, conclusion)));
Stream.of(SUCCESS, SKIPPED)
.map(conclusion -> Arguments.of(status.name(), conclusion)));
}

@BeforeEach
Expand Down Expand Up @@ -190,13 +192,13 @@ void shouldFetchJobDetailsForGivenWorkflowWhenLatestBuildIsSuccess() {
void shouldFetchJobDetailsForGivenWorkflowWhenLatestBuildIsSuccessAndPreviousBuildIsFailed() {
final WorkflowRunDetails latestWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(0).toBuilder()
.status(COMPLETED)
.status(WorkflowRunDetails.COMPLETED)
.conclusion(SUCCESS)
.build();

final WorkflowRunDetails previousWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(1).toBuilder()
.status(COMPLETED)
.status(WorkflowRunDetails.COMPLETED)
.conclusion(FAILURE)
.build();

Expand Down Expand Up @@ -266,7 +268,7 @@ void shouldFetchJobDetailsForGivenWorkflowWhenLatestBuildIsSuccessAndPreviousBui
@SneakyThrows
void
shouldFetchJobDetailsForGivenWorkflowWhenLatestBuildIsNotCompletedAndLastBuildStatusIsNotFailure(
RunStatus latestRunStatus, RunConclusion previousConclusion) {
String latestRunStatus, RunConclusion previousConclusion) {
final WorkflowRunDetails latestWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(0).toBuilder()
.status(latestRunStatus)
Expand Down Expand Up @@ -343,7 +345,7 @@ void shouldFetchJobDetailsForGivenWorkflowWhenLatestBuildIsSuccessAndPreviousBui
@MethodSource(value = "getPermutationOfWorkflowRunStatusAndPreviousConclusion")
@SneakyThrows
void shouldFetchJobDetailsForGivenWorkflowWhenLatestAndPreviousBothBuildsAreNotSuccessOrSkipped(
RunStatus latestRunStatus, RunConclusion previousConclusion) {
String latestRunStatus, RunConclusion previousConclusion) {
final WorkflowRunDetails latestWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(0).toBuilder()
.status(latestRunStatus)
Expand All @@ -352,7 +354,7 @@ void shouldFetchJobDetailsForGivenWorkflowWhenLatestAndPreviousBothBuildsAreNotS

final WorkflowRunDetails previousWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(1).toBuilder()
.status(COMPLETED)
.status(WorkflowRunDetails.COMPLETED)
.conclusion(previousConclusion)
.build();

Expand Down Expand Up @@ -456,7 +458,7 @@ void shouldFetchJobDetailsForGivenWorkflowWhenLatestAndPreviousBothBuildsAreNotS
void shouldFetchJobDetailsWhenLatestBuildIsRunningAndItHasANewJobAddedAndLastJobIsSuccess() {
final WorkflowRunDetails latestWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(0).toBuilder()
.status(IN_PROGRESS)
.status("in_progress")
.conclusion(null)
.build();

Expand Down Expand Up @@ -530,7 +532,7 @@ void shouldFetchJobDetailsWhenLatestBuildIsRunningAndItHasANewJobAddedAndLastJob
@SneakyThrows
void
shouldFetchJobDetailsWhenLatestBuildIsRunningAndItHasANewJobAddedAndLastJobIsFailureConclusion(
RunStatus latestRunStatus, RunConclusion previousConclusion) {
String latestRunStatus, RunConclusion previousConclusion) {
final WorkflowRunDetails latestWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(0).toBuilder()
.status(latestRunStatus)
Expand All @@ -539,7 +541,7 @@ void shouldFetchJobDetailsWhenLatestBuildIsRunningAndItHasANewJobAddedAndLastJob

final WorkflowRunDetails previousWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(1).toBuilder()
.status(COMPLETED)
.status(WorkflowRunDetails.COMPLETED)
.conclusion(previousConclusion)
.build();

Expand Down Expand Up @@ -675,13 +677,13 @@ void shouldNotThrowErrorIfTheFetchJobDetailsRunsCallFails() {
void shouldNotFetchJobDetailsForGivenWorkflowWhenTheDetailsIsPresentInCacheWithCompletedStatus() {
final WorkflowRunDetails latestWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(0).toBuilder()
.status(COMPLETED)
.status(WorkflowRunDetails.COMPLETED)
.conclusion(SUCCESS)
.build();

final WorkflowRunDetails previousWorkflowRunDetails =
BASE_WORKFLOWS_RUN_DETAILS_RESPONSE.getWorkflowRuns().get(1).toBuilder()
.status(COMPLETED)
.status(WorkflowRunDetails.COMPLETED)
.conclusion(FAILURE)
.build();

Expand Down

0 comments on commit 3bc1442

Please sign in to comment.