From 658801f16dbb5d455cfb48225e89c4ecef424383 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Mon, 12 May 2025 12:11:37 -0500 Subject: [PATCH 1/4] feat: Add setup-gh.sh script **Description**: Adds the script setup-gh.sh which can be run to set up environment variables **Related Issue(s)**: Closes #86 Signed-off-by: Roger Barker --- README.md | 40 +++++++++++++++++++++++++++------------- src/setup-gh.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 src/setup-gh.sh diff --git a/README.md b/README.md index e5ffc81..4d1c94e 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,53 @@ ![App icon](images/FullSizeIcon.png) # VersionTwo + Hackathon project: CLI tool to generate static planning view of issues for better team planning -# ๐Ÿš€ Getting Started -## ๐Ÿ“ฆ Requirements +## ๐Ÿš€ Getting Started + +### ๐Ÿ“ฆ Requirements + The following dependencies are required to run the program: + - Python 3.x - `brew install python3` - Python `pyenv` and `pyenv-virtualenv` - - `brew install pyenv pyenv-virtualenv` + - `brew install pyenv pyenv-virtualenv` - GitHub Command Line Interface (CLI) `gh` - `brew install gh` -## ๐Ÿ’ป Setup +### ๐Ÿ’ป Setup + - Authentication through `gh auth login` -- Set the appropriate token permissions: `gh auth refresh --scopes read:project` - - Note: The team must have `read` permissions on the Project Board in order to view the issues on the board. -- Set the `GITHUB_TOKEN` environment variable: `export GITHUB_TOKEN=$(gh auth token)` -- Set the `GITHUB_UNAME` environment variable: `export GITHUB_UNAME=$(gh auth status | grep "(GITHUB_TOKEN)" | cut -d " " -f9)` +- Source the [setup-gh.sh](src/setup-gh.sh) script to configure your gh environment variables + + ```bash + source src/setup-gh.sh # follow the prompts + ``` + + - Sets the appropriate token scopes: `read`. + - Note: The team must have `read` permissions on the Project Board in order to view the issues on the board. + - Sets the `GITHUB_TOKEN` environment variable. + - Sets the `GITHUB_UNAME` environment variable. - Run `make install` inside the repo directory to configure the appropriate versions of dependencies. -## ๐Ÿ›  Usage +### ๐Ÿ›  Usage + To run the main script, change to the current directory of the script, then run: `python version2.py --output-file "" --temp-dir "" --include-project ` See the `--help` menu for full list of filter functionality. -# Background +## Background + GitHub users have issues assigned to themselves or a team they are a member of. These issues can be viewed on a Project board, which captures the issues in swim lanes. The Project board can only automate with a single organization, meaning users who work in more than one org do not have a single location to view all issues. This leads to fragmented planning and execution. -# How does it work? +## How does it work? ```mermaid %% A ยท System-Architecture Diagram (โ‰ค25 nodes) @@ -52,7 +65,8 @@ classDef api fill:#e3f2fd,stroke:#2196f3; classDef cli fill:#f1f8e9,stroke:#7cb342; ``` -# Our Solution +## Our Solution + Our python script will query the GitHub API for all issues associated with the appropriate filters provided to the CLI tool. The output will be a static HTML page showing all issues in swim lanes. This provides a comprehensive overview -of all issues the team or user has assigned. +of all issues the team or user has assigned. diff --git a/src/setup-gh.sh b/src/setup-gh.sh new file mode 100644 index 0000000..02b9608 --- /dev/null +++ b/src/setup-gh.sh @@ -0,0 +1,44 @@ +#! /usr/bin/env bash + +# This script sets up the authentication parameters for the GitHub CLI +# that are needed to run the version2.py script. +# It is assumed that the GitHub CLI is already installed and configured +# on the system. +# The script will update the user's github token to have the needed scopes, +# set the token in the environment and pull in the gh users username as +# another environment variable. + +# Exit if not sourced +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + echo "ERROR: This script must be sourced, not executed." + echo "Usage: source ${BASH_SOURCE[0]}" + exit 1 +fi + +# Check if the GITHUB_TOKEN environment variable is already set +set_gh_token() { + # If not set, set the scopes for the token and set the enviornment variable + gh auth refresh --scopes read:project + + # Set the GITHUB_TOKEN environment variable + export GITHUB_TOKEN=$(gh auth token) +} + + +configure_gh_env() { + if [ -n "${GITHUB_TOKEN}" ]; then + echo "GITHUB_TOKEN needs to be unset to update the token scopes." + unset GITHUB_TOKEN + fi + + # set the gh_token + set_gh_token + + # set the gh_user + export GITHUB_UNAME=$(gh api user --jq .login) + + echo "GITHUB_TOKEN is set. Length is: ${#GITHUB_TOKEN}" + echo "GITHUB_UNAME is set to: ${GITHUB_UNAME}" +} + +configure_gh_env From bff557c753578671274383ac9350463ad6c91df8 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Mon, 12 May 2025 12:23:10 -0500 Subject: [PATCH 2/4] Update based on copilot suggestion Signed-off-by: Roger Barker --- src/setup-gh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup-gh.sh b/src/setup-gh.sh index 02b9608..c3158a5 100644 --- a/src/setup-gh.sh +++ b/src/setup-gh.sh @@ -17,7 +17,7 @@ fi # Check if the GITHUB_TOKEN environment variable is already set set_gh_token() { - # If not set, set the scopes for the token and set the enviornment variable + # If not set, set the scopes for the token and set the environment variable gh auth refresh --scopes read:project # Set the GITHUB_TOKEN environment variable From cdd745dd8c13a6c321e8e889833a51373b608e33 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Mon, 12 May 2025 12:52:29 -0500 Subject: [PATCH 3/4] Update README.md Signed-off-by: Roger Barker --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d1c94e..8988691 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The following dependencies are required to run the program: source src/setup-gh.sh # follow the prompts ``` - - Sets the appropriate token scopes: `read`. + - Sets the appropriate token scopes: `read: project`. - Note: The team must have `read` permissions on the Project Board in order to view the issues on the board. - Sets the `GITHUB_TOKEN` environment variable. - Sets the `GITHUB_UNAME` environment variable. From 655a00b8be076c70be49ddc4cdec2bb6aafff96a Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Mon, 12 May 2025 12:56:53 -0500 Subject: [PATCH 4/4] Update src/setup-gh.sh Co-authored-by: Andrew Brandt Signed-off-by: Roger Barker --- src/setup-gh.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/setup-gh.sh b/src/setup-gh.sh index c3158a5..05799d3 100644 --- a/src/setup-gh.sh +++ b/src/setup-gh.sh @@ -24,7 +24,6 @@ set_gh_token() { export GITHUB_TOKEN=$(gh auth token) } - configure_gh_env() { if [ -n "${GITHUB_TOKEN}" ]; then echo "GITHUB_TOKEN needs to be unset to update the token scopes."