From 91ff46bb98e07a0acb3ba92ac9381a5ccd39076d Mon Sep 17 00:00:00 2001 From: Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> Date: Wed, 4 Sep 2024 00:50:48 +0530 Subject: T0000: check --- .github/workflows/darker-lint.yml | 19 ++++++++++++++----- src/tests/test.py | 7 +++++++ 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/tests/test.py diff --git a/.github/workflows/darker-lint.yml b/.github/workflows/darker-lint.yml index f13d683..ec7d12a 100644 --- a/.github/workflows/darker-lint.yml +++ b/.github/workflows/darker-lint.yml @@ -11,7 +11,7 @@ permissions: contents: read jobs: - darker-lint: + darker-ruff-lint: runs-on: ubuntu-latest permissions: pull-requests: write @@ -22,7 +22,7 @@ jobs: with: repository: vyos/.github path: reusable-actions - ref: feature/ruff-toml + ref: current - name: Checkout head uses: actions/checkout@v4 @@ -31,16 +31,25 @@ jobs: fetch-tags: true ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} + path: repo - name: Fetch base run: | + cd repo git fetch https://github.com/${{ github.event.pull_request.base.repo.full_name }} ${{ github.event.pull_request.base.ref }}:refs/remotes/origin/base - - name: darker install + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install darker ruff run: | pip install git+https://github.com/akaihola/darker.git@master ruff>=0.0.292 - name: Analyze Code run: | - ls -ltr - darker -r origin/base --check --diff --lint "ruff check --config ./reusable-actions/.github/ruff.toml" --color . \ No newline at end of file + cd repo + cp origin/base/ruff.toml . + cat ruff.toml + darker -r origin/base --check --diff --lint "ruff check" --color . \ No newline at end of file diff --git a/src/tests/test.py b/src/tests/test.py new file mode 100644 index 0000000..46803bd --- /dev/null +++ b/src/tests/test.py @@ -0,0 +1,7 @@ +from typing import List + +import os + +def sum_even_numbers(numbers: List[int]) -> int: + """Given a list of integers, return the sum of all even numbers in the list.""" + return sum(num for num in numbers if num % 2 == 0) \ No newline at end of file -- cgit v1.2.3 From 51a4c848158aa952a220ff8fb5f1d5e5ce06b45f Mon Sep 17 00:00:00 2001 From: Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> Date: Wed, 4 Sep 2024 01:12:07 +0530 Subject: T0000: check --- .github/workflows/darker-lint.yml | 2 +- ruff.toml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ruff.toml diff --git a/.github/workflows/darker-lint.yml b/.github/workflows/darker-lint.yml index ec7d12a..deeabd4 100644 --- a/.github/workflows/darker-lint.yml +++ b/.github/workflows/darker-lint.yml @@ -50,6 +50,6 @@ jobs: - name: Analyze Code run: | cd repo - cp origin/base/ruff.toml . + git checkout origin/base -- ruff.toml cat ruff.toml darker -r origin/base --check --diff --lint "ruff check" --color . \ No newline at end of file diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..2aaac4a --- /dev/null +++ b/ruff.toml @@ -0,0 +1,18 @@ +# Same as Black. +line-length = 100 +indent-width = 4 + +# Assume Python 3.11 +target-version = "py311" + +[format] +quote-style = "single" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" \ No newline at end of file -- cgit v1.2.3 From 2db4d12aae588aeb03c9c6ece5b0cd7e5fb71a7c Mon Sep 17 00:00:00 2001 From: Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:05:55 +0530 Subject: T0000: Update --- src/tests/test.py | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/tests/test.py diff --git a/src/tests/test.py b/src/tests/test.py deleted file mode 100644 index 46803bd..0000000 --- a/src/tests/test.py +++ /dev/null @@ -1,7 +0,0 @@ -from typing import List - -import os - -def sum_even_numbers(numbers: List[int]) -> int: - """Given a list of integers, return the sum of all even numbers in the list.""" - return sum(num for num in numbers if num % 2 == 0) \ No newline at end of file -- cgit v1.2.3 From 0fb05bbf0ffc9c341f56ab5e3ee1421e3044a4ac Mon Sep 17 00:00:00 2001 From: Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:11:49 +0530 Subject: T0000: Update --- .github/workflows/darker-lint.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/darker-lint.yml b/.github/workflows/darker-lint.yml index deeabd4..746c09b 100644 --- a/.github/workflows/darker-lint.yml +++ b/.github/workflows/darker-lint.yml @@ -50,6 +50,10 @@ jobs: - name: Analyze Code run: | cd repo - git checkout origin/base -- ruff.toml - cat ruff.toml + if git ls-tree -r origin/base --name-only | grep -q '^ruff.toml$'; then + git checkout origin/base -- ruff.toml + echo "Using ruff.toml from base repo" + else + echo "No ruff.toml found in base repo" + fi darker -r origin/base --check --diff --lint "ruff check" --color . \ No newline at end of file -- cgit v1.2.3 From 7c14873dad7e6662ee4428fec3738c03a8be7d59 Mon Sep 17 00:00:00 2001 From: Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:12:26 +0530 Subject: T0000: Update --- .github/workflows/darker-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/darker-lint.yml b/.github/workflows/darker-lint.yml index 746c09b..aea4666 100644 --- a/.github/workflows/darker-lint.yml +++ b/.github/workflows/darker-lint.yml @@ -53,6 +53,7 @@ jobs: if git ls-tree -r origin/base --name-only | grep -q '^ruff.toml$'; then git checkout origin/base -- ruff.toml echo "Using ruff.toml from base repo" + cat ruff.toml else echo "No ruff.toml found in base repo" fi -- cgit v1.2.3