-
Notifications
You must be signed in to change notification settings - Fork 27
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
FMF metadata support to colin #141
Conversation
a5c8249
to
f8c4ef7
Compare
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.
It would be for the best to discuss this in person.
colin/checks/dockerfile.py.fmf
Outdated
@@ -0,0 +1,19 @@ | |||
description: "asdasdsfdasfsda f" |
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.
what format is this? is it yaml?
colin/core/checks/abstract_check.py
Outdated
def _get_fmf_metadata(self): | ||
output = {} | ||
classfile = inspect.getfile(self.__class__) | ||
fmf_tree = fmf.Tree(os.path.dirname(classfile)) |
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.
does this mean that we would have to store the metadata alongside the .py file?
colin/core/checks/abstract_check.py
Outdated
setattr(self, k, metadata_dict[k]) | ||
|
||
def __init__(self, message=None, description=None, reference_url=None, tags=None): | ||
if message or description or reference_url or tags: |
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.
better logic could be to load the metadata and just enable overriding them
af8f0e9
to
caf053c
Compare
@@ -0,0 +1,188 @@ | |||
#!/usr/bin/python3 |
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.
Since this script actually proposes a new runtime, I would personally prefer to have it proposed in a different PR. I actually dislike that it's not integrated into colin's CLI interface.
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.
yep, this is my suggested solution, split this PR, to 2 or 3 PRs, and last of them will be this nosetests generator.
But on other hand, without this, it is harder to show benefits eg:
- write tests just in metadata without empty python classes
- using nosetests scheduled tests
- filtering and selecting or test items
- using FMF rulesets
And this PR will just split metadata outside python classes to FMF files.
But I agree and with this knowledge, that these PRs are closely connected I can split it.
reference_url="https://fedoraproject.org/wiki/Container:Guidelines#FROM", | ||
tags=["from", "dockerfile", "baseimage", "latest"]) | ||
class FromTagNotLatestCheck(FMFAbstractCheck, DockerfileAbstractCheck): | ||
name, metadata = FMFAbstractCheck.get_metadata("from_tag_not_latest") |
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 wonder whether there is a nicer way of doing this. Calling functions on class' attributes outside of methods seems sketchy.
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.
Yep, I had also troubles with this, but actually there is probably not better way how to do it without bigger changes in colin. Because current colin implementation does static inspection of classes, to find checks based on class attribute name
. If you have some idea I'll be happy to change it to better way
FMF Metadata works well
FMF metadata support in colin. There are two different parts
TODOs:
research how to ideally solve two
__init__()
or how to check that all variables are setfind way how to name tests
transform all
__init__
s to FMF compatible wayfind way how transform rulesets to FMF testsets
remove all duplicated stuff from colin what is already implemented by FMF** (next PRs)
Colin output:
$ python -m colin.cli.colin list-checks
python -m colin.cli.colin check tests/data/Dockerfile
FMF output
fmf show --path colin/checks
when I want to be supercool and have backward compilant output:
use format abilites of fmf:
fmf show --path colin/checks --format "{}\n -> {}\n -> {}\n -> {}\n -> {}\n\n" --value name --value "data['description']" --value "data['message']" --value "data['reference_url']" --value "data['tags']"
Nosetests output - direct
TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py
using rulesets
advanced filtering
possible to apply them to rulesets or directy to testcases
FILTERS=tags:dockerfile TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py
$ NAMES="from_tag_not_latest;maintainer_label" TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py
rulesets filters
$ NAMES=default RULESETPATH=rulesets/ TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py
$ NAMES=fedora RULESETPATH=rulesets/ TARGET=tests/data/Dockerfile nosetests -d -v fmf_scheduler.py
fedora ruleset is not given there, so that it runs 0 tests