diff options
author | Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> | 2024-09-12 00:55:44 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 00:55:44 +0530 |
commit | 46c208142a528a8d09600827a07238f6dbc79e37 (patch) | |
tree | 9993e52f0b1e336f9d9d1804d935eeb4717266dd | |
parent | 6482aeb3c474370bdd667fc038ef5f2ccc6353fa (diff) | |
parent | 505fd94fd48b545da18487ce3aa202a92e6835e7 (diff) | |
download | vyos-workflow-test-temp-46c208142a528a8d09600827a07238f6dbc79e37.tar.gz vyos-workflow-test-temp-46c208142a528a8d09600827a07238f6dbc79e37.zip |
Merge pull request #50 from kumvijaya/current
Test 1
-rw-r--r-- | .github/workflows/ruff-lint-2.yml | 56 | ||||
-rw-r--r-- | .github/workflows/ruff-lint.yml | 28 | ||||
-rw-r--r-- | ruff.toml | 2 | ||||
-rw-r--r-- | src/tests/test.py | 7 | ||||
-rw-r--r-- | src/tests/test_utils.py | 1 |
5 files changed, 35 insertions, 59 deletions
diff --git a/.github/workflows/ruff-lint-2.yml b/.github/workflows/ruff-lint-2.yml deleted file mode 100644 index 1c5d54e..0000000 --- a/.github/workflows/ruff-lint-2.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -name: Ruff Lint 2 - -on: - pull_request: - branches: - - current - -permissions: - pull-requests: write - contents: read - -jobs: - ruff-lint-2: - runs-on: ubuntu-latest - permissions: - pull-requests: write - contents: read - steps: - - name: Checkout reusable actions repo - uses: actions/checkout@v3 - with: - repository: vyos/.github - path: reusable-actions - ref: current - - - name: Checkout head - uses: actions/checkout@v4 - with: - fetch-depth: 0 - 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: Setup python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Get changed files - id: changed-files - run: | - cd repo - git diff --name-only origin/base...${{ github.event.pull_request.head.ref }} > changed_files.txt - - - name: Run ruff on changed files - uses: ChartBoost/ruff-action@v1 - with: - files: | - $(cat repo/changed_files.txt)
\ No newline at end of file diff --git a/.github/workflows/ruff-lint.yml b/.github/workflows/ruff-lint.yml index 4a87521..6ba9447 100644 --- a/.github/workflows/ruff-lint.yml +++ b/.github/workflows/ruff-lint.yml @@ -6,10 +6,34 @@ on: pull_request jobs: ruff-lint: runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read steps: - - uses: actions/checkout@v4 + - name: Checkout Head + uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: chartboost/ruff-action@491342200cdd1cf4d5132a30ddc546b3b5bc531b + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + + - name: Get changed py files + id: changed-py-files + uses: tj-actions/changed-files@v44 + with: + files: | + **.py + + - name: Ruff Check + if: steps.changed-py-files.outputs.any_changed == 'true' + uses: chartboost/ruff-action@491342200cdd1cf4d5132a30ddc546b3b5bc531b with: + args: check changed-files: 'true' + + - name: Ruff Format + if: always() && steps.changed-py-files.outputs.any_changed == 'true' + uses: chartboost/ruff-action@491342200cdd1cf4d5132a30ddc546b3b5bc531b + with: + args: format --diff + changed-files: 'true'
\ No newline at end of file @@ -1,4 +1,4 @@ -line-length = 100 # defaults to 88 like black
+line-length = 80 # defaults to 88 like black
target-version = "py39" # the python version to target, useful when considering code upgrades, defaults to "py310"
select = [
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 diff --git a/src/tests/test_utils.py b/src/tests/test_utils.py index b7b7f22..8ae63ae 100644 --- a/src/tests/test_utils.py +++ b/src/tests/test_utils.py @@ -15,6 +15,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. from unittest import TestCase +import os class TestVyOSUtils(TestCase): def test_key_mangling(self): from vyos.utils.dict import mangle_dict_keys |