Merge lp:~adeuring/charm-tools/check-config-yaml into lp:~charmers/charm-tools/trunk
Status: | Rejected |
---|---|
Rejected by: | Abel Deuring |
Proposed branch: | lp:~adeuring/charm-tools/check-config-yaml |
Merge into: | lp:~charmers/charm-tools/trunk |
Diff against target: |
775 lines (+639/-0) 23 files modified
scripts/lib/proof.py (+89/-0) tests/charms/broken-categories/config.yaml (+5/-0) tests/charms/broken-config/README (+1/-0) tests/charms/broken-config/config.yaml (+5/-0) tests/charms/broken-config/copyright (+17/-0) tests/charms/broken-config/hooks/install (+5/-0) tests/charms/broken-config/hooks/relation-a-relation-joined (+5/-0) tests/charms/broken-config/hooks/start (+4/-0) tests/charms/broken-config/hooks/stop (+7/-0) tests/charms/broken-config/icon.svg (+198/-0) tests/charms/broken-config/metadata.yaml (+10/-0) tests/charms/broken-config/revision (+1/-0) tests/charms/broken-maintainer/config.yaml (+5/-0) tests/charms/broken-subordinate/config.yaml (+5/-0) tests/charms/broken-subordinate2/config.yaml (+5/-0) tests/charms/empty-requires/config.yaml (+5/-0) tests/charms/icon-template/config.yaml (+5/-0) tests/charms/missing-maintainer/config.yaml (+5/-0) tests/charms/mod-spdy/config.yaml (+5/-0) tests/charms/test/config.yaml (+5/-0) tests/charms/unknown-metadata/config.yaml (+5/-0) tests/proof/expected/broken-config (+1/-0) tests/proof/test_proof.py (+246/-0) |
To merge this branch: | bzr merge lp:~adeuring/charm-tools/check-config-yaml |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
charmers | Pending | ||
Review via email: mp+186066@code.launchpad.net |
Description of the change
This branch adds a method check_config_file() to class Linter
of the proof tool.
Working on manage.
for problems in the config.yaml files in the job that "ingests"
all charms from Launchpad.
The ingest job does not do a thorough check of the config file --
it justs tries to parse the YAML data in order to store it in the
Mongo DB. So, only parsing errors are currently recorded and presented
on the pages for charm details.
The changes in this branch are based on this specification:
http://
(I could not find any more recent documentation of config.yaml.)
The main points I took from this doc: If the content of config.yaml
is represented as a Python object,
- this object should be a dictionary with one key, 'options'.
- config['options'] should in turn also be a dictionary, with
arbitrary keys. (OK -- it might make sense to check id the
keys strings.)
- the values of the dict config['options'] shoule also be a
dictionary, with three keys: 'description', 'type', 'default'.
- 'description' is required, 'type' and 'default' are optional
- 'type' may be 'str', 'int' or 'float'. If no type is specified,
'str' is assumed.
Running a script similar to the changes in this branch over a
local copy of all public charms known in Launchpad, I noticed
that many charms use the type 'boolean' too, so the changes in
this branch allow this too.
I added a new method, check_config_
scripts/
generates warnings or errors for those problems in config.yaml I
could imagine. (I would claim though that the check is indeed
complete...)
My first attempt to test the new method by adding charms with
test data to tests/charms turned quickly out to be really
cumbersome: Each simple test would require its own subdirectory with
a bunch of files in order to limit the errors generated when
tests/proof/test.sh is run to those relevant for the given test.
I added one charm with an error in config.yaml nevertheless, just
to have some kind of integration test. And the existing test charms
now also have a file config.yaml -- while this bloats the diff of this
branch considerably, the alternative would have been to add an error
message about a missing config file to each file in
tests/proof/
Most tests are done in the new file tests/proof/
The setup of the test is a bit cumbersome, especially the manipulation
of sys.path, but the setup of a better infrastructure for unit tests
is something for another branch, I think.
Unmerged revisions
- 184. By Abel Deuring
-
call Linter.
check_config_ file() in proof.py; add test files for tests/proof/test.sh - 183. By Abel Deuring
-
check of config file completed.
- 182. By Abel Deuring
-
config.yaml: checks for valid option keys added.
- 181. By Abel Deuring
-
proof.py: start checking config.yaml; unit tests for config.yaml checks added
Thanks for this work. However lp:charm-tools is about to be massively updated today with work done in the lp:~marcoceppi/charm-tools/python-port branch. Could you move your changes to proof.py and test work to that branch and re-propose the merge there?