Skip to content

Commit

Permalink
feat: Added refactoring process
Browse files Browse the repository at this point in the history
  • Loading branch information
gokborayilmaz committed Aug 16, 2024
1 parent 3195f28 commit 00b451b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/refactor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Manual Refactor

on:
workflow_dispatch:

jobs:
run-refactor:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

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

- name: setup git config
run: |
# setup the username and email. I tend to use 'GitHub Actions Bot' with no email by default
git config user.name "Upsonic Refactor Bot"
git config user.email "<[email protected]>"
- name: Run Refactor Script
run: |
python refactor.py
6 changes: 3 additions & 3 deletions bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def read_version():
with open('upsonic/__init__.py', 'r') as file:
for line in file:
match = re.search(r"__version__ = '(.*)'", line)
match = re.search(r"__version__ = '(.*)'", line) # fmt: skip
if match:
return match.group(1)

Expand All @@ -25,7 +25,7 @@ def increment_version(part, version):
def write_version(version):
with open('upsonic/__init__.py', 'r+') as file:
content = file.read()
content = re.sub(r"__version__ = '.*'", f"__version__ = '{version}'", content)
content = re.sub(r"__version__ = '.*'", f"__version__ = '{version}'", content) # fmt: skip
file.seek(0)
file.write(content)

Expand All @@ -34,7 +34,7 @@ def update_version(version):
for file in files:
with open(file, 'r+') as f:
content = f.read()
content = re.sub(r' version=".*"', f' version="{version}"', content)
content = re.sub(r' version=".*"', f' version="{version}"', content) # fmt: skip
f.seek(0)
f.write(content)

Expand Down
26 changes: 26 additions & 0 deletions refactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os


def install_refactor_tool():
os.system("pip install ruff==0.6.0")


def refactor():
os.system("ruff check --fix")
os.system("ruff format")


def create_commit():
os.system("git add .")
os.system("git commit -m 'refactor: Scheduled refactoring'")


def push():
os.system("git push")


if __name__ == "__main__":
install_refactor_tool()
refactor()
create_commit()
push()
2 changes: 1 addition & 1 deletion upsonic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

open_databases = {}

__version__ = '0.28.4'
__version__ = '0.28.4' # fmt: skip



Expand Down

0 comments on commit 00b451b

Please sign in to comment.