Skip to content

Commit

Permalink
Merge pull request #1 from hari0205/ci
Browse files Browse the repository at this point in the history
Added CI Workflow
  • Loading branch information
hari0205 authored Jul 5, 2024
2 parents 16bc2ca + 6b12465 commit 3de369c
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
max-line-length = 88
exclude =
.git,
__pycache__,
.venv,
build,
dist,
Makefile
ignore =
E203,
E266,
E501,
W503
69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Porunga-CI"

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint_build_publish:
runs-on: ubuntu-latest

steps:
- name: "Checkout Code"
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.12

- name: Cache Poetry
id: cache-poetry
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: "Install Poetry"
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $GITHUB_ENV
- name: Cache dependencies
id: cache-dependencies
if: steps.cache-poetry.outputs.cache-hit != 'true'
uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/cache
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}-cache
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry install
- name: Run linting
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry run make lint
- name: Build file
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry run make build
- name: Config poetry for PyPi
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_token }}
- name: Publish
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry run make publish
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# For Linting
.PHONY: lint
lint:
@echo "Running flake8"
@flake8 ./porunga

# Clean pyc and pycache
.PHONY: clean
clean:
@echo "Clean pyc"
find . -type f -name "*.pyc" -delete
find . -type d -name "__pycache__" -exec rm -r {} +

# For building
.PHONY: build
build:
@echo "Building package"
@poetry build

# For publishing
.PHONY: publish
publish:
@echo "Publishing package"
@poetry publish
# Define a help target to show usage
.PHONY: help
help:
@echo "Makefile targets:"
@echo " lint - Run Python linter"
@echo " clean - Clean up build artifacts"
@echo " help - Show this help message"
51 changes: 50 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions porunga/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def suggest_commit_message(diff, x) -> dict | ParseError | Exception:
- [feat] for feature addition
- [ref] for Code refactor
- [docs] for documentation
3. Return your suggestions in XML format, wrapped in a single root element <suggestions>
3. Return your suggestions in XML format, wrapped in a single root element <suggestions>
"""

prompt_message = PromptTemplate.from_template(PROMPT)
Expand All @@ -41,10 +41,10 @@ def suggest_commit_message(diff, x) -> dict | ParseError | Exception:
chain = prompt_message | llm | XMLOutputParser()
op = chain.invoke({"diff": diff, "x": x})
print(type(op))
except OutputParserException as _:
except OutputParserException:
# Custom Error class
return ParseError()
except Exception as e:
except Exception:
return Exception
else:
return op
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ inquirerpy = "^0.3.4"
keyring = "^25.2.1"
tenacity = "^8.4.2"
keyrings-alt = "^5.0.1"
flake8 = "^7.1.0"

[tool.poetry.scripts]
porunga = "porunga.cli:cli"
Expand Down

0 comments on commit 3de369c

Please sign in to comment.