diff --git a/src/main/kotlin/com/dsoftware/ghmanager/psi/Tools.kt b/src/main/kotlin/com/dsoftware/ghmanager/psi/Tools.kt index 47bbd54..adaebaa 100644 --- a/src/main/kotlin/com/dsoftware/ghmanager/psi/Tools.kt +++ b/src/main/kotlin/com/dsoftware/ghmanager/psi/Tools.kt @@ -9,7 +9,7 @@ import java.util.Collections object Tools { fun isActionFile(virtualFile: VirtualFile): Boolean { return (virtualFile.name == "action.yml" || virtualFile.name == "action.yaml") - && virtualFile.parent.path.endsWith(".github/actions") + && virtualFile.parent.parent.path.endsWith(".github/actions") } fun isWorkflowFile(virtualFile: VirtualFile): Boolean { diff --git a/src/test/kotlin/com/dsoftware/ghmanager/psi/ProjectStartupTest.kt b/src/test/kotlin/com/dsoftware/ghmanager/psi/ProjectStartupTest.kt index e850b67..4ca8af3 100644 --- a/src/test/kotlin/com/dsoftware/ghmanager/psi/ProjectStartupTest.kt +++ b/src/test/kotlin/com/dsoftware/ghmanager/psi/ProjectStartupTest.kt @@ -2,11 +2,10 @@ package com.dsoftware.ghmanager.psi import com.intellij.codeInsight.navigation.openFileWithPsiElement import com.intellij.openapi.components.service -import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.psi.PsiManager import com.intellij.testFramework.common.initTestApplication import com.intellij.testFramework.junit5.RunInEdt -import com.intellij.testFramework.rules.ClassLevelProjectModelExtension +import com.intellij.testFramework.rules.ProjectModelExtension import com.intellij.testFramework.useProject import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @@ -15,20 +14,16 @@ import org.junit.jupiter.api.extension.RegisterExtension @RunInEdt(writeIntent = true) class ProjectStartupTest { - - - companion object { - init { - initTestApplication() - } - - @JvmField - @RegisterExtension - protected val projectRule: ClassLevelProjectModelExtension = ClassLevelProjectModelExtension() + init { + initTestApplication() } + @JvmField + @RegisterExtension + protected val projectRule: ProjectModelExtension = ProjectModelExtension() + @Test - fun testScanWorkflowFile() { + fun `testScanWorkflowFile workflow-file is scanned`() { val content = """ jobs: build: @@ -49,9 +44,27 @@ class ProjectStartupTest { val gitHubActionDataService = project.service() Assertions.assertEquals(1, gitHubActionDataService.actionsToResolve.size) } + } + @Test + fun `testScanWorkflowFile action-file is scanned`() { + val content = """ + runs: + using: "composite" + steps: + - uses: mshick/add-pr-comment@v2 + message-id: coverage + """.trimIndent() + val workflowFile = projectRule.baseProjectDir + .newVirtualFile(".github/actions/test-coverage/action.yaml", content.toByteArray()) -// projectResource.after() + val project = projectRule.project + project.useProject { + val psiFile = PsiManager.getInstance(project).findFile(workflowFile) + openFileWithPsiElement(psiFile!!, true, true) + val gitHubActionDataService = project.service() + Assertions.assertEquals(1, gitHubActionDataService.actionsToResolve.size) + } }