-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use native API and UI for running tests * Remove obsolete settings * Fix yum tests * Fix import issues * Refactor pytest.ini * Add download-requirements tests to pytest.ini * Use default junit_family * Do not use deprecated distutils package * Ignore only known warnings * Fix pylint import issues for download-requirements * Update py-version * Fix comment * Refactor VSCode tasks * Format tasks.json * Add "Pylint download-requirements" task
- Loading branch information
Showing
9 changed files
with
86 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# https://code.visualstudio.com/docs/python/environments#_environment-variables | ||
|
||
# PYTHONPATH can contain multiple locations separated by os.pathsep: semicolon (;) on Windows and colon (:) on Linux/macOS. | ||
# Invalid paths are ignored. To verify use "python.analysis.logLevel": "Trace". | ||
PYTHONPATH="ansible/playbooks/roles/repository/files/download-requirements:${PYTHONPATH}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,68 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Pytest", | ||
"type": "shell", | ||
"command": "mkdir -p test_results && pytest --junitxml=${workspaceFolder}/test_results/pytest_results.xml" | ||
}, | ||
{ | ||
"label": "Pylint junit", | ||
"type": "shell", | ||
"command": "mkdir -p test_results && pylint --rcfile .pylintrc ./cli ./tests --output ${workspaceFolder}/test_results/pylint_results.xml" | ||
}, | ||
{ | ||
"label": "Pylint terminal", | ||
"type": "shell", | ||
"command": "pylint --rcfile .pylintrc ./cli ./tests --output-format text" | ||
}, | ||
{ | ||
"label": "Ansible-lint junit", | ||
"type": "shell", | ||
"command": "mkdir -p test_results && ansible-lint --nocolor -q -c .ansible-lint -p ${workspaceFolder}/ansible/playbooks/*.yml > ${workspaceFolder}/test_results/ansiblelint_results.txt ; ansible-lint-to-junit-xml ${workspaceFolder}/test_results/ansiblelint_results.txt > ${workspaceFolder}/test_results/ansiblelint_results.xml" | ||
}, | ||
{ | ||
"label": "Ansible-lint terminal", | ||
"type": "shell", | ||
"command": "ansible-lint -q -c .ansible-lint -p ${workspaceFolder}/ansible/playbooks/*.yml" | ||
}, | ||
{ | ||
"label": "Rubocop junit", | ||
"type": "shell", | ||
"command": "mkdir -p test_results && rubocop -c .rubocop.yml --require rubocop/formatter/junit_formatter --format RuboCop::Formatter::JUnitFormatter --out test_results/rubocop_results.xml" | ||
}, | ||
{ | ||
"label": "Rubocop terminal", | ||
"type": "shell", | ||
"command": "rubocop -c .rubocop.yml" | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 for the documentation about the tasks.json format | ||
"problemMatcher": [], | ||
"type": "shell", | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Ensure test_results directory", | ||
"command": "mkdir -p ${workspaceFolder}/test_results", | ||
"presentation": { | ||
"echo": false, | ||
"reveal": "silent", | ||
"showReuseMessage": false, | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"label": "Pytest", | ||
"command": "pytest --junitxml=${workspaceFolder}/test_results/pytest_results.xml", | ||
"dependsOn": ["Ensure test_results directory"], | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Pylint epicli [junit]", | ||
"command": "pylint --rcfile .pylintrc ./cli ./tests --output ${workspaceFolder}/test_results/pylint_results.xml", | ||
"dependsOn": ["Ensure test_results directory"], | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Pylint epicli [terminal]", | ||
"command": "pylint --rcfile .pylintrc ./cli ./tests --output-format text", | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Pylint download-requirements", | ||
"command": "pylint", | ||
"args": [ | ||
"--rcfile", ".pylintrc", | ||
"--output-format", "text", | ||
"./ansible/playbooks/roles/repository/files/download-requirements/download-requirements.py", | ||
"./ansible/playbooks/roles/repository/files/download-requirements/src", | ||
"./ansible/playbooks/roles/repository/files/download-requirements/tests", | ||
], | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Ansible-lint [junit]", | ||
"command": "ansible-lint --nocolor -q -c .ansible-lint -p ${workspaceFolder}/ansible/playbooks/*.yml > ${workspaceFolder}/test_results/ansiblelint_results.txt ; ansible-lint-to-junit-xml ${workspaceFolder}/test_results/ansiblelint_results.txt > ${workspaceFolder}/test_results/ansiblelint_results.xml", | ||
"dependsOn": ["Ensure test_results directory"], | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Ansible-lint [terminal]", | ||
"command": "ansible-lint -q -c .ansible-lint -p ${workspaceFolder}/ansible/playbooks/*.yml", | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Rubocop [junit]", | ||
"command": "rubocop -c .rubocop.yml --require rubocop/formatter/junit_formatter --format RuboCop::Formatter::JUnitFormatter --out test_results/rubocop_results.xml", | ||
"dependsOn": ["Ensure test_results directory"], | ||
"group": "test", | ||
}, | ||
{ | ||
"label": "Rubocop [terminal]", | ||
"command": "rubocop -c .rubocop.yml", | ||
"group": "test", | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
ansible/playbooks/roles/repository/files/download-requirements/conftest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This file fixes import issues (like ModuleNotFoundError: No module named 'tests.mocks') | ||
# when discovering or running tests by adding parent directory to sys.path. | ||
# See https://stackoverflow.com/a/50610630/10861750 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# This file should only contain common options (not CI pipeline or IDE specific) | ||
[pytest] | ||
addopts = -x tests/ -p no:warnings | ||
junit_family = xunit1 | ||
filterwarnings = | ||
# packaging package is dependency of azure-cli | ||
ignore:The distutils package is deprecated:DeprecationWarning:packaging.tags | ||
testpaths = | ||
tests/unit/ | ||
ansible/playbooks/roles/repository/files/download-requirements/tests/ |