We build demisto-sdk
to support python 3.7 and 3.8.
- Clone demisto-sdk repository
- Install demisto-sdk as editable versions
- Pre-commit hooks setup
- Develop new command
- Running unit-tests using tox
- Push changes to GitHub (Exernal PRs)
- Review Process
- Contributor License Agreement (Exernal PRs)
Perform the following command in the path you want the repository to be cloned:
git clone https://github.com/demisto/demisto-sdk.git
-
If you are using virtualenv for this proccess you can skip this step, uninstall current installed version of
demisto-sdk
:pip3 uninstall demisto-sdk
-
Inside root directory of
demisto-sdk
repository - Install PyPi package as editable package:pip3 install -e .
-
Validate that
demisto-sdk
installed path is correct bypip3 show demisto-sdk | grep Location
should be
demisto-sdk
repository in your local enviorment. -
Install dev-requirements -
pip3 install -r <repo>/requirements-dev.txt
We use are using pre-commit to run hooks on our build. To use it run:
- Install hook to be performed as a hook before commiting changes -
pre-commit install
- Enable auto update of pre-commit hooks -
pre-commit autoupdate
- In order to run pre-commit without commiting -
pre-commit run -a
(on all files),pre-commit run
(on staged files)
- Create package for your command in the following path:
<repo>/demisto_sdk/commands/<your_new_command>
. - Create the following in the above path:
-
CLI arguments parsing - Add CLI parsing in
<repo>/demisto_sdk/__main__
using click package. -
commands_module - The modules suppose to return
0
if succeed else1
, commonprint
function can import from<repo>/demisto_sdk/commands/common/tools.py
-
unit-tests -
-
Unit-tests should be located for each command in the following path-
<repo>/demisto_sdk/commands/<your_new_command>/tests
-
data files tests - Usally its shared data files for all commands which located in:
<repo>/demisto_sdk/tests/test_files
(you can use constants for right path in
<repo>/demisto_sdk/tests/constants_test.py
) -
check build influence on CircleCI -
- Test your functionality on CircleCI build of
Content
repository by changing requirements inContent
repository:-
Perform the following in
<content_repo>/dev-requirements-py3.txt
:-
Delete
demisto-sdk
requirement. -
Add the following requirement in new line -
git+https://github.com/demisto/demisto-sdk@<branch>
-
-
Remove cache using in CircleCI build config, perform the following in file
<content_repo>/.circleci/config.yml
- Remove the following string form the following key
restore_cache:
:-{{ checksum "dev-requirements-py3.txt" }}
- Remove the following string form the following key
-
- Test your functionality on CircleCI build of
-
-
Tox aims to automate and standardize testing in Python. It is part of a larger vision of easing the packaging, testing and release process of Python software, We use it inorder to check unit-tests on python versions 3.7 and 3.8.
If you have one interperter in your local environment it will skip the missing interperter and not failed - the 2 versions test will be performed in the CircleCI build.
- To run all our unit tests we use:
tox
on all envs, optional args:- For additional verbosity use:
tox -vv
- Run
tox
without verbosity run:tox -q
- Run on a specific environment, you can use:
tox -q -e py37
- For additional verbosity use:
- To run a specific test using pytest run:
pytest -vv tests/{test_file}.py::{TestClass}::{test_function}
The Demisto SDK is MIT Licensed and accepts contributions via GitHub pull requests. If you are a first time GitHub contributor, please look at these links explaining on how to create a Pull Request to a GitHub repo:
- https://guides.github.com/activities/forking/
- https://help.github.com/articles/creating-a-pull-request-from-a-fork/
Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub
A member of the team will be assigned to review the pull request. Comments will be provided by the team member as the review process progresses.
You will see a few GitHub Status Checks that help validate that your pull request is according to our standards:
- ci/circleci: build: We use CircleCI to run a full build on each commit of your pull request. The build will run our content validation hooks, linting and unit test. We require that the build pass (green build). Follow the
details
link of the status to see the full build UI of CircleCI. - LGTM analysis: Python: We use LGTM for continues code analysis. If your PR introduces new LGTM alerts, the LGTM bot will add a comment with links for more details. Usually, these alerts are valid and you should try to fix them. If the alert is a false positive, specify this in a comment of the PR.
- license/cla: Status check that all contributors have signed our contributor license agreement (see below).
Before merging any PRs, we need all contributors to sign a contributor license agreement. By signing a contributor license agreement, we ensure that the community is free to use your contributions.
When you contribute a new pull request, a bot will evaluate whether you have signed the CLA. If required, the bot will comment on the pull request, including a link to accept the agreement. The CLA document is available for review as a PDF.
If the license/cla
status check remains on Pending, even though all contributors have accepted the CLA, you can recheck the CLA status by visiting the following link (replace [PRID] with the ID of your PR): https://cla-assistant.io/check/demisto/demisto-sdk?pullRequest=[PRID] .
If you have a suggestion or an opportunity for improvement that you've identified, please open an issue in this repo. Enjoy and feel free to reach out to us on the DFIR Community Slack channel, or at [email protected].