Skip to content

Commit

Permalink
Merge pull request #169 from GatorEducator/feat/add-status-border
Browse files Browse the repository at this point in the history
feat/add status border
  • Loading branch information
gkapfham authored Jan 22, 2025
2 parents 192f923 + 321f1a4 commit 5e2814c
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 273 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Python 3.7
- name: Setup Python 3.12
uses: actions/setup-python@v2
id: setup-python
with:
python-version: 3.7
python-version: 3.12
- name: Install Poetry
uses: Gr1N/setup-poetry@v8
with:
Expand Down Expand Up @@ -68,12 +68,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.10"]
python-version: ["3.12", "3.10"]
include:
- os: macos-latest
python-version: "3.9"
- os: windows-latest
python-version: "3.8"
python-version: "3.11"
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
Expand Down
35 changes: 7 additions & 28 deletions gatorgrade/output/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import gator
import rich
from rich.panel import Panel

from gatorgrade.input.checks import GatorGraderCheck
from gatorgrade.input.checks import ShellCheck
Expand Down Expand Up @@ -365,37 +366,15 @@ def run_checks(
if all(report):
report_output_data = create_report_json(passed_count, results, percent)
configure_report(report, report_output_data)
# compute summary results and display them in the console
# compute summary results and display them in the console using the Panel
# provided by Rich; this enables a border that resizes with the terminal;
# note that there is one blank line between the prior output and the Panel
summary = f"Passed {passed_count}/{len(results)} ({percent}%) of checks for {Path.cwd().name}!"
summary_color = "green" if passed_count == len(results) else "bright white"
print_with_border(summary, summary_color)
summary_color = "green" if passed_count == len(results) else "bright_red"
rich.print("")
rich.print(Panel(summary, expand=False, title=None, style=summary_color))
# determine whether or not the run was a success or not:
# if all of the tests pass then the function returns True;
# otherwise the function must return False
summary_status = True if passed_count == len(results) else False
return summary_status


def print_with_border(text: str, rich_color: str):
"""Print text with a border.
Args:
text: Text to print
rich_color: Color of text to print
"""
upleft = "\u250f"
# Upper left corner
upright = "\u2513"
# Upper right corner
downleft = "\u2517"
# Lower left corner
downright = "\u251b"
# Lower right corner
vert = "\u2503"
# Vertical line
horz = "\u2501"
# Horizontal line
line = horz * (len(text) + 2)
rich.print(f"[{rich_color}]\n\t{upleft}{line}{upright}")
rich.print(f"[{rich_color}]\t{vert} {text} {vert}")
rich.print(f"[{rich_color}]\t{downleft}{line}{downright}\n")
Loading

0 comments on commit 5e2814c

Please sign in to comment.