- Python 3.11 or newer
- pip and pipenv
- Clone the Project
First, clone the repository to your local machine:
git clone https://github.com/warestack/stack-analyzer.git
cd stack-analyzer- Set up your virtual environment
Use pipenv to create a virtual environment and install dependencies:
pipenv installThis command reads the Pipfile in the project root and installs all necessary packages, creating a virtual environment.
- Activate the Virtual Environment
Activate the pipenv-created virtual environment:
pipenv shell- Setting up your PAT token
The Stack Analyzer utilises the github API to analyze a repository's structure, so you'd need to create a .env file on the project root directory with the following content:
GITHUB_PAT=your_pat_token- Start the Flask Application
The repository includes a flask application for testing purposes. This means you can send curl commands to test various repositories while you develop more analyzers.
Run the Flask web service:
flask runAlternatively, you can run the application on debug (and live reload) mode:
flask --app app.py --debug runTo test the tech stack analyzer service, you can use curl to send a POST request to the /analyze endpoint. Replace http://127.0.0.1:5000 with the appropriate URL if you've configured the service to run elsewhere.
curl -X POST http://127.0.0.1:5000/analyze -H "Content-Type: application/json" -d "{\"repo_url\":\"https://github.com/example/repo\"}"This command simulates sending a repository URL to the analyzer. Given the project's current setup, it will return a JSON response based on the hardcoded analysis within the Flask application.
To run the unit tests (included within tests), you can use the following command while being at the project root directory:
python -m unittest discover testsOr if you want to run a specific unit test you could do so as such:
python -m unittest tests/test_analyze_node.pyOnce we some changes that we want to publish to PyPI (or test.PyPi), we can build a new library version as such:
python setup.py sdist bdist_wheel # build a new version
twine upload --repository testpypi dist/* # publish to test PyPI