From a46e0cb9d0b64114a98086fdc08f0237e7e01b60 Mon Sep 17 00:00:00 2001 From: Shan Mu Date: Tue, 9 Dec 2025 11:55:37 +0800 Subject: [PATCH] Enhance static check workflow with file existence checks Added checks for requirements.txt and pyproject.toml existence before installing dependencies and analyzing code. --- .github/workflows/static-check.yml | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static-check.yml b/.github/workflows/static-check.yml index 0cfef51..e1530b5 100644 --- a/.github/workflows/static-check.yml +++ b/.github/workflows/static-check.yml @@ -15,12 +15,42 @@ jobs: uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Check requirements.txt exists + id: check_req + run: | + if [ -f requirements.txt ]; then + echo "requirements_exists=true" >> $GITHUB_OUTPUT + else + echo "requirements_exists=false" >> $GITHUB_OUTPUT + fi + if [ -f pyproject.toml ]; then + echo "pyproject_exists=true" >> $GITHUB_OUTPUT + else + echo "pyproject_exists=false" >> $GITHUB_OUTPUT + fi + - name: Install dependencies by requirements.txt + id: install_deps_req + if: ${{ steps.check_req.outputs.requirements_exists == 'true' }} run: | python -m pip install --upgrade pylint python -m pip install --upgrade isort python -m pip install -r requirements.txt + echo "dependencies_installed=true" >> $GITHUB_OUTPUT - name: Analysing the code with pylint + if: ${{ steps.check_req.outputs.requirements_exists == 'true' }} run: | isort $(git ls-files '*.py') --check-only --diff pylint $(git ls-files '*.py') + - name: Install dependencies by uv + id: install_deps_uv + if: ${{ steps.check_req.outputs.pyproject_exists == 'true' }} + run: | + python -m pip install uv + uv sync + uv pip install pylint + uv pip install isort + - name: Analysing the code with pylint + if: ${{ steps.check_req.outputs.pyproject_exists == 'true' }} + run: | + uv run isort $(git ls-files '*.py') --check-only --diff + uv run pylint $(git ls-files '*.py')