Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions .github/workflows/jest-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: 'coverage'
on:
pull_request:
branches:
- master
- main
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ArtiomTr/jest-coverage-report-action@v2
id: coverage
with:
output: report-markdown
- uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.coverage.outputs.report }}
# name: 'coverage'
# on:
# pull_request:
# branches:
# - master
# - main
# jobs:
# coverage:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: ArtiomTr/jest-coverage-report-action@v2
# id: coverage
# with:
# output: report-markdown
# - uses: peter-evans/create-or-update-comment@v3
# with:
# issue-number: ${{ github.event.pull_request.number }}
# body: ${{ steps.coverage.outputs.report }}
60 changes: 30 additions & 30 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: Jest
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
# name: Jest
# on: push
# jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version: "16"

# Speed up subsequent runs with caching
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# Install required deps for action
- name: Install Dependencies
run: npm install
# # Speed up subsequent runs with caching
# - name: Cache node modules
# uses: actions/cache@v3
# env:
# cache-name: cache-node-modules
# with:
# # npm cache files are stored in `~/.npm` on Linux/macOS
# path: ~/.npm
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
# # Install required deps for action
# - name: Install Dependencies
# run: npm install

# Finally, run our tests
- name: Run the tests
run: npm test
# # Finally, run our tests
# - name: Run the tests
# run: npm test
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

*/bin
*/include
*/lib
*pyvenv.cfg


# dependencies
/node_modules
/.pnp
Expand Down Expand Up @@ -33,3 +39,4 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.env
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": "${command:pickArgs}"
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
54 changes: 54 additions & 0 deletions github/repos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import logging
from typing import Dict, List, Any
import requests

def __request_repos_for_user(username: str) -> List[Any]:
"""Get repos for a GitHub user
GitHub docs: https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user

Args:
username (str): _description_
"""
token = os.environ.get('GITHUB_TOKEN')
headers = {
'Authorization': f'token {token}',
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github+json'
}
timeout = 10

params: Dict[str, int] = { 'per_page': 100, 'page': 1 }
repos: List[Any] = []
try:
continue_paging = True
while continue_paging:
r = requests.get(f'https://api.github.com/users/{username}/repos',
headers = headers,
params = params,
timeout = timeout
)
result = r.json()
if len(result) == 0:
continue_paging = False
else:
params['page'] = params['page'] + 1
repos.extend(result)
except Exception as e:
logging.error(f"--- ERROR --- {e}")
print(f"--- ERROR --- {e}")

return repos

def user_repos_report(username: str):
"""Handle reporting GitHub repos for user
"""

repos = __request_repos_for_user(username)
print(repos)

def handle_args(args):
print(f"IN github/repos.py args: {args}")

if args.report == 'list':
user_repos_report(args.user)
46 changes: 45 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@

import argparse
import textwrap
import github.repos as gh_repos
from dotenv import load_dotenv

def start_repl():
print("Welcome to the REPL")

while True:
try:
user_input = input(">> ").strip().lower()
if user_input in ('exit', 'quit'):
print('Exiting!...')
break

args_list = user_input.split()
print(args_list)
except KeyboardInterrupt:
print('Exiting \n')
break

def main():
"""Main - entry point, and sets up CLI args handling
"""
print("Welcome to GitHub Inventory!")
load_dotenv()

parser = argparse.ArgumentParser(prog = 'github-inventory',
formatter_class = argparse.RawDescriptionHelpFormatter,
epilog = textwrap.dedent('Examples: main.py --option')
)
parser.add_argument('--repl', action = argparse.BooleanOptionalAction, help = "Start REPL-mode")

subparsers = parser.add_subparsers(dest = 'service', required = True)
gh_parser = subparsers.add_parser('github', help = 'GitHub related commands')
gh_subparser = gh_parser.add_subparsers(dest = 'command')

repo_parser = gh_subparser.add_parser('repo', help = 'GitHub repo commands')
repo_parser.add_argument('--name', type = str, help = 'Name of repository')
repo_parser.add_argument('--report', type = str, help = 'Type of report to execute')
repo_parser.add_argument('--user', type = str, help = 'GitHub username')
repo_parser.add_argument('--csv', action = argparse.BooleanOptionalAction)
repo_parser.set_defaults(func = gh_repos.handle_args)

args = parser.parse_args()
if hasattr(args, 'func'):
args.func(args)

if __name__ == "__main__":
main()
main()
11 changes: 11 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
certifi==2025.7.14
charset-normalizer==3.4.2
idna==3.10
markdown-it-py==3.0.0
mdurl==0.1.2
Pygments==2.19.2
python-dotenv==1.1.1
requests==2.32.4
rich==14.0.0
typing_extensions==4.14.1
urllib3==2.5.0