From 771c69d89c1182cfc4847d3428fe11907c3beef1 Mon Sep 17 00:00:00 2001 From: David Paul Graham Date: Thu, 3 Oct 2024 22:36:23 -0400 Subject: [PATCH] implement ruff based workflow to check all python files are linted and formatted --- .github/workflows/lint_server.yaml | 31 ++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint_server.yaml diff --git a/.github/workflows/lint_server.yaml b/.github/workflows/lint_server.yaml new file mode 100644 index 00000000..0f298063 --- /dev/null +++ b/.github/workflows/lint_server.yaml @@ -0,0 +1,31 @@ +name: Lint Python files +on: + pull_request: + paths: + - "server/**" + - ".github/workflows/*" + push: + paths: + - "server/**" + - ".github/workflows/*" + workflow_call: + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./server + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - run: pip install -r requirements_dev.txt + - name: Lint Python files + run: | + ruff check . -e + - name: Format Python files + run: | + ruff format . --check diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67b93ea9..87ed5337 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: rev: v0.5.6 hooks: - id: ruff - args: [--fix, --exit-non-zero-on-fix, --config, ./server/pyproject.toml] + args: [--fix, --config, ./server/pyproject.toml] - id: ruff-format args: [--config, ./server/pyproject.toml] # Check django migrations