Skip to content
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

feat(examples): add linting to all examples #12595

Merged
merged 2 commits into from
Mar 14, 2024
Merged

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Mar 14, 2024

This PR adds linting and validation improved validation for examples templates and matches the requirements imposed by registry.coder.com.

The improvements caught an additional issue:

❯ make lint/examples
error: parse failed:
    main.run
        /Users/maf/Work/Code/coder/scripts/examplegen/main.go:87
  - example "templates/incus" has errors
front matter validation failed
icon does not exist: stat examples/templates/incus/icon/lxc.svg: no such file or directory
icon is not in site/static: "/icon/lxc.svg"
exit status 1

Ultimately the icon path was correct (as seen from the dashboard), but all other templates use a relative path so that we can verify the icons existence.

Here's another example after fudging up some more files:

❯ make lint/examples
error: parse failed:
    main.run
        /Users/maf/Work/Code/coder/scripts/examplegen/main.go:87
  - example "templates/gcp-devcontainer" has errors
front matter validation failed
tags isn't a slice: type bool
example "templates/gcp-linux" has errors
front matter validation failed
icon does not exist: stat site/static/icon/asdf.svg: no such file or directory
example "templates/incus" has errors
front matter validation failed
front matter does not contain "display_name"
front matter does not contain "maintainer_github"
icon does not exist: stat examples/templates/incus/icon/lxc.svg: no such file or directory
exit status 1

Fixes #12588

@mafredri mafredri force-pushed the mafredri/feat-lint-examples branch from d461d12 to b981cf2 Compare March 14, 2024 14:29
@mafredri mafredri marked this pull request as ready for review March 14, 2024 14:34
@@ -1,7 +1,7 @@
---
display_name: Incus System Container with Docker
description: Develop in an Incus System Container with Docker using incus
icon: /icon/lxc.svg
icon: ../../../site/static/icon/lxc.svg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fair, both forms work. But all our other examples/templates use this relative form, and it's handy for confirming that the exact path exists.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, +1 for enforced consistency!

@mafredri mafredri merged commit 5dd436c into main Mar 14, 2024
28 checks passed
@mafredri mafredri deleted the mafredri/feat-lint-examples branch March 14, 2024 14:49
@github-actions github-actions bot locked and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: any typo in template matadata is crashing registry.coder.com deployment
2 participants