Skip to content

Commit

Permalink
Merge a43ec3d into 088978d
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelYochpaz committed Jan 9, 2024
2 parents 088978d + a43ec3d commit 54f6022
Show file tree
Hide file tree
Showing 12 changed files with 513 additions and 81 deletions.
25 changes: 15 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
exclude: demisto_sdk/tests/test_files/.*|.circleci/config.yml|demisto_sdk/commands/.*/tests/test_files/.*
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.11"
rev: v0.1.11
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
args:
- --fix
- --exit-non-zero-on-fix
- --show-fixes
- repo: https://github.com/python-poetry/poetry
rev: "1.6.1"
rev: 1.6.1
hooks:
- id: poetry-check
- id: poetry-lock
args: [--check]
args:
- --check
files: ^pyproject.toml$
- id: poetry-export
args: [--without-hashes, "-o", "requirements.txt"]

args:
- --without-hashes
- -o
- requirements.txt
- repo: https://github.com/demisto/demisto-sdk
rev: v1.17.2
rev: v1.25.1
hooks:
- id: update-additional-dependencies
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
hooks:
- id: mypy
exclude: tests/.*|demisto_sdk/commands/init/templates/.*
# This is auto-generated dependencies list taken from `poetry.lock`. DO NOT EDIT MANUALLY
additional_dependencies:
- astroid==2.9.3 ; python_version >= "3.8" and python_version < "3.11"
- attrs==23.1.0 ; python_version >= "3.8" and python_version < "3.11"
Expand Down Expand Up @@ -89,6 +94,7 @@ repos:
- jsonschema==4.17.3 ; python_version >= "3.8" and python_version < "3.11"
- junitparser==3.1.0 ; python_version >= "3.8" and python_version < "3.11"
- lazy-object-proxy==1.9.0 ; python_version >= "3.8" and python_version < "3.11"
- lxml==5.1.0 ; python_version >= "3.8" and python_version < "3.11"
- mccabe==0.6.1 ; python_version >= "3.8" and python_version < "3.11"
- mergedeep==1.3.4 ; python_version >= "3.8" and python_version < "3.11"
- more-itertools==9.1.0 ; python_version >= "3.8" and python_version < "3.11"
Expand Down Expand Up @@ -191,7 +197,7 @@ repos:
- yamlordereddictloader==0.4.0 ; python_version >= "3.8" and python_version < "3.11"
- zipp==3.15.0 ; python_version >= "3.8" and python_version < "3.10"
- repo: https://github.com/psf/black
rev: "22.12.0"
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -207,7 +213,6 @@ repos:
language_version: python3
- id: name-tests-test
exclude: test_tools.py|demisto_sdk/commands/download/tests/tests_env/.*|demisto_sdk/commands/create_artifacts/tests/data|demisto_sdk/commands/common/content/tests/objects/pack_objects/script/script_test/TestNotUnifiedScript|demisto_sdk/commands/common/content/tests/objects/pack_objects/integration/integration_test/TestNotUnifiedIntegration|demisto_sdk/commands/test_content/tests/DemistoClientMock

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.13
hooks:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Fixed an issue where **lint** command didn't work on detached heads.
* Added the *DockerHubClient* class to allow interaction with the dockerhub-api efficiency and easily.
* Added support to check the version of the modeling rule against the demisto version of the XSIAM tenant when running the **modeling-rule test** command, and skip incompatible modeling rules.
* Added support for JetBrains IDEs (PyCharm, IDEA, etc.) to the **setup-env** command, and added a new `--ide` flag.
* Internal: Fixed an issue where `nativeimage` tags were not uploaded to buckets.
* Fixed an issue where **lint -g** crashed when comparing changes against branches which are not `master`.
* Fixed an issue in **prepare-content** command where the `incident to alert` process was not triggered when the playbook is set to only XSIAM.
Expand Down
45 changes: 38 additions & 7 deletions demisto_sdk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from demisto_sdk.commands.prepare_content.prepare_upload_manager import (
PrepareUploadManager,
)
from demisto_sdk.commands.setup_env.setup_environment import IDEType
from demisto_sdk.commands.split.ymlsplitter import YmlSplitter
from demisto_sdk.commands.test_content.test_modeling_rule import (
init_test_data,
Expand Down Expand Up @@ -3455,6 +3456,14 @@ def update_content_graph(


@main.command(short_help="Setup integration environments")
@click.option(
"--ide",
help="IDE type to configure the environment for. If not specified, the IDE will be auto-detected. Case-insensitive.",
default="auto-detect",
type=click.Choice(
["auto-detect"] + [IDEType.value for IDEType in IDEType], case_sensitive=False
),
)
@click.option(
"-i",
"--input",
Expand All @@ -3467,40 +3476,41 @@ def update_content_graph(
"--create-virtualenv",
is_flag=True,
default=False,
help="Create a virtualenv for the environment",
help="Create a virtualenv for the environment.",
)
@click.option(
"--overwrite-virtualenv",
is_flag=True,
default=False,
help="Overwrite existing virtualenvs. Use with the create-virtualenv flag",
help="Overwrite existing virtualenvs. Relevant only if the 'create-virtualenv' flag is used.",
)
@click.option(
"--secret-id",
help="Secret ID, to use with Google Secret Manager instance with `DEMISTO_SDK_GCP_PROJECT_ID` environment variable set.",
help="Secret ID to use for the Google Secret Manager instance. Requires the `DEMISTO_SDK_GCP_PROJECT_ID` environment variable to be set.",
required=False,
)
@click.option(
"--instance-name",
required=False,
help="Instance name to configure in XSOAR/XSIAM.",
help="Instance name to configure in XSOAR / XSIAM.",
)
@click.option(
"--run-test-module",
required=False,
is_flag=True,
default=False,
help="Whether to run test-module on the configured XSOAR/XSIAM instance",
help="Whether to run test-module on the configured XSOAR / XSIAM instance.",
)
@click.option(
"--clean",
is_flag=True,
default=False,
help="Clean the repo out of the temp files that were created by `lint`",
help="Clean the repository of temporary files created by the 'lint' command.",
)
@click.argument("file_paths", nargs=-1, type=click.Path(exists=True, resolve_path=True))
def setup_env(
input,
ide,
file_paths,
create_virtualenv,
overwrite_virtualenv,
Expand All @@ -3513,11 +3523,32 @@ def setup_env(
setup_env,
)

if ide == "auto-detect":
# Order decides which IDEType will be selected for configuration if multiple IDEs are detected
if (CONTENT_PATH / ".vscode").exists():
logger.info(
"Visual Studio Code IDEType has been detected and will be configured."
)
ide_type = IDEType.VSCODE
elif (CONTENT_PATH / ".idea").exists():
logger.info(
"PyCharm / IDEA IDEType has been detected and will be configured."
)
ide_type = IDEType.PYCHARM
else:
raise RuntimeError(
"Could not detect IDEType. Please select a specific IDEType using the --ide flag."
)

else:
ide_type = IDEType(ide)

if input:
file_paths = tuple(input.split(","))

setup_env(
file_paths,
file_paths=file_paths,
ide_type=ide_type,
create_virtualenv=create_virtualenv,
overwrite_virtualenv=overwrite_virtualenv,
secret_id=secret_id,
Expand Down
33 changes: 19 additions & 14 deletions demisto_sdk/commands/common/content_constant_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@
)
NATIVE_IMAGE_PATH = CONTENT_PATH / "Tests" / NATIVE_IMAGE_FILE_NAME

COMMON_SERVER_PYTHON_PATH = (
CONTENT_PATH / "Packs" / "Base" / "Scripts" / "CommonServerPython"
)
DEMISTO_MOCK_PATH = CONTENT_PATH / TESTS_DIR / "demistomock"
API_MODULES_SCRIPTS_DIR = CONTENT_PATH / "Packs" / "ApiModules" / "Scripts"

PYTHONPATH = [
Path(CONTENT_PATH).absolute(),
Path(CONTENT_PATH / "Packs" / "Base" / "Scripts" / "CommonServerPython").absolute(),
Path(CONTENT_PATH / TESTS_DIR / "demistomock").absolute(),
Path(__file__).parent.parent / "lint" / "resources" / "pylint_plugins",
path.absolute()
for path in [
Path(CONTENT_PATH),
COMMON_SERVER_PYTHON_PATH,
DEMISTO_MOCK_PATH,
Path(__file__).parent.parent / "lint" / "resources" / "pylint_plugins",
]
]
try:
PYTHONPATH.extend(
(
path.absolute()
for path in Path(
CONTENT_PATH / "Packs" / "ApiModules" / "Scripts"
).iterdir()
)

if API_MODULES_SCRIPTS_DIR.exists():
PYTHONPATH.extend(path.absolute() for path in API_MODULES_SCRIPTS_DIR.iterdir())

else:
logger.debug(
"Could not add API modules to 'PYTHONPATH' as the base directory does not exist."
)
except FileNotFoundError:
logger.info("ApiModules not found, skipping adding to PYTHONPATH")

0 comments on commit 54f6022

Please sign in to comment.