From 441e1b13208929b3bbd14f74a642bc54f250a852 Mon Sep 17 00:00:00 2001 From: Vijayakumar A <36878324+kumvijaya@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:38:09 +0530 Subject: T1111: update for ruff --- .github/workflows/darker-lint.yml | 60 --------------------------------------- .github/workflows/ruff-lint-2.yml | 56 ++++++++++++++++++++++++++++++++++++ .github/workflows/ruff-lint.yml | 2 +- 3 files changed, 57 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/darker-lint.yml create mode 100644 .github/workflows/ruff-lint-2.yml diff --git a/.github/workflows/darker-lint.yml b/.github/workflows/darker-lint.yml deleted file mode 100644 index aea4666..0000000 --- a/.github/workflows/darker-lint.yml +++ /dev/null @@ -1,60 +0,0 @@ ---- -name: Darker-Ruff Lint - -on: - pull_request: - branches: - - current - -permissions: - pull-requests: write - contents: read - -jobs: - darker-ruff-lint: - 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: Install darker ruff - run: | - pip install git+https://github.com/akaihola/darker.git@master ruff>=0.0.292 - - - name: Analyze Code - run: | - cd repo - 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 - darker -r origin/base --check --diff --lint "ruff check" --color . \ No newline at end of file diff --git a/.github/workflows/ruff-lint-2.yml b/.github/workflows/ruff-lint-2.yml new file mode 100644 index 0000000..1c5d54e --- /dev/null +++ b/.github/workflows/ruff-lint-2.yml @@ -0,0 +1,56 @@ +--- +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 559853c..4a87521 100644 --- a/.github/workflows/ruff-lint.yml +++ b/.github/workflows/ruff-lint.yml @@ -1,7 +1,7 @@ --- name: Ruff Lint -on: [push, pull_request] +on: pull_request jobs: ruff-lint: -- cgit v1.2.3