GitHub - astral-sh/ruff-action: A GitHub Action to run Ruff (original) (raw)

ruff-action

A GitHub Action to run ruff.

This action is commonly used as a pass/fail test to ensure your repository stays clean, abiding the rules specified in your configuration. Though it runs ruff, the action can do anything ruff can (ex, fix).

Contents

Usage

Input Description Default
version The version of Ruff to install. See Install specific versions latest
version-file The file to read the version from. See Install a version from a specified version file None
args The arguments to pass to the ruff command. See Configuring Ruff check
src The directory or single files to run ruff on. github.workspace
checksum The sha256 checksum of the downloaded executable. None
github-token The GitHub token to use for authentication. GITHUB_TOKEN

Basic

Specify a different source directory

Specify multiple files

Use to install ruff

This action adds ruff to the PATH, so you can use it in subsequent steps.

By default, this action runs ruff check after installation. If you do not want to run any ruff command but only install it, you can use the args input to overwrite the default value (check):

Use ruff format

Install specific versions

By default this action looks for a pyproject.toml file in the root of the repository to determine the ruff version to install. If no pyproject.toml file is found, or no ruff version is defined inproject.dependencies, project.optional-dependencies, or dependency-groups, the latest version is installed.

Install the latest version

Install a specific version

Install a version by supplying a semver range

You can specify a semver rangeto install the latest version that satisfies the range.

Install a version from a specified version file

You can specify a file to read the version from. Currently pyproject.toml and requirements.txt are supported.

Validate checksum

You can specify a checksum to validate the downloaded executable. Checksums up to the default version are automatically verified by this action. The sha256 hashes can be found on thereleases page of the ruff repo.

GitHub authentication token

This action uses the GitHub API to fetch the ruff release artifacts. To avoid hitting the GitHub API rate limit too quickly, an authentication token can be provided via the github-token input. By default, the GITHUB_TOKEN secret is used, which is automatically provided by GitHub Actions.

If the defaultpermissions for the GitHub tokenare not sufficient, you can provide a custom GitHub token with the necessary permissions.

Outputs

Output Description
ruff-version The version of Ruff that was installed.

Made by Astral