From 07723979552b2e5768ba6f0831490dd3d8969a59 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sun, 3 Mar 2024 23:48:54 +0900 Subject: [PATCH] Add pr check workflow (#8) * rename build image workflow * add check-pr workflow * make linter happy --- .github/workflows/check-pr.yml | 18 ++++++++++++++++++ .github/workflows/deploy-image.yml | 2 +- .ruff.toml | 5 +++++ app/exceptions/__init__.py | 1 + app/models/language.py | 14 +++++++------- app/tasks/output_project.py | 1 + 6 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/check-pr.yml diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml new file mode 100644 index 0000000..56c326d --- /dev/null +++ b/.github/workflows/check-pr.yml @@ -0,0 +1,18 @@ +name: PR checks + +on: + pull_request: + workflow_dispatch: + +jobs: + check-pr: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + - run: pip install -r requirements.txt + - run: ruff . diff --git a/.github/workflows/deploy-image.yml b/.github/workflows/deploy-image.yml index 3487aea..5cf0b40 100644 --- a/.github/workflows/deploy-image.yml +++ b/.github/workflows/deploy-image.yml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: Build Docker image on: workflow_dispatch: diff --git a/.ruff.toml b/.ruff.toml index b315d5d..bd3602d 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -2,3 +2,8 @@ target-version = "py310" line-length = 88 indent-width = 4 + +lint.external = ['F403'] +extend-exclude = [ + "./tests" +] diff --git a/app/exceptions/__init__.py b/app/exceptions/__init__.py index bbf2424..afec738 100644 --- a/app/exceptions/__init__.py +++ b/app/exceptions/__init__.py @@ -1,3 +1,4 @@ +# ruff: noqa: F403 """ 所有API异常定义在此 """ diff --git a/app/models/language.py b/app/models/language.py index 642d9ac..7af4a79 100644 --- a/app/models/language.py +++ b/app/models/language.py @@ -780,14 +780,14 @@ def init_system_languages(cls) -> None: logger.info("已存在语言表,跳过初始化") return sort = 0 - for l in cls.SYSTEM_LANGUAGES_DATA: + for lang in cls.SYSTEM_LANGUAGES_DATA: cls( - en_name=l["en_name"], - lo_name=l["lo_name"], - no_space=l.get("no_space", False), - code=l["code"], - g_tra_code=l["g_tra_code"], - g_ocr_code=l["g_ocr_code"], + en_name=lang["en_name"], + lo_name=lang["lo_name"], + no_space=lang.get("no_space", False), + code=lang["code"], + g_tra_code=lang["g_tra_code"], + g_ocr_code=lang["g_ocr_code"], sort=sort, ).save() sort += 1 diff --git a/app/tasks/output_project.py b/app/tasks/output_project.py index bd1c6cc..e9ccd1c 100644 --- a/app/tasks/output_project.py +++ b/app/tasks/output_project.py @@ -1,3 +1,4 @@ +# ruff: noqa: F841 """ 导出项目 """