{"id":18062080,"url":"https://github.com/morgan-sell/github-user-activity","last_synced_at":"2026-01-27T15:31:28.426Z","repository":{"id":258803467,"uuid":"875333542","full_name":"Morgan-Sell/github-user-activity","owner":"Morgan-Sell","description":"A CLI application to fetch the recent activity of a GitHub user and generate a detailed report in the CLI.","archived":false,"fork":false,"pushed_at":"2024-10-23T23:50:06.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T07:48:02.130Z","etag":null,"topics":["cicd","cli-app","pytest","python","shell","strategy-pattern"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Morgan-Sell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-19T17:41:30.000Z","updated_at":"2024-10-23T23:50:09.000Z","dependencies_parsed_at":"2024-10-24T02:32:36.435Z","dependency_job_id":"e8c55c49-11d1-4fbc-980d-4d72a376549e","html_url":"https://github.com/Morgan-Sell/github-user-activity","commit_stats":null,"previous_names":["morgan-sell/github-user-activity"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morgan-Sell%2Fgithub-user-activity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morgan-Sell%2Fgithub-user-activity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morgan-Sell%2Fgithub-user-activity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morgan-Sell%2Fgithub-user-activity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morgan-Sell","download_url":"https://codeload.github.com/Morgan-Sell/github-user-activity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339158,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cicd","cli-app","pytest","python","shell","strategy-pattern"],"created_at":"2024-10-31T05:05:38.430Z","updated_at":"2026-01-27T15:31:28.382Z","avatar_url":"https://github.com/Morgan-Sell.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub User Activity Tracker\n\n## Introduction\n\nThis project is a Python-based application that retrieves and analyzes the GitHub activity history of a specified GitHub user. The application interacts with the GitHub API to provide details about various activities, such as commits, pull requests, issues, and reviews. It leverages the **Strategy Design Pattern**, which makes the system flexible, scalable, and easy to maintain.\n\nBy using the Strategy pattern, the application delegates event-specific logic to different strategy classes. This makes it simple to add new types of events in the future without modifying the core system, adhering to the **Open/Closed Principle** of object-oriented design.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Features](#features)\n- [Event Strategies](#event-strategies)\n- [Dependencies](#dependencies)\n- [Configuration](#configuration)\n- [Documentation](#documentation)\n- [Examples](#examples)\n- [Troubleshooting](#troubleshooting)\n- [License](#license)\n- [Acknowledgement](#acknowledgement)\n\n## Installation\n\n### Prerequisites\n\n- Python 3.11 or higher\n- GitHub API token\n\n### Steps\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/Morgan-Sell/github-user-activity.git\n    cd github-user-activity\n    ```\n\n2. Run the initial setup:\n\n    ```\n    ./run.sh initial-setup\n    ```\n\n    This script will:\n\n   - Check and load environment variables from the `.env` file\n   - Set up a virtual environment\n   - Activate the virtual environment\n   - Install dependencies\n  \n3. Run the application:\n\n    ```\n    ./run.sh run-app\n    ```\n\n## Usage\n\nOnce you run the application, you can select which GitHub user's activity would you like to see. \n\nLet's see what [Eric Riddoch](https://github.com/phitoduck), an exceptional MLOps engineer, has been up to.\n\n```\n$ Which GitHub user's activity would you like to see? phitoduck\n\nPushed 66 times.\nCreated 15 repos, branches, or tags.\nOpen or closed 2 issues.\nCommented on 3 issues or PRs.\nOpened, closed, or merged 2 PRs.\nReviewed 4 PRs.\nCommented on 3 PR reviews.\nForked 1 repos.\nStarred 1 repos.\n```\n\nThe application will then ask if you would like to see details of a specific even type. As of now, there are **5 valid event types** that must be entered in the following format:\n\n- IssueCommentEvent\n- IssuesEvent\n- PullRequestEvent\n- PullRequestReviewEvent\n- PushEvent\n\n\nHere's an example of the question and a response:\n\n```\n$ Select an event type to see a more detailed history of phitoduck's activity. PullRequestReviewEvent\n```\n\nThe application will generate a table showcasing the details of the selected GitHub event, which in this example is a PR review.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./img/event_table.png\" alt=\"Strategy Pattern Diagram\" width=\"850\" height=100/\u003e\n\u003c/p\u003e\n\n\n\nThe application will then ask if you would like to view another GitHub user's activity. You can continue to collect GitHub users' activity and request details on accepted event type for a long as you wish.\n\n## Features\n- **Fetch GitHub Activity**: Retrieve the activity history for a specified GitHub user, including details like commits, pull requests, and issues.\n- **Strategy Design Pattern**: The application dynamically handles different GitHub events using strategies, making the system easily extendable.\n- **Supports Multiple Event Types**: Handles events like commits, pull requests, issue comments, and reviews.\n- **Extensible and Scalable**: New event types can be added by implementing additional strategies without modifying the core logic.\n- **Environment Variable Management**: Uses a `.env` file to securely load sensitive data like GitHub API tokens.\n\n\n## Event Strategies\n\nThis application follows the **Strategy Design Pattern**, where each type of GitHub event is processed by a separate strategy. The `EventType` class (the **Context**) interacts with different strategies, e.g., `IssueCommentStrategy`, to extract the relevant event data.\n\n### Key Components:\n- **EventType** (Context): Uses an `EventExtractionStrategy` to process and extract event details.\n- **EventExtractionStrategy** (Strategy Interface): Defines methods for extracting event details like the title, user, and action.\n- **Concrete Strategies**:\n    - **IssueCommentStrategy**: Extracts information from GitHub `IssueCommentEvent`.\n    - **IssueStrategy**: Handles details from `IssuesEvent`.\n    - **PullRequestStrategy**: Processes `PullRequestEvent` data.\n    - **PullRequestReviewStrategy**: Extracts information from `PullRequestReviewEvent`.\n    - **PushStrategy**: Handles `PushEvent` data.\n  \n### Strategy Design Pattern\nThe diagram below illustrates how the Strategy Design Pattern is implemented in this application:\n\n![Strategy Pattern Diagram](./img/strategy_pattern_diagram.png)\n\n\n## Dependencies\nThe application relies on the following Python libraries, which are listed in the requirements.txt file:\n\n- black - Python code formatter.\n- isort - Python import sorting tool.\n- pytest - Python testing framework.\n- ruff - Python linter.\n- python-dotenv - Manages environment variables from .env.\n- pytest-cov - Test coverage reporting tool for pytest.\n- tabulate - Pretty-print tabular data in Python.\n\n## Configuration\nThe application uses a `.env` file to securely manage configuration variables. You need to include your GitHub API token in this file for the application to access the GitHub API. Here's an example `.env` file:\n\n    GITHUB_TOKEN=\u003cyour-github-token\u003e\n\nReplace `\u003cyour-github-token\u003e` with your actual GitHub token. This token is essential for making authenticated requests to the GitHub API.\n\n\n## Documentation\nThe project structure is as follows:\n\n```\n.\n├── .github/               # GitHub-specific configuration (CI, issue templates, etc.)\n│   └── workflows/\n│       └── cicd.yml       # CICD workflow (e.g., run tests, linting, etc.)\n├── img/                   # Images for documentation \n├── src/                   # Application code\n│   ├── api.py             # Logic for interacting with the GitHub API\n│   ├── config.py          # Configuration settings\n│   ├── custom_errors.py   # Custom error classes\n│   ├── event_strategy.py  # Strategy classes for GitHub event extraction\n│   ├── main.py            # Main entry point of the application\n│   ├── operations.py      # Utility functions for event data processing\n├── tests/                 # Unit and integration tests\n├── README.md              # Project documentation\n├── requirements.txt       # Python dependencies\n└── run.sh                 # Shell script for setup and execution\n```\n\n## Example\n\nTo extend the application with a new type of GitHub activity, follow these steps:\n\n1. Create a new strategy class in `event_strategy.py` that implements the behavior for the new event.\n2. Update the event dispatcher in `main.py` to handle the new event type.\n\nFor example, you might add a `CreationStrategy` to track repository, branch, and tag creation events and register it within the system without modifying the core logic.\n\n## Troubleshooting\n\n- Virtual environment issues: If the virtual environment isn't activating, ensure Python 3.11+ is installed and that the virtual environment has been correctly set up by running `./run.sh setup-venv`.\n\n- Environment variables: Ensure that the `.env` file exists and contains the correct `GITHUB_TOKEN`. Without this token, the application cannot access the GitHub API.\n\n## License\nThis project is licensed under the MIT License. See the `LICENSE` file for more details.\n\n## Acknowledgement\nThis application was built following the architecture outlined in [roadmap.sh's GitHub User Activity project](https://roadmap.sh/projects/github-user-activity).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorgan-sell%2Fgithub-user-activity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorgan-sell%2Fgithub-user-activity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorgan-sell%2Fgithub-user-activity/lists"}