From f7cc63c6f31d02edeebf579762638bbc66e486a3 Mon Sep 17 00:00:00 2001 From: Isaac Cheng <47993930+IsaacCheng9@users.noreply.github.com> Date: Sun, 4 Feb 2024 02:43:33 +0000 Subject: [PATCH 1/4] Add CI for formatting and testing --- .github/workflows/format.yml | 31 +++++++++++++++++++++++++ .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/format.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..5534ce0 --- /dev/null +++ b/.github/workflows/format.yml @@ -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: ". --exclude src/trading_portfolio_tracker/ui" + + - 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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5753a78 --- /dev/null +++ b/.github/workflows/test.yml @@ -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/trading_portfolio_tracker -m pytest -v + + - name: Get code coverage report + run: poetry run coverage report -m From 64382715584d85d60727e806d0abdf03fa51e059 Mon Sep 17 00:00:00 2001 From: IsaacCheng9 Date: Sun, 4 Feb 2024 02:43:55 +0000 Subject: [PATCH 2/4] Format Python code with Black --- src/boruvkas_algorithm/boruvka.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/boruvkas_algorithm/boruvka.py b/src/boruvkas_algorithm/boruvka.py index 3f55cf9..febfa57 100644 --- a/src/boruvkas_algorithm/boruvka.py +++ b/src/boruvkas_algorithm/boruvka.py @@ -1,6 +1,7 @@ """ Implement Boruvka's algorithm for finding the minimum spanning tree of a graph. """ + from typing import Dict, List, Optional, Tuple From a1e4ee11701bfa3c3ca93ee45a1eed4a6aba21d1 Mon Sep 17 00:00:00 2001 From: Isaac Cheng <47993930+IsaacCheng9@users.noreply.github.com> Date: Sun, 4 Feb 2024 02:45:55 +0000 Subject: [PATCH 3/4] Fix refs to project directory --- .github/workflows/format.yml | 2 -- .github/workflows/test.yml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5534ce0..f3321dd 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -14,8 +14,6 @@ jobs: - name: Run Python code formatting with Black uses: lgeiger/black-action@v1.0.1 - with: - args: ". --exclude src/trading_portfolio_tracker/ui" - name: Commit changes made by Black uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5753a78..e0acf31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: poetry install - name: Run unit tests with Pytest - run: poetry run coverage run --source=src/trading_portfolio_tracker -m pytest -v + run: poetry run coverage run --source=src/boruvkas_algorithm -m pytest -v - name: Get code coverage report run: poetry run coverage report -m From dcd300f29678be92f1f751b7ddfa79ce2ac82e12 Mon Sep 17 00:00:00 2001 From: Isaac Cheng <47993930+IsaacCheng9@users.noreply.github.com> Date: Sun, 4 Feb 2024 02:47:20 +0000 Subject: [PATCH 4/4] Add arg for Black, add CI badge to README --- .github/workflows/format.yml | 2 ++ README.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index f3321dd..7026ce1 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -14,6 +14,8 @@ jobs: - 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 diff --git a/README.md b/README.md index 909acd3..a75fa60 100644 --- a/README.md +++ b/README.md @@ -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)