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

Bring schema in house #910

Merged
merged 2 commits into from
Oct 29, 2022
Merged

Bring schema in house #910

merged 2 commits into from
Oct 29, 2022

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Oct 27, 2022

Since the Taskfile schema was added to SchemaStore/schemastore, it has slowly diverged as features have been added and documentation changed. This means that users are often left with an error message in their editor saying that a field is not supported when it is.

image

This PR brings the Taskfile schema back into the Task repo. This will allow us to ensure that it is updated whenever a new feature is added and that users will not run into errors when they shouldn't.

In order to get this to work properly, we will need to update the schema in SchemaStore/schemastore to look like this:

{
  "$ref": "https://raw.githubusercontent.com/go-task/task/master/schema/taskfile-schema.json",
  "title": "Taskfile YAML Schema"
}

A good example of another project that already does this is MarkdownLint. You can see the schema here and the reference in schemastore here.

Once this change is merged and the schemastore reference is updated, we should also update the contribution guide to ask contributors to keep the schema up-to-date when making changes.


In addition to bringing the schema in-house, I've also updated the schema descriptions and the docs so that they match (updating both where appropriate) and I've reordered all the keys in both so that they appear in the same order as the Go structs. This makes it much easier to "spot the difference", so it is less likely that keys are missed in the future.

@pd93
Copy link
Member Author

pd93 commented Oct 27, 2022

Quick note. I know that single commits are preferred, but I thought it would be slightly easier to review as separate commits since the first commit is just copying the schema as-is and the other two allow you to see the changes that I've made. I'm happy to squash these once reviewed.

@pd93 pd93 force-pushed the bring-schema-in-house branch from a160baa to 060dfc4 Compare October 28, 2022 22:50
@andreynering
Copy link
Member

andreynering commented Oct 29, 2022

Hi @pd93,

This makes sense. I didn't know it was possible to reference another file via a URL to make this possible.

Some comments:

  1. We need to make sure the schemastore project would allow us to reference our schema via a URL instead of having the definitions there. I found only a few schemas the does this there, but seems that it would be allowed indeed.
  2. I think it would be more appropriate to move the file to the docs like /docs/schema.json. This way we could reference it via the website (https://taskfile.dev/schema.json) instead of a GitHub URL. What do you think?

pd93 added 2 commits October 29, 2022 14:43
- Also reorder them both to match the struct definitions. This makes it easier to compare them
@pd93 pd93 force-pushed the bring-schema-in-house branch from 060dfc4 to 620e695 Compare October 29, 2022 14:45
@andreynering andreynering added the area: json schema Changes related to the JSON schema. label Oct 29, 2022
@pd93
Copy link
Member Author

pd93 commented Oct 29, 2022

  1. We need to make sure the schemastore project would allow us to reference our schema via a URL instead of having the definitions there. I found only a few schemas the does this there, but seems that it would be allowed indeed.

Yeah, agreed. I think the first step would be to get this merged and then I can open a PR on their side. and ask @madskristensen if this is the correct approach. If it's not, we can always revert this change. Nothing will change until a PR is merged in schemastore anyway.

  1. I think it would be more appropriate to move the file to the docs like /docs/schema.json. This way we could reference it via the website (https://taskfile.dev/schema.json) instead of a GitHub URL. What do you think?

This is a great idea, I've pushed a change.

@andreynering
Copy link
Member

Thanks @pd93!

@andreynering andreynering merged commit dba964b into master Oct 29, 2022
@pd93 pd93 deleted the bring-schema-in-house branch October 29, 2022 15:19
per1234 added a commit to per1234/.github that referenced this pull request Nov 17, 2022
The "Check Taskfiles" template workflow validates the project's taskfiles against the official JSON schema.

The contents of that schema was recently moved from the previous location in the Schema Store to the Task project
repository:

go-task/task#910

An attempt was made to mitigate the impact of that move by replacing the content in the original schema with an external
reference to the new one. However, the schema validator used by the workflow does not automatically follow external
references, which caused the workflow to fail:

schema /home/runner/work/_temp/taskfile-schema/taskfile.json is invalid
error: can't resolve reference https://taskfile.dev/schema.json from id #

Although this could be resolved by also downloading the referenced schema, since the original schema intentionally does
not contain anything of value, the better fix is to simply use the real schema directly in the workflow.
per1234 added a commit to per1234/.github that referenced this pull request Nov 17, 2022
The "Check Taskfiles" template workflow validates the project's taskfiles against the official JSON schema.

The contents of that schema was recently moved from the previous location in the Schema Store to the Task project
repository:

go-task/task#910

An attempt was made to mitigate the impact of that move by replacing the content in the original schema with an external
reference to the new one. However, the schema validator used by the workflow does not automatically follow external
references, which caused the workflow to fail:

schema /home/runner/work/_temp/taskfile-schema/taskfile.json is invalid
error: can't resolve reference https://taskfile.dev/schema.json from id #

Although this could be resolved by also downloading the referenced schema, since the original schema intentionally does
not contain anything of value, the better fix is to simply use the real schema directly in the workflow.
per1234 added a commit to arduino/libraries-repository-engine that referenced this pull request Jul 19, 2023
The "Check Taskfiles" template workflow validates the project's taskfiles against the official JSON schema.

The contents of that schema was recently moved from the previous location in the Schema Store to the Task project
repository:

go-task/task#910

An attempt was made to mitigate the impact of that move by replacing the content in the original schema with an external
reference to the new one. However, the schema validator used by the workflow does not automatically follow external
references, which caused the workflow to fail:

schema /home/runner/work/_temp/taskfile-schema/taskfile.json is invalid
error: can't resolve reference https://taskfile.dev/schema.json from id #

Although this could be resolved by also downloading the referenced schema, since the original schema intentionally does
not contain anything of value, the better fix is to simply use the real schema directly in the workflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: json schema Changes related to the JSON schema.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants