Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removed coverage.json file, updated version and coverage badge to work #60

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Chezka109
Copy link
Collaborator

@Chezka109 Chezka109 commented Nov 21, 2024

Pull Request

Contributors:
@Chezka109

Issue Addressed:
This pull request addresses and resolves Issue #51.

Labels:
Infrastructure

Goal of This Pull Request:
This PR introduces updates and fixes to the badge system. The coverage badge is updated to now need a .json file anymore, the version badge is now correct.

Testing:
Operating Systems Tested On: MacOS

Screenshots:
build.yml
Screenshot 2024-11-21 at 3 32 54 PM
This runs the commands in GitHub actions to update the badges automatically using the workflow.

pytest --cov=. --cov-report=term
Screenshot 2024-11-21 at 3 34 17 PM

Will run coverage and will collect data depending on the TOTAL percentage.

python scripts/badges.py
When this command is run, either manually or through the CI/CD pipeline, it will output either an ERROR or SUCCESS message for both the coverage and version badges.
Screenshot 2024-11-21 at 3 35 16 PM
Codeblock for outputs (through regex):

        match = re.search(r"TOTAL\s+\d+\s+\d+\s+(\d+)%", result.stdout)
        if match:
            return float(match.group(1))
        else:
            print(
                "[ERROR] Could not extract coverage percentage from pytest output."
            )
            return None
    except subprocess.CalledProcessError as e:
        print(f"[ERROR] pytest failed: {e.stderr}")
        return None


def get_version():
    """Fetch version from pyproject.toml."""
    if not os.path.exists(PYPROJECT_FILE):
        print(f"[ERROR] {PYPROJECT_FILE} not found.")
        return None
    try:
        with open(PYPROJECT_FILE) as f:
            pyproject_data = toml.load(f)
            return pyproject_data["tool"]["poetry"]["version"]
    except (KeyError, toml.TomlDecodeError) as e:
        print(f"[ERROR] Invalid format in {PYPROJECT_FILE}: {e}")
        return None

@Chezka109
Copy link
Collaborator Author

@gkapfham, I've fixed the coverage in the build.yml file, but I keep getting this error and that's the reason the build is failing:

Run git config --global user.name "github-actions"
[detached HEAD 5b0470a] Update badges in README.md
 1 file changed, 2 insertions(+), 2 deletions(-)
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
  5b0470a Update badges in README.md
Switched to a new branch 'main'
branch 'main' set up to track 'origin/main'.
remote: Permission to GatorEducator/execexam.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/GatorEducator/execexam/': The requested URL returned error: 403
Error: Process completed with exit code 128.

Correct me if I'm wrong, but would the build pass if the PR was merged? The only reason it's not passing is because it doesn't have access to the repository to commit README.md.

@Chezka109 Chezka109 added question Further information is requested infrastructure CI/CD configuration labels Nov 21, 2024
@boulais01
Copy link
Collaborator

Hi @Chezka109 there exists some documentation of this error online with recommended fixes. I recommend trying those; it is not something that would be fixed by force merging, to my knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure CI/CD configuration question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants