Skip to content

Commit

Permalink
Add REAME
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Sep 29, 2024
1 parent 4913422 commit 4cf20f3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 51 deletions.
57 changes: 45 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# ruff-action
A GitHub Action for Ruff

A [GitHub Action](https://github.com/features/actions) to run
[Ruff](https://github.com/astral-sh/ruff).

Ruff can now be used as a [GitHub Action](https://github.com/features/actions).
> [!TIP] This Action is a fork of
> [chartboost/ruff-action](https://github.com/ChartBoost/ruff-action), which is
> no longer maintained. The Action is largely unchanged, but will be updated in
> a future major release.
This action is commonly used as a pass/fail test to ensure your repository stays clean, abiding the [Rules](https://docs.astral.sh/ruff/rules/) specified in your configuration. Though it runs `ruff`, the action can do anything `ruff` can (ex, fix).
This action is commonly used as a pass/fail test to ensure your repository stays
clean, abiding the [Rules](https://docs.astral.sh/ruff/rules/) specified in your
configuration. Though it runs `ruff`, the action can do anything `ruff` can (ex,
fix).

## Compatibility
This action is known to support all GitHub-hosted runner OSes. It likely can run on self-hosted runners, but might need specific dependencies. Only published versions of Ruff are supported (i.e. whatever is available on PyPI).

This action is known to support all GitHub-hosted runner OSes. It likely can run
on self-hosted runners, but might need specific dependencies. Only published
versions of Ruff are supported (i.e., whatever is available on
[PyPI](https://pypi.org/project/ruff/)).

## Basic Usage

Create a file (ex: `.github/workflows/ruff.yml`) inside your repository with:

```yaml
Expand All @@ -24,38 +36,59 @@ jobs:
```
## Advanced Usage
The Ruff action can be customized via optional configuration parameters passed to Ruff (using `with:`):
- version: Must be a Ruff release available on PyPI. By default, latest release of Ruff. You can pin a version, or use any valid version specifier.
- args: You can specify the arguments to pass to the ruff command. By default, it's `check`.
- src: default, '.'
The Ruff action can be customized via optional configuration parameters passed
to Ruff (using `with:`):

- `version`: Must be a Ruff release available on
[PyPI](https://pypi.org/project/ruff/). Defaults to the latest Ruff release.
You can pin a version, or use any valid version specifier.
- `args`: The arguments to pass to the `ruff` command. Defaults to `check`,
which lints the current directory.
- `src`: The directory to run `ruff` in. Defaults to the root of the repository.

See [Configuring Ruff](https://github.com/astral-sh/ruff/blob/main/docs/configuration.md) for details
See
[Configuring Ruff](https://github.com/astral-sh/ruff/blob/main/docs/configuration.md)
for details

### Use a different ruff version

```yaml
- uses: chartboost/ruff-action@v1
with:
version: 0.2.2
```

### Specify a different source directory

```yaml
- uses: chartboost/ruff-action@v1
with:
src: './src'
src: "./src"
```

### Use `ruff format`

```yaml
- uses: chartboost/ruff-action@v1
with:
args: 'format --check'
args: "format --check"
```

### Only run ruff on changed files

```yaml
- uses: chartboost/ruff-action@v1
with:
changed-files: 'true'
changed-files: "true"
```

## License

Apache

<div align="center">
<a target="_blank" href="https://astral.sh" style="background:none">
<img src="https://raw.githubusercontent.com/astral-sh/uv/main/assets/svg/Astral.svg" alt="Made by Astral">
</a>
</div>
44 changes: 5 additions & 39 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,12 @@
[tool.ruff]

select = ["A", "ANN", "B", "C90", "D", "E", "F", "I", "N", "COM", "DTZ", "PD", "RUF", "TID", "UP", "W"]
ignore = ["D203", "D212"]

fixable = ["I", "RUF100"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff]
target-version = "py311"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[tool.ruff.lint]
extend-select = ["B", "UP"]
fixable = ["I", "RUF100"]
unfixable = []

[tool.pyright]
typeCheckingMode = "lazy"
Expand Down

0 comments on commit 4cf20f3

Please sign in to comment.