mpalmer / action-validator

Tool to validate GitHub Action and Workflow YAML files
GNU General Public License v3.0
271 stars 25 forks source link

Support self-hosted runners (custom `runs-on` values) #59

Closed MPV closed 7 months ago

MPV commented 9 months ago

There's plenty of warnings received when using a self-hosted runner in workflows, since it doesn't match the enum's in this schema: https://github.com/SchemaStore/schemastore/blob/14a055e90e675a7b1ae41fee3bcebcf8790f59de/src/schemas/json/github-workflow.json#L558-L587

For example using any of these approaches:

Then you'll get errors like:

[...]
        OneOf {
            code: "one_of",
            detail: None,
            path: "/jobs/publish-test-results",
            title: "OneOf conditions are not met",
            states: [
                ValidationState {
                    action_type: None,
                    file_path: None,
                    errors: [
                        OneOf {
                            code: "one_of",
                            detail: None,
                            path: "/jobs/publish-test-results/runs-on",
                            title: "OneOf conditions are not met",
                            states: [
                                ValidationState {
                                    action_type: None,
                                    file_path: None,
                                    errors: [
                                        Enum {
                                            code: "enum",
                                            detail: None,
                                            path: "/jobs/publish-test-results/runs-on",
                                            title: "Enum conditions are not met",
                                        },
                                    ],
                                },
                                ValidationState {
                                    action_type: None,
                                    file_path: None,
                                    errors: [
                                        WrongType {
                                            code: "wrong_type",
                                            detail: Some(
                                                "The value must be array",
                                            ),
                                            path: "/jobs/publish-test-results/runs-on",
                                            title: "Type of the value is wrong",
                                        },
                                    ],
                                },
                                ValidationState {
                                    action_type: None,
                                    file_path: None,
                                    errors: [
                                        WrongType {
                                            code: "wrong_type",
                                            detail: Some(
                                                "The value must be object",
                                            ),
                                            path: "/jobs/publish-test-results/runs-on",
                                            title: "Type of the value is wrong",
                                        },
                                    ],
                                },
                                ValidationState {
                                    action_type: None,
                                    file_path: None,
                                    errors: [
                                        Pattern {
                                            code: "pattern",
                                            detail: None,
                                            path: "/jobs/publish-test-results/runs-on",
                                            title: "Pattern condition is not met",
                                        },
                                    ],
                                },
                            ],
                        },
                    ],
                },
                ValidationState {
                    action_type: None,
                    file_path: None,
                    errors: [
                        Properties {
                            code: "properties",
                            detail: Some(
                                "Additional property 'runs-on' is not allowed",
                            ),
                            path: "/jobs/publish-test-results",
                            title: "Property conditions are not met",
                        },
                        Properties {
                            code: "properties",
                            detail: Some(
                                "Additional property 'steps' is not allowed",
                            ),
                            path: "/jobs/publish-test-results",
                            title: "Property conditions are not met",
                        },
                        Required {
                            code: "required",
                            detail: None,
                            path: "/jobs/publish-test-results/uses",
                            title: "This property is required",
                        },
                    ],
                },
            ],
        },
[...]

For comparison, see how actionlint does this: https://github.com/rhysd/actionlint/blob/main/docs/config.md

mpalmer commented 9 months ago

Yeah, self-hosted runners are rather tricky to support well (cf #5, #51). Also, since I don't use them myself, it's unlikely I'll get a sufficient shipment of round tuits to do much to make it better. Does the method described in this comment (and the rest of that issue) act as a suitable workaround? If not, can you provide a minimal example that action-validator rejects?

MPV commented 9 months ago

Yeah, self-hosted runners are rather tricky to support well (cf #5, #51).

Thanks for shining the light on those, my bad on not seeing them. 🙈

Also, since I don't use them myself, it's unlikely I'll get a sufficient shipment of round tuits to do much to make it better.

Understandable.

Does the method described in this comment (and the rest of that issue) act as a suitable workaround?

It sounds to me like that comment/issue talks about/suggests one of two approaches:

  1. Using runner groups
  2. Using runner labels

However since I'm using "ARC", it doesn't allow one to use labels anymore, as per:

I may give runner groups another think/try, maybe it's reasonable either way (to control access/usage separately too).

If not, can you provide a minimal example that action-validator rejects?

I may if I find the timing. Have moved back to actionlint for the time being. It also has actions for commenting inline suggestions using "reviewdog", thus quite nice UX and easily understandable signals:

MPV commented 9 months ago

On a second look, this issue probably originates upstream, as seen in:

MPV commented 8 months ago

I say we resolve this now, as the/this upstream issue has been solved:

MPV commented 7 months ago

Reopening as we'll need to bump the referenced/checked-in/submodule schemastore to get this new fix/support.