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

Add CI pipelines for testing and formatting #4

Merged
merged 5 commits into from
Feb 4, 2024
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
31 changes: 31 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Format

on: [push]

jobs:
format:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.12.x]

steps:
- uses: actions/checkout@v3

- name: Run Python code formatting with Black
uses: lgeiger/black-action@v1.0.1
with:
args: "."

- name: Commit changes made by Black
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Format Python code with Black

- name: Switch to current branch
run: git checkout ${{ env.BRANCH }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3.1.4
with:
python-version: ${{ matrix.python-version }}
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test

# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the main branch.
push:
# Allows you to run this workflow manually from the Actions tab.
workflow_dispatch:

jobs:
test:
# The type of runner that the job will run on.
runs-on: macos-latest
# Configures the build to use the latest version of Python 3.
strategy:
matrix:
python-version: [3.12.x]

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can
# access it.
- uses: actions/checkout@v3

- name: Switch to current branch
run: git checkout ${{ env.BRANCH }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry

- name: Install Python dependencies with Poetry
run: |
poetry install

- name: Run unit tests with Pytest
run: poetry run coverage run --source=src/boruvkas_algorithm -m pytest -v

- name: Get code coverage report
run: poetry run coverage report -m
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Boruvka's Algorithm

[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Test](https://github.com/IsaacCheng9/boruvkas-algorithm/actions/workflows/test.yml/badge.svg)](https://github.com/IsaacCheng9/boruvkas-algorithm/actions/workflows/test.yml)

An implementation of Boruvka's algorithm to find a minimum spanning tree in a graph.

[Link to narrated video demonstration on YouTube.](https://www.youtube.com/watch?v=n5LNVobuBNU)
Expand Down
1 change: 1 addition & 0 deletions src/boruvkas_algorithm/boruvka.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Implement Boruvka's algorithm for finding the minimum spanning tree of a graph.
"""

from typing import Dict, List, Optional, Tuple


Expand Down
Loading