-
Notifications
You must be signed in to change notification settings - Fork 10
[WIP] Fix schema #359
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
[WIP] Fix schema #359
Changes from all commits
02d3404
7cf0405
5a2b019
c0f3886
8d28830
d1c727d
89d455f
050bb96
0980d08
bf1ddad
dfefc15
0c66f0a
16a8b58
f67bb23
8d1c78e
ff8ced9
673d8c5
e55f482
7971f5f
d5dddb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| language: python | ||
| python: ["2.7"] | ||
| python: | ||
| - "2.7" | ||
| - "3.6" | ||
| cache: pip | ||
| install: pip install yamllint | ||
| script: "find . -type f -name *.bug | xargs yamllint -f parsable -c .yamllint.yml" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ requests>=2.19.1 | |
| docker>=3.5.0 | ||
| packaging~=19.0 | ||
| bugzoo>=2.1.27 | ||
| yamale==3.0.4 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| id: str(min=7, max=7) | ||
| title: str(min=1, max=160) | ||
| description: str(min=1) | ||
| classification: str(min=1) | ||
| keywords: list(str(min=1, max=80)) | ||
| system: str(min=1, max=40) | ||
| severity: enum("error", "warning", "convention-violation", "bad-smell", | ||
| "minor-issue", "not-a-bug") | ||
| links: list(regex("^(http)s?://([A-Z0-9])?")) | ||
| failure-codes: list(enum("BAD-SMELL", "ROS-SPECIFIC", "NAMING-TYPOS", "COPYPASTA", "DEFAULTS", | ||
| "CONFIG:PARAM", "CONFIG:REMAPPING", "CONFIG:ARGS", "CONFIG:CONSTANTS", "CONFIG:ENCODING", "CONFIG:NAMESPACE", "CONFIG:TOPIC", | ||
| "BDO:BUILD", "BDO:DEPENDENCY", "BDO:ORCHESTRATION", | ||
| "CONCURRENCY:NO-SYNC", "CONCURRENCY:BAD-SYNC", "CONCURRENCY:TIMING", "CONCURRENCY:SIGNALS", | ||
| "EVOLUTION:LANGUAGE", "EVOLUTION:LIBRARY", "EVOLUTION:PACKAGE", "EVOLUTION:DEPRECATION", "EVOLUTION:ROBOT", "EVOLUTION:FIRMWARE", "EVOLUTION:DOCS", "EVOLUTION:PATHS", | ||
| "PROGRAMMING:LOGIC", "PROGRAMMING:CALCULATIONS", "PROGRAMMING:CONTROL-FLOW", "PROGRAMMING:MISSING-FEATURE", "PROGRAMMING:VALIDATION", "PROGRAMMING:UNINITIALISED", "PROGRAMMING:BROKEN-CONTRACT", "PROGRAMMING:RESOURCES", "PROGRAMMING:DATATYPE", "PROGRAMMING:UNUSED", "PROGRAMMING:PATH", "PROGRAMMING:STRING-FORMATTING", "PROGRAMMING:COMPILER-ERROR", | ||
| "MODELS:ROBOT", "MODELS:WORLD", "MODELS:TRANSFORMATIONS", | ||
| "SYSTEMS:OS", "SYSTEMS:HARDWARE", "SYSTEM:FIRMWARE", "SYSTEMS:CONFIG")) | ||
| fault-codes: list(enum("WARNING", "UNKNOWN", "HARMLESS", "MISLEADING", "NONE", | ||
| "SYSTEM:LIVENESS", "SYSTEM:UNINTENDED-BEHAVIOUR", "SYSTEM:PERFORMANCE", "SYSTEM:NONE", "SYSTEM:PHYSICAL", "SYSTEM:MOTION", "SYSTEM:SIMULATION", | ||
| "SOFTWARE:BUILD", "SOFTWARE:RUNTIME", "SOFTWARE:NETWORK", "SOFTWARE:UX", "SOFTWARE:CONCURRENCY", "SOFTWARE:PERFORMANCE")) | ||
| bug: include('_bug') | ||
| fix: include('_fix') | ||
| time-machine: include('_time-machine') | ||
| bugzoo: include('_bugzoo') | ||
|
|
||
| --- | ||
|
|
||
| _bug: | ||
| phase: enum("build", "deployment", "runtime", "does not apply", "unknown") | ||
| specificity: enum("general issue", "robotics-specific", "ROS-specific", | ||
| "application-specific") | ||
| architectural-location: enum("application-specific code", "platform code", "N/A") | ||
| application: any(str(min=1), null()) | ||
| task: enum("perception", "localization", "planning", "manipulation", "locomotion", | ||
| "human-robot interaction", "simulation", "diagnostics", "SLAM", | ||
| "N/A") | ||
| subsystem: str(min=1) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be an enum?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean the subsystem. I think we should definitely make sure that consistent names and spelling is used, otherwise, I think it is of secondary importance, whether it is an enum or not. If you make it enum it is easier for you to detect divergences. The cost is that the scheme has to be changed whenever a new value pops up. I think this is a price that is entirely acceptable. So if you prefer to let yamale control it, just go ahead. |
||
| package: list(regex("^([a-z0-9A-Z-]+)(/[a-z0-9A-Z_]+){2}$")) | ||
| languages: list(enum("python", "cmake", "C++", "package.xml", | ||
| "launch.xml", "msg", "srv", "xacro", "urdf", "robot specific")) | ||
| detected-by: enum("build system", "compiler", "code scanning tool", | ||
| "assertions", "runtime detection", "runtime crash", | ||
| "testing violation", "developer", "user") | ||
| reported-by: enum("guest user", "contributor", "member developer", | ||
| "automatic", "unreported") | ||
| issue: any(regex("^((https://github\\.com/[a-zA-Z0-9_]+/[a-zA-Z0-9_]+/issues/[0-9]+)?)$"), str("N/A")) | ||
| time-reported: any(date(), null()) | ||
| reproducibility: str() | ||
| trace: str(min=1) | ||
| reproduction: any(str(min=1), null(), required=False) | ||
|
|
||
| _fix: | ||
| repo: regex("^(https://github\\.com/[a-zA-Z0-9-]+/[a-zA-Z0-9_]+)$") | ||
| hash: include('_hash') | ||
| pull-request: regex("(^(https://github\\.com/[a-zA-Z0-9-]+/[a-zA-Z0-9_]+/pull/[0-9]+)?$)|(^N/A$)") | ||
| license: list(enum("BSD", "GPLv3", "LGPLv3")) | ||
| fix-in: list(str(min=1)) | ||
| languages: list(enum("python", "cmake", "C++", "package.xml", "launch.xml", | ||
| "msg", "srv", "xacro", "urdf", "robot specific")) | ||
| time: any(date(), null()) | ||
|
|
||
| _time-machine: | ||
| ros_distro: enum("noetic", "melodic", "lunar", "kinetic", "jade", "indigo", | ||
| "hydro", "groovy", "fuerte", "electric", "diamondback") | ||
| ros_pkgs: list(str(min=1)) | ||
| datetime: date() | ||
gavanderhoorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| _bugzoo: | ||
| is-build-failure: any('true', 'false') | ||
| bug-commit: include('_hash') | ||
| fix-commit: include('_hash') | ||
| fork-urls: list(regex("^(https://github\\.com/[a-zA-Z0-9-]+/[a-zA-Z0-9_]+)$")) | ||
hsd-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| _hash: regex("^[0-9a-f]{40}$") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| #!/bin/bash | ||
|
|
||
| # usage: ./validate.sh bugid.bug | ||
| # | ||
| # install: https://github.com/any-json/any-json | ||
| # install: https://github.com/jessedc/ajv-cli | ||
|
|
||
| DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| SCHEMA="${DIR}/robust.json" | ||
| VALIDATOR="${DIR}/yamale_validator.py" | ||
| echo Checking schema compliance for $1 | ||
| any-json --input-format=yaml $1 | ajv --verbose --errors=text -s ${SCHEMA} -d /dev/stdin 2>&1 >/dev/null | sed "s/\/dev\/stdin/File $1/" | ||
| python3 ${VALIDATOR} $1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does our CI setup guarantee Python 3 is installed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest to add that, just so we keep things working/consistent. Just checked and the current |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Import Yamale and make a schema object: | ||
gavanderhoorn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import sys | ||
| import os | ||
| import yamale | ||
| import datetime | ||
| from yamale.validators import DefaultValidators, Validator | ||
|
|
||
| class Date(Validator): | ||
| """ Custom Date validator """ | ||
| tag = 'date' | ||
|
|
||
| def _is_valid(self, value): | ||
| return isinstance(value, datetime.date) | ||
|
|
||
| validators = DefaultValidators.copy() # This is a dictionary | ||
| validators[Date.tag] = Date | ||
|
|
||
| dir_here = os.path.dirname(__file__) | ||
| schema_path = os.path.join(dir_here, 'robust.yaml') | ||
| data_path = os.path.join(dir_here, 'yamale.bug') | ||
|
|
||
| schema = yamale.make_schema(schema_path, validators=validators) | ||
|
|
||
| # Create a Data object | ||
| data = yamale.make_data(sys.argv[1]) | ||
|
|
||
| # Validate data against the schema. Throws a ValueError if data is invalid. | ||
| try: | ||
| yamale.validate(schema, data) | ||
| print('Validation success! 👍') | ||
| except yamale.YamaleError as e: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle errors in each field |
||
| print('Validation failed!\n') | ||
| for result in e.results: | ||
| print("Error validating data '%s' with '%s'\n\t" % (result.data, result.schema)) | ||
| for error in result.errors: | ||
| print('\t%s' % error) | ||
| sys.exit(1) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question: we don't use
nullany more for this then? Or was that too ambiguous (as in: could also mean we just haven't bothered to look for one)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure in general, but for this specific case, the commit was not part of any PR. So
N/Amight be more suitable here.