diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index f3b3786d..85db04cb 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -56,10 +56,6 @@ jobs: - name: Install dependencies run: uv sync --frozen --no-build --no-binary-package django-memoize --extra ci - # Linting will come after the migration to uv is complete, disabled for now - #- name: Lint with ruff - # run: uv run --frozen ruff check . - - name: Django system check env: DATABASE_URL: postgres://postgres:insecure@localhost/fragforce_test diff --git a/.github/workflows/ruff-check.yaml b/.github/workflows/ruff-check.yaml new file mode 100644 index 00000000..704efd81 --- /dev/null +++ b/.github/workflows/ruff-check.yaml @@ -0,0 +1,34 @@ +name: Ruff Check + +on: + push: + branches: + - dev + - master + pull_request: + +jobs: + ruff-check: + name: Run Ruff linting + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: Install uv + uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 + with: + python-version: '3.13' + + - name: Install dependencies + run: uv sync --frozen --no-build --no-binary-package django-memoize --extra ci + + - name: Run Ruff linting + run: uv run --no-sync --no-build ruff check . diff --git a/CHANGELOG.md b/CHANGELOG.md index 4418c4e5..4a08a77c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed + - Renamed fields on `ffdonations` to follow linting requirements (numDonations -> num_donations) - Linted the whole codebase, passes `ruff check` fully now. +### Added + +- Added `ruff-check.yaml` workflow to force linting on all pull requests and pushes. + ## [3.0.0] - 2026-09-09 ### Fixed diff --git a/dev/lint.sh b/dev/lint.sh index 884370a9..82018be0 100755 --- a/dev/lint.sh +++ b/dev/lint.sh @@ -22,6 +22,5 @@ if [[ -z "$FILES" ]]; then exit 0 fi -echo "Linting is not currently enforced, but would be appreciated until it is enforced" echo "Running ruff on $(echo $FILES | wc -w | tr -d ' ') Python files..." dc exec -T web uv run --no-sync --no-build ruff check $FILES diff --git a/dev/pr.sh b/dev/pr.sh index 12f1c0db..e8ab56b6 100755 --- a/dev/pr.sh +++ b/dev/pr.sh @@ -5,24 +5,27 @@ # dev/pr.sh "PR title" # dev/pr.sh "PR title" --base some-branch # default base is dev # dev/pr.sh "PR title" --body "Description" # add a description above test results +# dev/pr.sh "PR title" --skip-lint # push and open PR without running lint # dev/pr.sh "PR title" --skip-tests # push and open PR without running tests cd "$(git rev-parse --show-toplevel)" TITLE="${1}" if [[ -z "$TITLE" ]]; then - echo "Usage: dev/pr.sh \"PR title\" [--base ] [--body \"description\"] [--skip-tests]" + echo "Usage: dev/pr.sh \"PR title\" [--base ] [--body \"description\"] [--skip-lint] [--skip-tests]" exit 1 fi shift BASE="dev" +SKIP_LINT=false SKIP_TESTS=false BODY="" while [[ $# -gt 0 ]]; do case "$1" in --base) BASE="$2"; shift 2 ;; --body) BODY="$2"; shift 2 ;; + --skip-lint) SKIP_LINT=true; shift ;; --skip-tests) SKIP_TESTS=true; shift ;; *) echo "Unknown argument: $1"; exit 1 ;; esac @@ -30,6 +33,20 @@ done BRANCH=$(git rev-parse --abbrev-ref HEAD) +if [[ "$SKIP_LINT" = false ]]; then + echo "Running lint..." + LINT_OUTPUT=$(dev/lint.sh 2>/dev/null) + LINT_EXIT=$? + + if [[ $TEST_EXIT -ne 0 ]]; then + echo "" + echo "Linting failed - aborting. Use --skip-lint to open a PR anyway." + echo "" + echo "$LINT_OUTPUT" + echo $LINT_EXIT + fi +fi + if [[ "$SKIP_TESTS" = false ]]; then echo "Running tests..." TEST_OUTPUT=$(dev/runtests.sh 2>/dev/null) @@ -61,5 +78,6 @@ ${BODY:+${BODY} }## Test Results ${TEST_OUTPUT:-"Tests skipped."} +${LINT_OUTPUT:-"Linting skipped"} EOF )" diff --git a/pyproject.toml b/pyproject.toml index 739be683..83d2d575 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ [project.optional-dependencies] ci = [ "coverage", + "ruff>=0.16.6", "unittest-xml-reporting", ] dev = [ diff --git a/uv.lock b/uv.lock index 5f10b0c2..751eb657 100644 --- a/uv.lock +++ b/uv.lock @@ -391,6 +391,7 @@ dependencies = [ [package.optional-dependencies] ci = [ { name = "coverage" }, + { name = "ruff" }, { name = "unittest-xml-reporting" }, ] dev = [ @@ -416,6 +417,7 @@ requires-dist = [ { name = "py-cord", specifier = ">=2.8.1,<3" }, { name = "redis", specifier = ">=8.1.0" }, { name = "requests", extras = ["security"] }, + { name = "ruff", marker = "extra == 'ci'", specifier = ">=0.16.6" }, { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.16.6" }, { name = "social-auth-app-django", specifier = ">=6.0.1" }, { name = "unittest-xml-reporting", marker = "extra == 'ci'" },