astral-sh / ruff-action

A GitHub Action to run Ruff
Apache License 2.0
58 stars 4 forks source link

Convert from composite to typescript #17

Open eifinger opened 5 days ago

eifinger commented 5 days ago

Summary

Converts the action from a composite to javascript. Most importantly to make use of prebuilt libraries and helpers like actions/toolkit.

The structure and features are modeled after astral-sh/setup-uv

Changes

  1. Download the ruff executable for the current platform from the GitHub releases
  2. Add ruff to the PATH
  3. Validate the downloaded ruff executable against its checksum
  4. Cache ruff in the Tool Cache to speed up runs on self-hosted runners
  5. Support semver ranges to define the ruff version to install

🚨 Breaking changes

Removes the changed-files input.

This input could previously be used to run ruff only on files changed in a PR. The functionality was implemented by calling another action. This repo should focus on providing a quick and easy way to use ruff in GitHub Actions, not add more functionality on top of ruff.

The previous functionality can be replicated with:

- uses: actions/checkout@v4
- name: Get changed files
  id: changed-files
  uses: tj-actions/changed-files@v45
  with:
    files: |
      **.py
- name: Run ruff on changed files only 
  uses: astral-sh/ruff-action@v2
  with:
    src: ${{ steps.changed-files.outputs.all_changed_files }}

This was tested here: https://github.com/astral-sh/ruff-action/actions/runs/12017035736/job/33498508269

github-advanced-security[bot] commented 5 days ago

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

eifinger commented 4 days ago

actionlint is currently failing because of https://github.com/rhysd/actionlint/issues/484

eifinger commented 1 day ago

Alternative for the removed changed-files input tested here: https://github.com/astral-sh/ruff-action/actions/runs/12017035736/job/33498508269