ChartBoost / ruff-action

A GitHub Action for Ruff
Apache License 2.0
121 stars 21 forks source link

Pulling ruff version from requirements.txt file #5

Closed alichaudry closed 5 months ago

alichaudry commented 1 year ago

Hello, is there a way to pull the ruff version to be used from a specific requirements.txt (or pyproject.toml) file? Currently I have to hardcode the ruff version in two locations to get this to work, but it would be nice to keep the ruff-action version in sync with what's being used in the Python develop/build manifest.

Or if there are other workflows to solve for this problem that I may not have considered, happy to try those out as well.

Cheers!

brycedrennan commented 11 months ago

here you go

  ruff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Extract ruff version from requirements.txt
        id: ruff_version
        run: echo "::set-output name=version::$(grep -oP 'ruff==\K[^"]+' requirements.txt)"
      - uses: chartboost/ruff-action@v1
        with:
          args: --config tests/ruff.toml
          version: ${{ steps.ruff_version.outputs.version }}
brucearctor commented 10 months ago

@brycedrennan -- THANKS! This looks like it works well from a requirements.txt file [ which can also be generated from a pyproject.toml/poetry config ].

brucearctor commented 10 months ago

Anyone that's sufficiently interested, we'd welcome a way to handle this as part of this action [ anyone want to add that functionality? ].

It also invites interesting questions like what to do if both pyproject.toml and requirements.txt exist ... etc... :-)

brucearctor commented 5 months ago

marking closed, since looks like addressed