Skip to content

Commit

Permalink
ci: 自动格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
XYCode-Kerman committed May 4, 2024
1 parent dd2413e commit 35c5389
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/autoformat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: AutoFormat
on: [push, pull_request]

jobs:
autotest:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v3

- name: Set up Python version
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install poetry
uses: abatilo/actions-poetry@v2

- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}

- name: Install the project dependencies
run: poetry install

- name: Auto format
run: bash autoformat.sh

- name: Run flake8
run: poetry run flake8 .

- name: Run mypy
run: poetry run mypy .

- uses: actions-go/push@master
with:
commit-message: 'style: 自动格式化代码'
remote: origin
4 changes: 3 additions & 1 deletion autoformat.sh
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
autoflake -i --remove-unused-variables --remove-duplicate-keys --remove-all-unused-imports --ignore-init-module-imports --remove-rhs-for-unused-variables **/*.py
poetry run autopep8 -i **/*.py
poetry run autoflake -i --remove-unused-variables --remove-duplicate-keys --remove-all-unused-imports --ignore-init-module-imports --remove-rhs-for-unused-variables **/*.py
poetry run isort .
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
dotenv.load_dotenv()




def telemetering():
if TELEMETERING:
requests.post('http://itte.api.xycode.club/', json={
Expand Down
21 changes: 20 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ types-psutil = "^5.9.5.20240423"
types-requests = "^2.31.0.20240406"
flake8 = "^7.0.0"
autopep8 = "^2.1.0"
isort = "^5.13.2"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit 35c5389

Please sign in to comment.