From 5eacc0479aa360de23623f94161ac60ad7aa34e7 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Mon, 2 Dec 2024 12:03:37 +0100 Subject: [PATCH 1/3] project: Set fixed ruff version Prevent ruff issues being reported by updates of the tool itself. UP027 has been removed in version 0.8.0, remove it from the ignore list. Signed-off-by: Pieter De Gendt --- .github/workflows/format.yml | 1 + pyproject.toml | 3 --- tox.ini | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 15974344..3598b072 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -59,6 +59,7 @@ jobs: with: args: "format --check --diff" src: "${{ matrix.files.path }}" + version: 0.8.1 - name: Annotate unformatted file if: ${{ failure() }} diff --git a/pyproject.toml b/pyproject.toml index 10f1dddf..e5c16b0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,9 +57,6 @@ extend-select = [ "UP", # pyupgrade "W", # pycodestyle warnings ] -ignore = [ - "UP027", # deprecated pyupgrade rule -] [tool.ruff.format] quote-style = "preserve" diff --git a/tox.ini b/tox.ini index 4cbe9d35..09c51b30 100644 --- a/tox.ini +++ b/tox.ini @@ -33,7 +33,7 @@ deps = types-PyYAML flake8 mypy - ruff + ruff==0.8.1 setenv = # For instance: ./.tox/py3/tmp/ TOXTEMPDIR={envtmpdir} From cd3753c848dc7a3e6158716a399a4995079d8d74 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Mon, 2 Dec 2024 12:04:57 +0100 Subject: [PATCH 2/3] ci: Change format warning to notice, and succeed the job if step fails Github only has 2 states for the result of a job, either success or error. A warning state would be nice but isn't available. We still add a notice to changed files to suggest contributors to format. Signed-off-by: Pieter De Gendt --- .github/workflows/format.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 3598b072..62cd1194 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -43,8 +43,6 @@ jobs: needs: find-changed-files if: ${{ needs.find-changed-files.outputs.files != '[]' }} runs-on: ubuntu-latest - # Allow the workflow run to pass when this job fails - continue-on-error: true strategy: fail-fast: false matrix: @@ -55,13 +53,17 @@ jobs: - uses: actions/checkout@v4 - name: Run ruff format check for ${{ matrix.files.path }} + id: format-check uses: astral-sh/ruff-action@v1 + # Allow the job run to pass when this step fails + continue-on-error: true with: args: "format --check --diff" src: "${{ matrix.files.path }}" version: 0.8.1 - name: Annotate unformatted file - if: ${{ failure() }} + if: ${{ steps.format-check.outcome }} == 'failure' run: | - echo "::warning file=${{ matrix.files.path }},title=File format check failed::Run 'ruff format ${{ matrix.files.path }}'" + JOB_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + echo "::notice file=${{ matrix.files.path }},title=Unformatted file::Consider running 'ruff format ${{ matrix.files.path }}'%0ASee $JOB_URL for more details" From 11971c04c5e48d23bd762574e53b8393001cb244 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Mon, 2 Dec 2024 12:13:37 +0100 Subject: [PATCH 3/3] TEST: Touch an unformatted file Signed-off-by: Pieter De Gendt --- src/west/app/main.py | 1 + src/west/app/project.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/west/app/main.py b/src/west/app/main.py index bd4b6090..8d2f4822 100755 --- a/src/west/app/main.py +++ b/src/west/app/main.py @@ -1226,4 +1226,5 @@ def main(argv=None): } if __name__ == "__main__": + # Test touching a python file main() diff --git a/src/west/app/project.py b/src/west/app/project.py index d5f4c705..374a1070 100644 --- a/src/west/app/project.py +++ b/src/west/app/project.py @@ -2192,6 +2192,7 @@ def __format__(self, format_spec): # # Logging helpers +# Touch here #