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(json-schema-check): add new action #240

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

ambroise-arm
Copy link
Contributor

@ambroise-arm ambroise-arm commented Jun 23, 2023

Description

Create a new action, where the goal is to check the compliance of configuration files against their Schema template.

Leveraging the check-jsonschema CLI tool.

It can then be used in autoware.universe and autoware.core.

Related links

Implements #232

Tests performed

I haven't tested the deployment as a dedicated Github action in a separate repository, but I tested the specific commands in CI:

Checked that it passed on correct configuration files at https://github.com/ambroise-arm/autoware.universe/actions/runs/5354465514
Checked that it failed on wrong configuration files at https://github.com/ambroise-arm/autoware.universe/actions/runs/5322522827

Notes for reviewers

I will have a follow up PR to autoware.universe to make use of this.

Interface changes

Effects on system behavior

Pre-review checklist for the PR author

The PR author must check the checkboxes below when creating the PR.

In-review checklist for the PR reviewers

The PR reviewers must check the checkboxes below before approval.

  • The PR follows the pull request guidelines.
  • The PR has been properly tested.
  • The PR has been reviewed by the code owners.

Post-review checklist for the PR author

The PR author must check the checkboxes below before merging.

  • There are no open discussions or they are tracked via tickets.
  • The PR is ready for merge.

After all checkboxes are checked, anyone who has write access can merge the PR.

The goal is to check the compliance of configuration files against their
Schema template.

Leveraging the check-jsonschema CLI tool.

Issue-Id: SCM-6366
Signed-off-by: Ambroise Vincent <[email protected]>
Change-Id: I3ca864e58d408e85ed049266c3e703b8a19220b9
@kenji-miyake
Copy link
Contributor

@ambroise-arm Thank you for the pull request.
Could you explain the difference between the pre-commit hook you added in autowarefoundation/autoware.universe#4002? I don't understand it well.

@ambroise-arm
Copy link
Contributor Author

@kenji-miyake We want to have per package:

  • 1 schema/{pkg_name}.schema.json that acts the template for the configuration files
  • 1 (or more) config/*.param.yaml configuration that need to match the template

This patch is to allow to check that the param.yaml files match their package template.

Separately, each schema.json file refers to a meta-schema that it adheres to (https://github.com/autowarefoundation/autoware.universe/blob/e70df1239c67d8ae86a7a8bf8d6c83bc20e7ece7/perception/lidar_apollo_segmentation_tvm_nodes/schema/lidar_apollo_segmentation_tvm_nodes.schema.json#L2). That's what the pre-commit is checking.

I couldn't make the check of this patch fit within the already-existing pre-commit hook (or already-existing github actions). But the opposite is possible, we could drop the pre-commit check and have it as part of this action.


- name: Check configuration files
run: |
find -wholename '*/schema/*.schema.json' -execdir bash -c 'check-jsonschema --schemafile "$1" ../config/*.param.yaml' bash '{}' +
Copy link
Contributor

Choose a reason for hiding this comment

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

1 schema/{pkg_name}.schema.json that acts the template for the configuration files
1 (or more) config/*.param.yaml configuration that need to match the template

It seems these behaviors aren't implemented yet.
Is this pull request still under draft or do you plan to implement them in another pull request?
If it's the former, please mark this pull request as a draft.
If it's the latter, creating an issue would be good.
(Or am I misunderstanding something?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The design for the structure has been published here: https://github.com/orgs/autowarefoundation/discussions/3371
It has been implemented as an example for lidar_apollo_segmentation_tvm_nodes. A second one was added recently with autoware_auto_msgs_adapter. The rest is still to be done.
The idea is that in order for people to add those files, it is valuable to have the format checked in CI before they start to create patches. Otherwise we risk having incorrect files in the repositories and it will take time later to fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I misunderstood one thing. The correspondence between param.yaml and schema.json was checked in the command.

@ambroise-arm So do you want to merge this as it is?
I mean, it seems that this action succeeds if a package doesn't have any schema.json. Is that okay for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update the spelling with ROS 2, otherwise yes.
Should I update .github/workflows/test-composite-actions.yaml and the main README to add this? Or anything else that I missed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should I update .github/workflows/test-composite-actions.yaml

It's not mandatory, but it's preferable if you can test this action.

the main README to add this?

Ah, yes. It would be nice.

Or anything else that I missed?

No, looks good! Thank you for your work.

I'll make a new release after merging it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've fixed them, so I'll merge this.

@kenji-miyake kenji-miyake enabled auto-merge (squash) June 26, 2023 09:39
@kenji-miyake kenji-miyake merged commit 92ca968 into autowarefoundation:main Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants