Skip to content

Commit

Permalink
replaced circle flag in lint command with outfile argument
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakovi committed Jan 20, 2020
1 parent 92812e9 commit f301be3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Added validation for docker image inside integrations and scripts.
* Added --use-git flag to **format** command to format all changed files.
* Fixed an issue where **validate** did not fail on dockerimage changes with bc check.
* Added --circle flag to **lint**.
* Added --outfile to **lint** to allow saving failed packages to a file.


### 0.3.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pylint and pytest will run within all the docker images of an integration/script
Keep the test container (default: False)
* **-v, --verbose**
Verbose output (default: False)
* **--circle** Indicates that the command runs in CircleCI (default: False)
* **--outfile** Specify a file path to save failing package list. (default: None)
* **--cpu-num CPU_NUM**
Number of CPUs to run pytest on (can set to `auto` for automatic detection of the number of CPUs.) (default: 0)

Expand Down
10 changes: 5 additions & 5 deletions demisto_sdk/dev_tools/lint_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class LintManager:
parallel (bool): Whether to run command on multiple threads.
max_workers (int): How many workers to run for multi-thread run.
run_all_tests (bool): Whether to run all tests.
circle (bool): Indicates lint command runs in CircleCI.
outfile (str): file path to save failed package list.
configuration (Configuration): The system configuration.
"""

def __init__(self, project_dir_list: str, no_test: bool = False, no_pylint: bool = False, no_flake8: bool = False,
no_mypy: bool = False, verbose: bool = False, root: bool = False, keep_container: bool = False,
cpu_num: int = 0, parallel: bool = False, max_workers: int = 10, no_bandit: bool = False,
git: bool = False, run_all_tests: bool = False, circle: bool = False,
git: bool = False, run_all_tests: bool = False, outfile: str = '',
configuration: Configuration = Configuration()):

if no_test and no_pylint and no_flake8 and no_mypy and no_bandit:
Expand Down Expand Up @@ -70,7 +70,7 @@ def __init__(self, project_dir_list: str, no_test: bool = False, no_pylint: bool
self.configuration = configuration
self.requirements_for_python3 = get_dev_requirements(3.7, self.configuration.envs_dirs_base, self.log_verbose)
self.requirements_for_python2 = get_dev_requirements(2.7, self.configuration.envs_dirs_base, self.log_verbose)
self.circle = circle
self.outfile = outfile

@staticmethod
def get_all_directories() -> List[str]:
Expand Down Expand Up @@ -238,7 +238,7 @@ def create_failed_unittests_file(self, failed_unittests):
The file will be read in slack_notifier script - which will send the failed unittests to the content-team
channel.
"""
with open('./artifacts/failed_unittests.txt', "w") as failed_unittests_file:
with open(self.outfile, "w") as failed_unittests_file:
failed_unittests_file.write('\n'.join(failed_unittests))

def _print_final_results(self, good_pkgs: List[str], fail_pkgs: List[str]) -> int:
Expand All @@ -251,7 +251,7 @@ def _print_final_results(self, good_pkgs: List[str], fail_pkgs: List[str]) -> in
Returns:
int. 0 on success and 1 if any package failed
"""
if self.circle:
if self.outfile:
self.create_failed_unittests_file(fail_pkgs)

if fail_pkgs:
Expand Down
2 changes: 1 addition & 1 deletion demisto_sdk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def secrets(config, **kwargs):
@click.option(
"-a", "--run-all-tests", is_flag=True, help="Run lint on all directories in content repo")
@click.option(
"--circle", is_flag=True, help="Indicates the command runs in circle"
"--outfile", help="Save failing packages to a file"
)
@pass_config
def lint(config, dir, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions docs/lint_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ make sure the code works as intended.
Keep the test container (default: False)
* **-v, --verbose**
Verbose output (default: False)
* **--circle** Indicates that the command runs in CircleCI (default: False)
* **--outfile** Specify a file path to save failing package list. (default: None)
* **--cpu-num CPU_NUM**
Number of CPUs to run pytest on (can set to `auto` for automatic detection of the number of CPUs.) (default: 0)

Expand All @@ -63,5 +63,5 @@ This will run only the linters (flake8, mypy, bandit) on "Scripts/HelloWorldScri
`demisto-sdk lint -d Integrations/HelloWorld --no-mypy --no-flake8 --no-pytest -k -r`
This will run only pylint and pytest on "Integrations/HelloWorld" using the root user for the pytest and will also keep the test container with the docker image after the operation is over.

`demisto-sdk lint -g --circle`
This indicates lint runs in CircleCI and only on changed packages from content repo's 'origin/master' branch.
`demisto-sdk lint -g --outfile ~/failures.txt`
This indicates lint runs only on changed packages from content repo's 'origin/master' branch and saves the failed packages to failures.txt file.

0 comments on commit f301be3

Please sign in to comment.