YunaBraska / github-workflow-plugin

Your Ultimate Wingman for GitHub Workflows and Actions! 🚀
https://github.com/YunaBraska/github-workflow-plugin
Apache License 2.0
42 stars 9 forks source link

Assertion failed: Network must not be accessed in EDT or inside read action #6

Closed YannCebron closed 11 months ago

YannCebron commented 11 months ago

How can we reproduce the issue? Open GH workflow.yml file

Relevant log output

java.lang.Throwable: Assertion failed: Network must not be accessed in EDT or inside read action, because this may take considerable amount of time, and write actions will be blocked during that time so user won't be able to perform tasks in the IDE
    at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:258)
    at com.intellij.util.io.HttpRequests.process(HttpRequests.java:497)
    at com.intellij.util.io.HttpRequests$RequestBuilderImpl.connect(HttpRequests.java:335)
    at org.jetbrains.plugins.github.api.GithubApiRequestExecutor$Base.execute(GithubApiRequestExecutor.kt:92)
    at org.jetbrains.plugins.github.api.GithubApiRequestExecutor$WithTokenAuth.execute(GithubApiRequestExecutor.kt:65)
    at org.jetbrains.plugins.github.api.GithubApiRequestExecutor.execute(GithubApiRequestExecutor.kt:46)
    at com.github.yunabraska.githubworkflow.completion.GitHubWorkflowUtils.downloadFromGitHub(GitHubWorkflowUtils.java:229)
    at com.github.yunabraska.githubworkflow.completion.GitHubWorkflowUtils.lambda$downloadFileFromGitHub$9(GitHubWorkflowUtils.java:219)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.Collections$2.tryAdvance(Collections.java:4853)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
    at com.github.yunabraska.githubworkflow.completion.GitHubWorkflowUtils.downloadFileFromGitHub(GitHubWorkflowUtils.java:223)
    at com.github.yunabraska.githubworkflow.completion.GitHubWorkflowUtils.lambda$downloadContent$11(GitHubWorkflowUtils.java:259)
    at java.base/java.util.Optional.map(Optional.java:260)
    at com.github.yunabraska.githubworkflow.completion.GitHubWorkflowUtils.downloadContent(GitHubWorkflowUtils.java:259)
    at com.github.yunabraska.githubworkflow.completion.GitHubWorkflowUtils.downloadAction(GitHubWorkflowUtils.java:206)
    at com.github.yunabraska.githubworkflow.model.GitHubAction.setActionParameters(GitHubAction.java:142)
    at com.github.yunabraska.githubworkflow.model.GitHubAction.<init>(GitHubAction.java:134)
    at com.github.yunabraska.githubworkflow.model.GitHubAction.getGitHubAction(GitHubAction.java:48)
    at com.github.yunabraska.githubworkflow.model.WorkflowContext.lambda$init$23(WorkflowContext.java:179)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:411)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
    at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:276)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310)
    at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
    at com.github.yunabraska.githubworkflow.model.WorkflowContext.lambda$init$24(WorkflowContext.java:151)
    at java.base/java.util.Optional.ifPresent(Optional.java:178)
    at com.github.yunabraska.githubworkflow.model.WorkflowContext.init(WorkflowContext.java:151)
    at java.base/java.util.Optional.ifPresent(Optional.java:178)
    at com.github.yunabraska.githubworkflow.listeners.ApplicationListeners.lambda$asyncInitWorkflowFile$2(ApplicationListeners.java:58)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
    at com.github.yunabraska.githubworkflow.listeners.ApplicationListeners.asyncInitWorkflowFile(ApplicationListeners.java:52)
    at com.github.yunabraska.githubworkflow.listeners.FileFocusListener.selectionChanged(FileFocusListener.java:20)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:680)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:640)
    at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:415)
    at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:384)
    at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:448)
    at jdk.proxy7/jdk.proxy7.$Proxy198.needRefresh(Unknown Source)
    at stardust.project.HelpSolution$1.selectionChanged(HelpSolution.java:195)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:680)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:640)
    at com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:415)
    at com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:394)
    at com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:454)
    at jdk.proxy2/jdk.proxy2.$Proxy72.selectionChanged(Unknown Source)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.fireSelectionChanged(FileEditorManagerImpl.kt:1637)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.access$fireSelectionChanged(FileEditorManagerImpl.kt:119)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$1$1.invokeSuspend(FileEditorManagerImpl.kt:223)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at com.intellij.openapi.application.impl.DispatchedRunnable.run(DispatchedRunnable.kt:35)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:829)
    at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:454)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:122)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:788)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:731)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:758)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:667)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$7(IdeEventQueue.kt:571)
    at com.intellij.openapi.application.impl.ApplicationImpl.withoutImplicitRead(ApplicationImpl.java:1444)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:571)
    at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:68)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:349)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:348)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:348)
    at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:343)
    at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:995)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:995)
    at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$4(IdeEventQueue.kt:343)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:829)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:385)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Environment com.github.yunabraska.githubworkflowplugin (2.0.2)

IntelliJ IDEA 2023.1.5 (Community Edition) Build #IC-231.9392.1, built on July 25, 2023 Runtime version: 17.0.7+10-b829.16 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 13.5 GC: G1 Young Generation, G1 Old Generation Memory: 4000M Cores: 20 Metal Rendering is ON Registry: debugger.new.tool.window.layout=true ide.experimental.ui=true writerside.preview.rebuild.delay=1000

Non-Bundled Plugins: com.intellij.grazie.pro (0.3.241) com.github.yunabraska.githubworkflowplugin (2.0.2) org.jetbrains.idea.grammar (2022.3.2) org.jetbrains.kotlin (231-1.9.0-release-358-IJ8770.65) com.jetbrains.sdk.tool (0.59-dev) com.jetbrains.writerside (2023.06.3869) com.intellij.mermaid (0.0.13-231)

Kotlin: 231-1.9.0-release-358-IJ8770.65

YunaBraska commented 11 months ago

Thx for the feedback, I will fix it asap.

YunaBraska commented 11 months ago

Should be fixed now with version 2.0.4

SimonSchwendele commented 11 months ago

Is that surely resolved ? image

And do composite actions work at all ? image

I even added the github account to rider.

YunaBraska commented 11 months ago

The first example one should work. Unfortunately, JetBrains doesn't make it easy to refresh :( Its areal nightmare... I did some changes, but it's not reviewed yet, so fingers crossed, that this will fix it. As a manual workaround, you could try to add a space, save the file and remove a space at the end of the line.

*The second example** That's a new learning for me. Thx for pointing it out! I will have a look into this.

Sorry for so many bugs in the new release. Really embarrassing.

SimonSchwendele commented 11 months ago

Sorry for so many bugs in the new release. Really embarrassing.

Nah youre doing a great job here :). I guess you're testing all by yourself so of course some weird corner cases like "composite-actions" aren't covered.

The spacing workaround sadly does not work.

Actually no intellisense is functioning at all. image

I dont see any logs in the notification window. Where can I find them ? Maybe it's windows... again

YunaBraska commented 11 months ago

Logs

There are no logs if nothing was detected.

There are several things you can do:

1) Wait for Version 2.2.x (currently in review) 2) restart the whole IDE 3) Clear Cache - you will get the option at alt + return (Context Action) when the item was detected 4) Clear Cache manually - you can delete the folder ide_github_workflow_plugin in your temp folder and restart your IDE, this cleans the whole cache.

Background Story:

I wanted to do a lot of things like Syntax Highlighting, but for that I needed to exchange my yaml parsing from easy SnakeYaml to super hard PsiElements from JetBrains. Not the hell started. These elements are making it really hard to find the whole context as I receive the events line and element wise. The Code Completion should work, but the syntax highlighting could take a while until it gets stable

SimonSchwendele commented 11 months ago

I tried steps 2-4 still missing the intellisense. I couldn't care less about the correct highlighting ( my IDE is mostly red during work ) but I really rely on the intellisense.

I'm building your main right now. Maybe that one works

YunaBraska commented 11 months ago

You could also switch back to version 1 until I find the issue

SimonSchwendele commented 11 months ago

You could also switch back to version 1 until I find the issue

I guess I'll do that for now. 2.2.1 doesnt work as well in my case.

I really hope you can do it because we write a lot custom actions and having intellisense there as well would be amazing 😄 .

Maybe it's just a rider thing. Some regular stuff appears to be broken as well. image

Update: Oh great that already works on 1.0.1. Should've added the github account sooner 😆

YunaBraska commented 11 months ago

Missing intellisense I finally could reproduce it in Rider and Intellij. It seems a small issue detecting the cursor offset when there is no text in with: For me, it works again as soon as there is at least one character.

Some regular stuff appears to be broken as well I don't understand, as there is no IS_DRAFT in env: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables therefore is highlighted. The right way would be github.event.pull_request.draft from here: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context Do I miss something?

BTW: Thx for taking your time to report and try things out.

SimonSchwendele commented 11 months ago

The right way would be github.event.pull_request.draft from here: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

Sorry the draft variable does not check whether the PR is a draft but if the release should be a draft. If you have a look at the env: section above we define the environment variable there.

It could've be wrrite like this as well: gh release create *** --draft="${{ startsWith(github.ref_name, 'v.') == false && github.ref_name != 'master }}".

The screenshot I posted earlier contains another usage of upload-artifact where the with already contains some inputs. Despite that the input retention-days is not recognized but the action.yml exposes it

YunaBraska commented 11 months ago

Small Update Version 2.2.3 i still on review, we have to wait for it. When it's published, you will receive the following changes

YunaBraska commented 11 months ago

Version 2.2.3 is now available.

SimonSchwendele commented 11 months ago

Version 2.2.3 is now available.

Already testing it :)

Composite actions

In case the action resides in a remote repo the intellisense and stuff works. Thanks a lot for implementing this feature :) image

It's bad style so it doesnt matter that much to me personally, but when the composite file is a relative path within the repository the intellisense doesnt work again. I guess thats due to it waiting for an action rather than a file image

Editing a composite action

While I'm editing a composite action I don't get the intellisense as well. image

Missing inputs

However it appears some inputs are not recognized. image -> action.yml image -> action.yml

I need to write a lot of composite actions this Sprint. I really appreciate your implementation of this, thanks a lot for being so fast ❤️

YunaBraska commented 11 months ago

First the good things: Version 2.2.4 is now more responsive and refreshes the syntax highlighting faster. No more "Save File" to see changes.

Composite actions relative path

I would like to fix this, but I have not much of an idea on composite actions. It would be helpful if you could send me a link to a repo or tell me more about the project path structure.

Editing a composite action

Same here, I probably need an example with composite action to understand.

Missing inputs

Finally, I could reproduce the behaviour, after setting up a Windows machine. It looks like the JetBrains YAML Parser behaves differently - this bug is now my priority, but it could take a while...

SimonSchwendele commented 11 months ago

Thanks for keeping me up to date.

Finally, I could reproduce the behaviour, after setting up a Windows machine.

You're right about that. image

Well I'll guess I'll do them on my private laptop and let Linux do its magic :laughing:

And guess what.... image

I'm deeply sorry my company forces me to use that uselesss OS -.-

YunaBraska commented 11 months ago

Happy Weekend @SimonSchwendele I could fix the missing inputs faster than estimated. This also relates to Syntax Highlighting. The Version 2.2.5 will fix probably all windows problems.

Please open a new issue for other problems or feature request, since the thread is pretty long here and was starting at a different error.