Compare commits

...
37 Commits
Author SHA1 Message Date
David J. FelixandGitHub 61703ed12e Fix changed-files for cases where no python files changed (#4)
## Problem
When a PR contains no changed python files, but changed-files is set to
true, ruff will run on all files, including ones not changed.

## Solution
Pass the input through to the script and short circuit to success in
cases where both the flag is set and no python files were changed.
2024-09-30 13:17:11 -04:00
Charlie MarshandGitHub 701f39cb3f Use Ruff for formatting in CI (#3) 2024-09-29 19:43:26 -04:00
Charlie Marsh ad8ad9ec2e Update some documentation 2024-09-29 19:39:38 -04:00
Charlie MarshandCharlie Marsh beb1d37bb7 Update README.md 2024-09-29 19:24:56 -04:00
Charlie MarshandGitHub 7e5f451d8a Update README.md 2024-09-29 19:24:25 -04:00
dependabot[bot]andGitHub e88ca0d813 Bump tj-actions/changed-files from 44 to 45 in the github-actions group (#1) 2024-09-29 19:22:18 -04:00
Charlie MarshandGitHub 7388145ba9 Update README to reflect fork (#2) 2024-09-29 19:22:10 -04:00
Ferran Fernández GarridoandGitHub 491342200c Merge pull request #24 from ma-sadeghi/feature/changed-only
Provide support to lint/format changed files only
2024-05-30 17:38:45 +02:00
Amin Sadeghi 79eabade54 Document changed-files keyword in README 2024-04-04 15:34:23 -04:00
Amin Sadeghi 0df4a95686 Exclude non-Python files as part of changed-files action 2024-04-04 15:25:49 -04:00
Amin Sadeghi a9c46eeb9c Exclude non-Python files 2024-04-04 14:53:05 -04:00
Amin Sadeghi 992901c201 First try at implementing only-apply-to-changed-files 2024-04-04 14:40:34 -04:00
brucearctorandGitHub 47bc0821f5 Merge pull request #19 from yosmoc/configure_check_or_format_mode
support ruff mode argument
2024-03-25 07:30:11 -07:00
brucearctorandGitHub 6e7156986b Merge branch 'main' into configure_check_or_format_mode 2024-03-25 07:30:03 -07:00
brucearctorandGitHub 88d6702e4e Merge pull request #18 from zachborboa/patch-1
Clean up section headers
2024-03-21 12:15:54 -07:00
Yoshihisa Mochihara e31dbd6695 Add ruff format example in README 2024-03-19 19:38:06 +01:00
Yoshihisa Mochihara f8abd91ecb Revert "support ruff mode Argument"
This reverts commit 17a2e52c32.
2024-03-19 19:36:55 +01:00
Yoshihisa Mochihara 17a2e52c32 support ruff mode Argument
Users can now specify the mode of ruff to be 'check' or 'format' using the mode input.
2024-03-13 00:07:19 +01:00
Zach BorboaandGitHub 38ef108542 Clean up section headers 2024-03-07 05:05:40 -05:00
brucearctorandGitHub 42fd10b26e Merge pull request #16 from ChartBoost/dependabot/github_actions/github-actions-8ef4cb809c
Bump the github-actions group with 2 updates
2024-02-26 00:11:59 -08:00
dependabot[bot]andGitHub 32ddb6ca80 Bump the github-actions group with 2 updates
Bumps the github-actions group with 2 updates: [jakebailey/pyright-action](https://github.com/jakebailey/pyright-action) and [actions/stale](https://github.com/actions/stale).


Updates `jakebailey/pyright-action` from 1 to 2
- [Release notes](https://github.com/jakebailey/pyright-action/releases)
- [Commits](https://github.com/jakebailey/pyright-action/compare/v1...v2)

Updates `actions/stale` from 7 to 9
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v7...v9)

---
updated-dependencies:
- dependency-name: jakebailey/pyright-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-26 02:20:31 +00:00
brucearctorandGitHub 0cf49cc7a3 Merge pull request #14 from cclauss/patch-1
Keep GitHub Actions up to date with GitHub's Dependabot
2024-02-25 18:19:56 -08:00
brucearctorandGitHub 4c93cf060a Merge pull request #13 from boidolr/docs-update
Update documentation & build config
2024-02-18 11:34:29 -08:00
Raphael Boidol d1154b06e8 Update checkout action in workflows 2024-02-18 19:31:00 +01:00
Raphael Boidol 06460f5390 Update pre-commit hooks & run formatting 2024-02-18 19:31:00 +01:00
Raphael Boidol c0661673e2 Update README.md
Change links to point to up to date URLs
2024-02-18 19:30:44 +01:00
brucearctorandGitHub 41f0574bbd Merge pull request #15 from cclauss/patch-2
README.md: Update the Ruff version
2024-02-17 17:37:23 -08:00
Christian ClaussandGitHub 5619897516 Update README.md 2024-02-18 01:44:15 +01:00
Christian ClaussandGitHub b22a8e1c0d README.md: Update the Ruff version 2024-02-17 13:33:54 +01:00
Christian ClaussandGitHub 58ed8ddf37 Keep GitHub Actions up to date with GitHub's Dependabot
Automatically creates PRs like:
* py2many/py2many#592
---
* https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
* https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
2024-02-17 13:27:46 +01:00
brucearctorandGitHub a0f145b455 Merge pull request #9 from boidolr/main
Switch to `RUFF_OUTPUT_FORMAT`
2023-12-12 11:43:24 -07:00
Raphael BoidolandGitHub 98cc4a4345 Switch to RUFF_OUTPUT_FORMAT
`RUFF_FORMAT` was deprecated in favor of `RUFF_OUTPUT_FORMAT` in  v0.0.291.
2023-11-24 10:54:45 +01:00
brucearctorandGitHub 2bc585f125 Merge pull request #3 from YoniMelki/patch-1
Update README.md
2023-06-20 08:54:56 -07:00
Yoni MelkiandGitHub 1c2f7b23b4 Update README.md 2023-06-18 21:25:59 +03:00
brucearctor 9a777ad092 args 2023-04-03 10:23:03 -07:00
brucearctor ed9d6e65a4 cleaned 2023-04-02 20:34:03 -07:00
brucearctor 403a32e32b v1 2023-04-02 20:07:12 -07:00
9 changed files with 164 additions and 68 deletions
+13
View File
@@ -0,0 +1,13 @@
# Keep GitHub Actions up to date with GitHub's Dependabot...
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
version: 2
updates:
- package-ecosystem: github-actions
directory: /
groups:
github-actions:
patterns:
- "*" # Group all Actions updates into a single larger pull request
schedule:
interval: weekly
+2 -2
View File
@@ -5,12 +5,12 @@ on:
paths: paths:
- '.github/workflows/**' - '.github/workflows/**'
pull_request: pull_request:
paths: paths:
- '.github/workflows/**' - '.github/workflows/**'
jobs: jobs:
actionlint: actionlint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: reviewdog/action-actionlint@v1 - uses: reviewdog/action-actionlint@v1
+9 -5
View File
@@ -1,4 +1,4 @@
name: CheckPython name: Python
on: [push, pull_request] on: [push, pull_request]
@@ -6,7 +6,11 @@ jobs:
clean-python: clean-python:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: psf/black@stable - uses: chartboost/ruff-action@v1
- uses: chartboost/ruff-action@v0 with:
- uses: jakebailey/pyright-action@v1 args: 'check'
- uses: chartboost/ruff-action@v1
with:
args: 'format --check'
- uses: jakebailey/pyright-action@v2
+2 -2
View File
@@ -16,11 +16,11 @@ jobs:
issues: read issues: read
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/stale@v7 - uses: actions/stale@v9
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: "This pull request has been marked as stale. It will be closed in 14 days if no further activity occurs." stale-pr-message: "This pull request has been marked as stale. It will be closed in 14 days if no further activity occurs."
close-pr-message: "This pull request has been closed due to lack of activity." close-pr-message: "This pull request has been closed due to lack of activity."
days-before-pr-stale: ${{ env.PR_STALE_DAYS }} days-before-pr-stale: ${{ env.PR_STALE_DAYS }}
days-before-pr-close: ${{ env.PR_CLOSE_DAYS }} days-before-pr-close: ${{ env.PR_CLOSE_DAYS }}
delete-branch: true delete-branch: true
+7 -7
View File
@@ -1,23 +1,23 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/rhysd/actionlint - repo: https://github.com/rhysd/actionlint
rev: v1.6.23 rev: v1.6.26
hooks: hooks:
- id: actionlint - id: actionlint
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 23.3.0 rev: 24.1.1
hooks: hooks:
- id: black - id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.260' rev: 'v0.2.1'
hooks: hooks:
- id: ruff - id: ruff
- repo: https://github.com/RobertCraigie/pyright-python - repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.301 rev: v1.1.350
hooks: hooks:
- id: pyright - id: pyright
+95 -1
View File
@@ -1,2 +1,96 @@
# ruff-action # ruff-action
A GitHub Action for Ruff
> [!NOTE]
>
> 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 overhauled
> in a future major release.
A [GitHub Action](https://github.com/features/actions) to run
[Ruff](https://github.com/astral-sh/ruff).
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](https://pypi.org/project/ruff/)).
## Basic Usage
Create a file (ex: `.github/workflows/ruff.yml`) inside your repository with:
```yaml
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
```
## 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](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
### 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"
```
### Use `ruff format`
```yaml
- uses: chartboost/ruff-action@v1
with:
args: "format --check"
```
### Only run ruff on changed files
```yaml
- uses: chartboost/ruff-action@v1
with:
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>
+19 -9
View File
@@ -1,27 +1,35 @@
name: "Ruff GH Action" name: "ruff-action"
description: "A GH Action of Ruff, the extremely fast Python linter." description: "A GitHub Action to run Ruff, an extremely fast Python linter and code formatter."
author: "Austin Bennett and the Ruff Community" author: "astral-sh"
inputs: inputs:
args: args:
description: description: "Arguments passed to Ruff. Use `ruff --help` to see available options. Defaults to `check`."
"Arguments passed to Ruff. Use `ruff --help` to see available options.
Default: 'check'"
required: false required: false
default: "check" default: "check"
src: src:
description: "Source to run ruff. Default: '.'" description: "Source to run Ruff. Defaults to the current directory."
required: false required: false
default: "." default: "."
version: version:
description: 'The version of ruff to use, e.g. "0.0.259"' description: 'The version of Ruff to use, e.g., `0.6.0` Defaults to the latest version.'
required: false required: false
default: "" default: ""
changed-files:
description: 'Whether to only run Ruff on changed files. Defaults to `false`.'
required: false
default: "false"
branding: branding:
color: "black" color: "black"
icon: "code" icon: "code"
runs: runs:
using: composite using: composite
steps: steps:
- name: Get changed files
id: changed-files
if: ${{ inputs.changed-files == 'true' }}
uses: tj-actions/changed-files@v45
with:
files: '**.py'
- run: | - run: |
if [ "$RUNNER_OS" == "Windows" ]; then if [ "$RUNNER_OS" == "Windows" ]; then
python $GITHUB_ACTION_PATH/action/main.py python $GITHUB_ACTION_PATH/action/main.py
@@ -29,9 +37,11 @@ runs:
python3 $GITHUB_ACTION_PATH/action/main.py python3 $GITHUB_ACTION_PATH/action/main.py
fi fi
env: env:
RUFF_FORMAT: github RUFF_OUTPUT_FORMAT: github
INPUT_ARGS: ${{ inputs.args }} INPUT_ARGS: ${{ inputs.args }}
INPUT_SRC: ${{ inputs.src }} INPUT_SRC: ${{ inputs.src }}
INPUT_VERSION: ${{ inputs.version }} INPUT_VERSION: ${{ inputs.version }}
IS_CHANGED_FILES_ENABLED: ${{ inputs.changed-files }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
pythonioencoding: utf-8 pythonioencoding: utf-8
shell: bash shell: bash
+12 -1
View File
@@ -1,4 +1,5 @@
"""GitHub Action for Ruff.""" """GitHub Action for Ruff."""
import os import os
import re import re
import shlex import shlex
@@ -10,6 +11,8 @@ ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
ARGS = os.getenv("INPUT_ARGS", default="") ARGS = os.getenv("INPUT_ARGS", default="")
SRC = os.getenv("INPUT_SRC", default="") SRC = os.getenv("INPUT_SRC", default="")
VERSION = os.getenv("INPUT_VERSION", default="") VERSION = os.getenv("INPUT_VERSION", default="")
CHANGED_FILES = os.getenv("CHANGED_FILES", "")
IS_CHANGED_FILES_ENABLED = os.getenv("IS_CHANGED_FILES_ENABLED", default="false")
version_specifier = "" version_specifier = ""
if VERSION != "": if VERSION != "":
@@ -20,6 +23,14 @@ if VERSION != "":
req = f"ruff{version_specifier}" req = f"ruff{version_specifier}"
proc = run(["pipx", "run", req, *shlex.split(ARGS), *shlex.split(SRC)]) # If `CHANGED_FILES` is not empty, split it into a list; otherwise, use `SRC`.
files_to_check = shlex.split(CHANGED_FILES or SRC)
# If IS_CHANGED_FILES_ENABLED is true and CHANGED_FILES was empty, there were no files to check
# Short circuit to prevent ruff from running on all files because it got no file argument
if IS_CHANGED_FILES_ENABLED == "true" and not CHANGED_FILES:
sys.exit(0)
proc = run(["pipx", "run", req, *shlex.split(ARGS), *files_to_check])
sys.exit(proc.returncode) sys.exit(proc.returncode)
+5 -41
View File
@@ -1,46 +1,10 @@
[tool.ruff] [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]+?))$"
target-version = "py311" target-version = "py311"
[tool.ruff.mccabe] [tool.ruff.lint]
# Unlike Flake8, default to a complexity level of 10. extend-select = ["B", "UP"]
max-complexity = 10 fixable = ["I", "RUF100"]
unfixable = []
[tool.pyright] [tool.pyright]
typeCheckingMode = "lazy" typeCheckingMode = "lazy"
@@ -51,4 +15,4 @@ reportMissingTypeStubs = false
reportInvalidStringEscapeSequence = false reportInvalidStringEscapeSequence = false
pythonVersion = "3.11" pythonVersion = "3.11"
pythonPlatform = "Linux" pythonPlatform = "Linux"