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

Add JSON schema for shard.yml #623

Merged

Conversation

nobodywasishere
Copy link
Contributor

@nobodywasishere nobodywasishere commented Mar 7, 2024

Implements #622. I can add automated tests if desired. After this, I can add it to JSON Schema Store.

I wasn't sure if we should restrict additional properties in the file, as there may be other tools that add stuff to the shard.yml. Off the top of my head, I can't remember any though, and they should probably move those kinds of things to their own config file.

Also if you're using VSCode, you can add this to the .vscode/settings.json and it will use the schema to vaidate the shard.yml that shards uses. I used this for testing.

// .vscode/settings.json
{
  "yaml.schemas": {
    "docs/shard.yml.schema.json": "shard.yml"
  }
}

docs/shard.yml.schema.json Outdated Show resolved Hide resolved
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
docs/shard.yml.schema.json Outdated Show resolved Hide resolved
docs/shard.yml.schema.json Show resolved Hide resolved
Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

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

Nice work.

It would be nice to see how it behaves with existing shard.yml files, for large public projects (e.g. lucky), and if it catches some errors.

docs/shard.yml.schema.json Show resolved Hide resolved
@nobodywasishere
Copy link
Contributor Author

Here are some examples of it with existing shard.ymls

Lucky:
Amber:
Mint:
Blurhash.cr:

@nobodywasishere
Copy link
Contributor Author

Here are some of the errors it catches, alongside general format/form errors:
image
image
image

It currently doesn't verify dependency version: tags, the crystal: version tag, or the github/gitlab/bitbucket user/repo format

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@nobodywasishere
Copy link
Contributor Author

Is there anything else that needs to be done for this?

"dependencies": {
"type": "object",
"title": "dependencies",
"description": "A list of required dependencies\nhttps://github.com/crystal-lang/shards/blob/master/docs/shard.yml.adoc#dependency-attributes",
Copy link
Contributor

Choose a reason for hiding this comment

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

thought (non blocking): I'm wondering if we could host a HTML rendering of the shard.yml spec at a stable place under https://crystal-lang.org and link to that page instead of a github file that may be moved 🤔

poke @straight-shoota

Copy link
Member

Choose a reason for hiding this comment

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

Good point, we should certainly do that. Would fit right next to https://crystal-lang.org/reference/1.11/man/shards
Not sure why we're missing it there 🤔
Anyway, we can merge this as is and update the URL later.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, seems like I had this idea a long time ago already: crystal-lang/crystal-book#476
But we haven't managed to make the format compatible with HTML rendering: #488

@straight-shoota straight-shoota changed the title Add JSON schema for shard.yml Add JSON schema for shard.yml Mar 25, 2024
@straight-shoota straight-shoota merged commit cefdba7 into crystal-lang:master Mar 25, 2024
8 checks passed
@nobodywasishere nobodywasishere deleted the nobody/json-schema branch March 25, 2024 22:18
@nobodywasishere
Copy link
Contributor Author

@straight-shoota straight-shoota added this to the 0.18.0 milestone Mar 27, 2024
@straight-shoota straight-shoota linked an issue Apr 2, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create shard.yml.schema
4 participants