codevista / app.py
vsagar100's picture
Added token, git repo download
df513b0
raw
history blame
1.68 kB
# app.py
# Import necessary modules from lib
from lib.code_reviewer import CodeReviewer, ReviewManager
import os
import glob
# Variables for GitHub repository details
GITHUB_REPO_URL = "https://github.com/vsagar100/ansible_tf_provisioner"
GITHUB_BRANCH = "main" # Specify the branch or tag to download
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN") # Specify your GitHub token
def main():
# Directory structure setup
# Directory for storing downloaded GitHub repository
download_directory = "downloaded_repo"
# Directory for storing output JSON reviews
output_directory = "output_reviews"
# Ensure the directories exist
os.makedirs(download_directory, exist_ok=True)
os.makedirs(output_directory, exist_ok=True)
# Initialize the code reviewer and review manager
code_reviewer = CodeReviewer()
review_manager = ReviewManager(reviewer=code_reviewer)
# Download GitHub repository
review_manager.download_repo(GITHUB_REPO_URL, GITHUB_BRANCH, GITHUB_TOKEN, download_directory)
# Find all YAML files in the downloaded repository
yaml_files = glob.glob(os.path.join(download_directory, "**", "*.yml"), recursive=True)
yaml_files += glob.glob(os.path.join(download_directory, "**", "*.yaml"), recursive=True)
# Process files and generate reviews
reviews = review_manager.process_files(yaml_files)
# Save reviews to JSON
output_json_path = os.path.join(output_directory, "code_review_results.json")
review_manager.save_reviews_to_json(reviews, output_json_path)
print(f"Reviews saved to {output_json_path}")
if __name__ == "__main__":
main()