-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rohitinu6:main' into main
- Loading branch information
Showing
64 changed files
with
99,097 additions
and
15,024 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Issue Reference Number: | ||
<!-- Please mention the issue number this PR addresses (e.g., Resolves #123) --> | ||
|
||
## Description of Changes: | ||
<!-- Please provide a summary of the changes this PR introduces. Include all relevant context --> | ||
|
||
## Type of Change: | ||
<!-- Please delete options that are not relevant --> | ||
- [ ] Bug fix | ||
- [ ] New ML model | ||
- [ ] Feature engineering | ||
- [ ] Data analysis | ||
- [ ] Documentation update | ||
- [ ] Code refactor | ||
- [ ] Other (please specify in detail): | ||
|
||
## Checklist: | ||
<!-- Please check off the following, if applicable --> | ||
- [ ] My code follows the style guidelines of this project | ||
- [ ] I have performed a self-review of my code | ||
- [ ] I have made sure to comment on my code, particularly in hard-to-understand areas | ||
- [ ] My changes generate no new warnings or errors | ||
- [ ] Unit tests pass locally with my changes | ||
|
||
## Notes for Testing your implementation: | ||
<!-- Describe how the changes or the model you added can be tested for accuracy. Include any setup or dependencies that the maintainer or reviewer might need to install --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import os | ||
import requests | ||
from collections import defaultdict | ||
|
||
# GitHub API URL for closed pull requests | ||
API_URL = "https://api.github.com/repos/rohitinu6/Stock-Price-Prediction/pulls?state=closed" | ||
|
||
GITHUB_TOKEN = os.getenv("GH_TOKEN") | ||
|
||
# Points mapping based on the label names | ||
points_map = { | ||
"level1": 10, | ||
"level2": 25, | ||
"level3": 45 | ||
} | ||
|
||
# Function to fetch closed pull requests with pagination | ||
def get_closed_prs(): | ||
headers = {} | ||
|
||
if GITHUB_TOKEN: | ||
headers = {"Authorization": f"token {GITHUB_TOKEN}"} | ||
|
||
prs = [] | ||
page = 1 | ||
while True: | ||
response = requests.get(f"{API_URL}&page={page}", headers=headers) | ||
|
||
if response.status_code != 200: | ||
raise Exception(f"Failed to fetch PRs: {response.status_code} {response.text}") | ||
|
||
page_prs = response.json() | ||
|
||
if not page_prs: | ||
break | ||
|
||
prs.extend(page_prs) # Add fetched PRs to the list | ||
page += 1 # Increment page number for next request | ||
|
||
return prs | ||
|
||
leaderboard = defaultdict(lambda: {"points": 0, "avatar_url": ""}) | ||
|
||
prs = get_closed_prs() | ||
|
||
# Loop through each PR and calculate points based on the labels | ||
for pr in prs: | ||
user = pr['user']['login'] | ||
avatar_url = pr['user']['avatar_url'] | ||
labels = pr['labels'] | ||
|
||
for label in labels: | ||
label_name = label['name'] | ||
if label_name in points_map: | ||
leaderboard[user]["points"] += points_map[label_name] | ||
leaderboard[user]["avatar_url"] = avatar_url | ||
|
||
# Function to generate the leaderboard in markdown format | ||
def generate_leaderboard_md(leaderboard): | ||
sorted_leaderboard = sorted(leaderboard.items(), key=lambda x: x[1]["points"], reverse=True) | ||
|
||
md_content = "# Leaderboard\n\n" | ||
md_content += "| Avatar | Username | Points |\n" | ||
md_content += "|--------|----------|--------|\n" | ||
|
||
for user, data in sorted_leaderboard: | ||
points = data["points"] | ||
avatar_url = data["avatar_url"] | ||
md_content += f'| <img src="{avatar_url}" width="50" height="50"> | {user} | {points} |\n' | ||
|
||
return md_content | ||
|
||
# Generate the leaderboard markdown and save it to a file | ||
leaderboard_md = generate_leaderboard_md(leaderboard) | ||
|
||
# Save the leaderboard to leaderboard.md | ||
with open('leaderboard.md', 'w') as f: | ||
f.write(leaderboard_md) | ||
|
||
print("Leaderboard updated successfully!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import os | ||
import github | ||
from github import Github | ||
|
||
# Helper function to recursively build the repo structure and include file extensions | ||
def get_repo_structure(path='.', prefix=''): | ||
structure = [] | ||
try: | ||
items = sorted(os.listdir(path)) | ||
except FileNotFoundError: | ||
print(f"Path not found: {path}") | ||
return structure | ||
|
||
for i, item in enumerate(items): | ||
if item.startswith('.'): | ||
continue # Skip hidden files and directories | ||
item_path = os.path.join(path, item) | ||
is_last = i == len(items) - 1 | ||
current_prefix = '└── ' if is_last else '├── ' | ||
|
||
if os.path.isdir(item_path): | ||
# Directory case | ||
structure.append(f"{prefix}{current_prefix}{item}/") | ||
next_prefix = prefix + (' ' if is_last else '│ ') | ||
structure.extend(get_repo_structure(item_path, next_prefix)) | ||
else: | ||
# File case with extension | ||
file_name, file_extension = os.path.splitext(item) | ||
structure.append(f"{prefix}{current_prefix}{file_name}{file_extension}") | ||
|
||
return structure | ||
|
||
# Function to update the repo_structure.txt file | ||
def update_structure_file(structure): | ||
try: | ||
with open('repo_structure.txt', 'w') as f: | ||
f.write('\n'.join(structure)) | ||
print("repo_structure.txt updated successfully.") | ||
except IOError as e: | ||
print(f"Error writing to repo_structure.txt: {e}") | ||
|
||
# Function to update the README.md with the new structure | ||
def update_README(structure): | ||
try: | ||
with open('PROJECT_STRUCTURE.md', 'r') as f: | ||
content = f.read() | ||
except FileNotFoundError: | ||
print("PROJECT_STRUCTURE.md not found.") | ||
return | ||
|
||
start_marker = '<!-- START_STRUCTURE -->' | ||
end_marker = '<!-- END_STRUCTURE -->' | ||
|
||
start_index = content.find(start_marker) | ||
end_index = content.find(end_marker) | ||
|
||
if start_index != -1 and end_index != -1: | ||
new_content = ( | ||
content[:start_index + len(start_marker)] + | ||
'\n```\n' + '\n'.join(structure) + '\n```\n' + | ||
content[end_index:] | ||
) | ||
try: | ||
with open('PROJECT_STRUCTURE.md', 'w') as f: | ||
f.write(new_content) | ||
print("PROJECT_STRUCTURE.md updated with new structure.") | ||
except IOError as e: | ||
print(f"Error writing to PROJECT_STRUCTURE.md: {e}") | ||
else: | ||
print("Markers not found in PROJECT_STRUCTURE.md. Structure not updated.") | ||
|
||
# Main function to compare and update repository structure | ||
def main(): | ||
gh_token = os.getenv('GH_TOKEN') | ||
gh_repo = os.getenv('GITHUB_REPOSITORY') | ||
|
||
if not gh_token or not gh_repo: | ||
print("Environment variables GH_TOKEN and GITHUB_REPOSITORY must be set.") | ||
return | ||
|
||
g = Github(gh_token) | ||
repo = g.get_repo(gh_repo) | ||
|
||
current_structure = get_repo_structure() | ||
|
||
try: | ||
# Fetch the contents of repo_structure.txt from GitHub | ||
contents = repo.get_contents("repo_structure.txt") | ||
existing_structure = contents.decoded_content.decode().split('\n') | ||
except github.GithubException: | ||
existing_structure = None | ||
|
||
if current_structure != existing_structure: | ||
update_structure_file(current_structure) | ||
update_README(current_structure) | ||
print("Repository structure updated.") | ||
else: | ||
print("No changes in repository structure.") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Issue Auto Comment | ||
|
||
# Created by @smog-root | ||
|
||
on: | ||
issues: | ||
types: [opened, closed] | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add a comment when an issue is opened | ||
if: github.event.action == 'opened' | ||
uses: actions-ecosystem/action-create-comment@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
issue_number: ${{ github.event.issue.number }} | ||
body: "👋 Thanks for opening this issue! We appreciate your contribution. Please make sure you’ve provided all the necessary details and screenshots, and don't forget to follow our Guidelines and Code of Conduct. Happy coding! 🚀 | ||
" | ||
|
||
- name: Add a comment when an issue is closed | ||
if: github.event.action == 'closed' | ||
uses: actions-ecosystem/action-create-comment@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
issue_number: ${{ github.event.issue.number }} | ||
body: " ✅ This issue has been successfully closed. Thank you for your contribution and helping us improve the project! If you have any more ideas or run into other issues, feel free to open a new one. Happy coding! 🚀" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: PR Contribution Rules Check | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
|
||
jobs: | ||
check-contribution-rules: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check PR Description for Contribution Rules | ||
run: | | ||
# Check for issue reference | ||
if ! grep -q "Issue Reference:" "$GITHUB_EVENT_PATH"; then | ||
echo "PR does not reference an issue." | ||
exit 1 | ||
fi | ||
# Check for description of changes | ||
if ! grep -q "Description of changes:" "$GITHUB_EVENT_PATH"; then | ||
echo "PR does not contain a description of changes." | ||
exit 1 | ||
fi | ||
- name: Success message | ||
run: echo "PR follows contribution rules." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Install Dependencies | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: dependencies installation | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Verify installation | ||
run: | | ||
pip list # List installed packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Greetings | ||
|
||
on: [pull_request_target, issues] | ||
|
||
jobs: | ||
greeting: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/first-interaction@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-message: "Ensure the issue is not similar or previously being worked on.Thanks for your time" | ||
pr-message: "Ensure the PR matches the requirements mentioned in the Contribution guide. The maintainer might get in touch to enusre quality. Thanks for your time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Issue Labeler | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
manage-labels: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Create or Update Labels | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
curl -X POST \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/labels \ | ||
-d '{ | ||
"name": "gssoc-ext", | ||
"color": "0e4075", | ||
"description": "GSSOC extended contribution" | ||
}' | ||
curl -X POST \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/labels \ | ||
-d '{ | ||
"name": "hacktoberfest", | ||
"color": "006b75", | ||
"description": "Hacktoberfest participation" | ||
}' | ||
curl -X POST \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/labels \ | ||
-d '{ | ||
"name": "hacktoberfest-accepted", | ||
"color": "95d2aa", | ||
"description": "Hacktoberfest contribution accepted" | ||
}' | ||
curl -X POST \ | ||
-H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/labels \ | ||
-d '{ | ||
"name": "level?", | ||
"color": "5319e7", | ||
"description": "Placeholder for difficulty level" | ||
}' | ||
- name: Add Labels to Issue | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: | | ||
gssoc-ext | ||
hacktoberfest | ||
hacktoberfest-accepted | ||
level? |
Oops, something went wrong.