Skip to content

Commit

Permalink
fix: Use yaml as manifest extension
Browse files Browse the repository at this point in the history
- Instead of yml use yaml as the officially supported manifest extension
  • Loading branch information
kostas-petrakis committed Nov 4, 2024
1 parent 59ffd77 commit ad64249
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/net/leanix/githubagent/shared/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package net.leanix.githubagent.shared
const val TOPIC_PREFIX = "/app/ghe/"
const val APP_NAME_TOPIC = "appName"
const val LOGS_TOPIC = "logs"
const val MANIFEST_FILE_NAME = "leanix.yml"
const val MANIFEST_FILE_NAME = "leanix.yaml"

val SUPPORTED_EVENT_TYPES = listOf(
"REPOSITORY",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles

const val UNSUPPORTED_MANIFEST_EXTENSION = "leanix.yml"

@SpringBootTest
@ActiveProfiles("test")
class WebhookEventServiceTest {
Expand Down Expand Up @@ -150,6 +152,34 @@ class WebhookEventServiceTest {
verify { webSocketService.sendMessage(any(), any<ManifestFileUpdateDto>()) }
}

@Test
fun `should not send updates for unsupported yml manifest file`() {
val payload = """
{
"ref": "refs/heads/main",
"repository": {
"name": "repo",
"full_name": "org/repo",
"default_branch": "main",
"owner": {
"name": "org"
}
},
"head_commit": {
"added": ["$UNSUPPORTED_MANIFEST_EXTENSION"],
"modified": [],
"removed": []
},
"installation": {
"id": 1
}
}
"""
webhookEventService.consumeWebhookEvent("PUSH", payload)

verify (exactly = 0) { webSocketService.sendMessage(any(), any<ManifestFileUpdateDto>()) }
}

@Test
fun `should handle manifest file in subdirectory`() {
val payload = """{
Expand Down Expand Up @@ -233,4 +263,37 @@ class WebhookEventServiceTest {
)
}
}

@Test
fun `should handle push event with supported YAML extension`() {
val payload = """{
"repository": {
"name": "repo",
"full_name": "owner/repo",
"owner": {"name": "owner"},
"default_branch": "main"
},
"head_commit": {
"added": ["custom/path/added1/leanix.yml", "custom/path/added2/$MANIFEST_FILE_NAME"],
"modified": [],
"removed": []
},
"installation": {"id": 1},
"ref": "refs/heads/main"
}"""

webhookEventService.consumeWebhookEvent("PUSH", payload)

verify(exactly = 1) {
webSocketService.sendMessage(
"/events/manifestFile",
ManifestFileUpdateDto(
"owner/repo",
ManifestFileAction.ADDED,
"content",
"custom/path/added2/$MANIFEST_FILE_NAME"
)
)
}
}
}

0 comments on commit ad64249

Please sign in to comment.