diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a01d8a3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,24 @@ +name: Lint and Format + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Run Ruff Linter + uses: astral-sh/ruff-action@v3 + with: + args: "check" + + - name: Run Ruff Formatter + if: always() + uses: astral-sh/ruff-action@v3 + with: + args: "format --check" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..48ffa41 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +RUFF := $(shell command -v ruff 2>/dev/null || echo ~/.local/bin/ruff) + +.PHONY: fix check setup + +setup: + @command -v ruff >/dev/null 2>&1 || (echo "Installing Ruff..." && curl -LsSf https://astral.sh/ruff/install.sh | sh) + +fix: setup + $(RUFF) check --fix . + $(RUFF) format . + +check: setup + $(RUFF) check . + $(RUFF) format --check .