Skip to content

Latest commit

 

History

History
86 lines (55 loc) · 2.49 KB

CONTRIBUTING.md

File metadata and controls

86 lines (55 loc) · 2.49 KB

Contributing to GHASToolkit

The GHASToolkit project is an open-source library and CLI for working with the different features of GitHub Advance Security. We welcome contributions from the community! Here are some guidelines to help you get started.

Issues

The easiest way to contribute is to report issues. If you find a bug or have a feature request, please open an issue on the GitHub repository.

Requirements

  • python 3.10 or higher
  • uv

GHASToolkit needs to be able to run on all supported versions of Python. Please make sure to test your changes on all supported versions.

Building

To build the project, you just need to run the following command:

uv build

If you are having issues building / running the project, you might need to set the PYTHONPATH environment variable to the root of the project. You can do this by running the following command:

export PYTHONPATH=$PWD/src

Code Formatting

GHASToolkit uses black for code formatting. To format the code, you can use the following command:

uv run black .

Testing

GHASToolkit uses unittest for testing. To run the tests, you can use the following command:

uv run python -m unittest discover -v -s ./tests -p 'test_*.py'

API Requests / Responses

When writing tests for API requests, please make sure to use the responses library along with the utils module to mock the requests. This is important to ensure that the tests are not dependent on the actual API responses and can be run in isolation.

Example:

import responses
import utils

class TestMyClass(unittest.TestCase):
    @responses.activate
    def test_my_method(self):
        # This will add all the mocked
        utils.loadResponses('mytests', 'my_method')

        # Call the method
        result = utils.my_method()

        # Assert the result
        self.assertEqual(result, {'key': 'value'})

Running CLI

To run the CLI, you can use the following command:

uv run python -m ghastoolkit --help

Documentation

GHASToolkit uses sphinx for documentation. To build the documentation, run the following command:

uv run sphinx-build -b html ./docs ./public

Note: This might change in the future, but for now, the documentation is built using sphinx and hosted on GitHub Pages. You can find the documentation at https://ghastoolkit.github.io/.