Skip to content

Commit

Permalink
Fixes unnecessary log with no gha configurations (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecharp authored Oct 18, 2022
1 parent 08228f7 commit 003f48e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ public class ContinuousDeploymentProbe extends Probe {
protected ProbeResult doApply(Plugin plugin, ProbeContext context) {
final Path repo = context.getScmRepository();
final Path githubWorkflow = repo.resolve(".github/workflows");
if (Files.notExists(githubWorkflow)) {
return ProbeResult.failure(key(), "Plugin has no GitHub Action configured");
}
try (Stream<Path> files = Files.find(githubWorkflow, 1, (path, basicFileAttributes) -> Files.isRegularFile(path) && "cd.yml".equals(path.getFileName().toString()))) {
return files.findFirst().isPresent() ?
ProbeResult.success(key(), "JEP-229 workflow definition found") :
ProbeResult.failure(key(), "Could not find JEP-229 workflow definition");
} catch (IOException ex) {
LOGGER.warn("Could not walk {} Git clone in {}", plugin.getName(), repo, ex);
return ProbeResult.failure(key(), "Could not find GHA workflows definitions directory");
return ProbeResult.error(key(), "Could not work plugin repository");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ public void shouldBeAbleToDetectRepositoryWithNoGHA() throws Exception {
final ProbeContext ctx = mock(ProbeContext.class);
final ContinuousDeploymentProbe probe = new ContinuousDeploymentProbe();

when(plugin.getName()).thenReturn("foo");
when(ctx.getScmRepository()).thenReturn(Files.createTempDirectory("foo"));

final ProbeResult result = probe.apply(plugin, ctx);
assertThat(result.status()).isEqualTo(ResultStatus.FAILURE);
assertThat(result.message()).isEqualTo("Could not find GHA workflows definitions directory");
assertThat(result.message()).isEqualTo("Plugin has no GitHub Action configured");
}

@Test
Expand Down

0 comments on commit 003f48e

Please sign in to comment.