Skip to content

There is no formatter for 'github-actions-workflow' #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
asilverman opened this issue May 16, 2023 · 15 comments
Open

There is no formatter for 'github-actions-workflow' #195

asilverman opened this issue May 16, 2023 · 15 comments

Comments

@asilverman
Copy link

Describe the bug
A clear and concise description of what the bug is.
image

Expected behavior
I would expect formatting to 'just work' and also to have documentation about how to configure it

Extension Version
v0.25.7

Additional context
Add any other context about the problem here.

@felipesu19
Copy link
Contributor

I think a formatter would be great. I also think its a pretty big reach from where we are now. I think for there to be any chance of this card getting worked on, we need a much clearer idea of the scope of work. I'm going to leave it open for now while we mull it over, but its more likely to get traction if we had a better idea of what it would imply

@sparr
Copy link

sparr commented May 26, 2023

Can we just call an installed YAML formatter until there's a specific formatter for actions workflows?

@asilverman
Copy link
Author

asilverman commented May 28, 2023

@sparr that is a great idea and it's is how I am working around it, by switching betweeen the file type recognition in vscode. I would love to be able to configure the file association of a GitHub action file with a yaml formatter, that should be a heavy lift.

@felipesu19 what are your thought?

@scott-doyland-burrows
Copy link

scott-doyland-burrows commented May 31, 2023

I installed the redhat yaml extension and this uses various schemas from here:
https://github.com/SchemaStore/schemastore

This gives formatting for GHA yaml files - I see this in the GHAs files (including for action.yaml files - see the second image).

image

image

This is using the following schemas:

https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-action.json

I do not use the "official" GitHub Actions extension anymore as it is quite buggy (ie, red underlined text showing issues when there are none) and has no formatter. And it does not work on action.yaml files.

However, I keep an eye on it to see if it has improved, as I do like the way it colours the text and the things that do work are great.

If the GitHub Actions extension could make use of https://github.com/SchemaStore/schemastore then it'd be much more useful.

BTW - I also have this set in my vscode settings:

"yaml.schemas": {
    
        "https://json.schemastore.org/github-workflow.json": [
            "*.github/workflows/*.yaml",
            "*.github/workflows/*.yml",
        ],
        "https://json.schemastore.org/github-action.json": [
            "action.yaml",
            "action.yml",
        ]
    }

I did try just setting that without installing the redhat yaml extension, but it didn't work from what I remember. I had to have the redhat yaml extension installed as well. The settings config is not strictly necessary, but I did find a few files were not picked up as GHA workflow files, but this settings config seems to make them all get picked up.

@na-jakobs
Copy link

Can we just call an installed YAML formatter until there's a specific formatter for actions workflows?

This. Is it not possible to call Prettier or the configured YAML formatter?

@felipesu19
Copy link
Contributor

felipesu19 commented Jul 26, 2023

This. Is it not possible to call Prettier or the configured YAML formatter?

We'd need to expose a configuration that allowed the user to point at a YAML formatter. Not impossible but does require some UI work and may run into issues depending on what formatter people want to use.

@felipesu19 felipesu19 added enhancement New feature or request and removed bug Something isn't working enhancement New feature or request labels Jul 26, 2023
@starball5
Copy link

Related on Stack Overflow: There is no formatter for 'github-actions-workflow' files installed.

@felipesu19, why doesn't is work to just honour something like this?:

"[github-actions-workflow]": {
    "editor.defaultFormatter": "redhat.vscode-yaml"
},

@sparr
Copy link

sparr commented Aug 4, 2023

@felipesu19 Would you support a vscode feature request such that you could just name one or more fallback languages, so you only need to say "treat this file like yaml for features we don't provide"?

@jsolly
Copy link

jsolly commented Mar 8, 2024

My current workflow involves moving the workflow .yml files out of the workflows directory, formatting them, and returning them. This process is very painful.

@sykhro
Copy link

sykhro commented Mar 25, 2024

My current workflow involves moving the workflow .yml files out of the workflows directory, formatting them, and returning them. This process is very painful.

image

you can click on "GitHub Actions Workflow" in the bottom right to switch the language mode to yml, format, switch back

@jsolly
Copy link

jsolly commented Mar 27, 2024

My current workflow involves moving the workflow .yml files out of the workflows directory, formatting them, and returning them. This process is very painful.

image you can click on "GitHub Actions Workflow" in the bottom right to switch the language mode to yml, format, switch back

Great workaround! Thanks

@albertocavalcante
Copy link

Any intention in officially support this feature and not require workarounds by the end user? Thanks

@albertocavalcante
Copy link

By the way, it has been raised a feature request to the RedHat YAML Extension to allow association with the 'github-actions-workflow' type: redhat-developer/vscode-yaml#1086

@ecastilla95
Copy link

Still a need for this

@AnrDaemon
Copy link

Good that the issue is not a decade old. Surprised it exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog 🗒
Development

No branches or pull requests