-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add support for static linters #200
Changes from 3 commits
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
from __future__ import print_function | ||
|
||
import os | ||
from avocado import Test | ||
from moduleframework import module_framework | ||
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. remove this line and remove 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. It is not possible, because we have in |
||
from moduleframework import dockerlinter | ||
|
||
class DockerInstructionsTests(module_framework.AvocadoTest): | ||
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. replace by inherited from |
||
""" | ||
:avocado: enable | ||
:avocado: tags=sanity,rhel,fedora,docker,docker_instruction_test | ||
|
||
""" | ||
|
||
dp = None | ||
|
||
def setUp(self): | ||
# it is not intended just for docker, but just docker packages are | ||
# actually properly signed | ||
self.dp = dockerlinter.DockerfileLinter() | ||
if self.dp.dockerfile is None: | ||
self.skip("Dockerfile was not found") | ||
|
||
def test_from_is_first_directive(self): | ||
self.assertTrue(self.dp.check_from_is_first()) | ||
|
||
def test_from_directive_is_valid(self): | ||
self.assertTrue(self.dp.check_from_directive_is_valid()) | ||
|
||
def test_chained_run_dnf_commands(self): | ||
self.assertTrue(self.dp.check_chained_run_dnf_commands()) | ||
|
||
def test_chained_run_rest_commands(self): | ||
self.assertTrue(self.dp.check_chained_run_rest_commands()) | ||
|
||
def test_helpmd_is_present(self): | ||
self.assert_to_warn(self.assertTrue, self.dp.check_helpmd_is_present()) | ||
|
||
|
||
class DockerLabelsTests(DockerInstructionsTests): | ||
""" | ||
:avocado: enable | ||
:avocado: tags=sanity,rhel,fedora,docker,docker_labels_test | ||
|
||
""" | ||
|
||
def _test_for_env_and_label(self, docker_env, docker_label, env=True): | ||
label_found = True | ||
if env: | ||
label = self.dp.get_docker_specific_env(docker_env) | ||
else: | ||
label = self.dp.get_specific_label(docker_env) | ||
if not label: | ||
label_found = self.dp.get_specific_label(docker_label) | ||
return label_found | ||
|
||
def test_architecture_in_env_and_label_exists(self): | ||
self.assertTrue(self.dp.get_specific_label("architecture")) | ||
|
||
def test_name_in_env_and_label_exists(self): | ||
self.assertTrue(self.dp.get_docker_specific_env("NAME=")) | ||
self.assertTrue(self.dp.get_specific_label("name")) | ||
|
||
def test_maintainer_label_exists(self): | ||
self.assertTrue(self.dp.get_specific_label("maintainer")) | ||
|
||
def test_release_label_exists(self): | ||
self.assertTrue(self.dp.get_specific_label("release")) | ||
|
||
def test_version_label_exists(self): | ||
self.assertTrue(self.dp.get_specific_label("version")) | ||
|
||
def test_com_redhat_component_label_exists(self): | ||
self.assertTrue(self.dp.get_specific_label("com.redhat.component")) | ||
|
||
def test_summary_label_exists(self): | ||
self.assertTrue(self.dp.get_specific_label("summary")) | ||
|
||
def test_run_or_usage_label_exists(self): | ||
self.assertTrue(self._test_for_env_and_label("run", "usage", env=False)) | ||
|
||
|
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.
this change cause regression (now args.linter schedule all generic tests) with your change, just part of them will be sheduled. Is that intentional? we can discuss it. I'm not against this idea, but we should think about it more.