Skip to content

Modernize linting and configuration setup #3

Modernize linting and configuration setup

Modernize linting and configuration setup #3

Workflow file for this run

---
name: Lint with Ruff
defaults:
run:
shell: bash
on:
push:
branches: [master, dev]
pull_request:
branches: [master, dev]
paths:
- "**/*.py"
- "**/*.yml"
- "**/*.yaml"
- "pyproject.toml"
- ".github/workflows/ruff.yml"
schedule:
# run CI every day even if no PRs/merges occur
- cron: '0 12 * * *'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install lint dependencies
run: |
# Using pip for CI stability, but uv is recommended for local development
python -m pip install --upgrade pip
# Install latest ruff within 0.x range to get updates but avoid breaking changes
pip install "ruff>=0.12.0,<1.0" "yamllint>=1.35.1"
- name: Run Ruff linter
run: |
echo "::group::Running Ruff checks"
ruff check slither/ tests/ scripts/ || RUFF_EXIT=$?
echo "::endgroup::"
if [ "${RUFF_EXIT:-0}" -ne 0 ]; then
echo "❌ Ruff check failed. Run 'make reformat' or 'ruff check --fix' locally to fix issues."
exit $RUFF_EXIT
fi
echo "✅ Ruff check passed"
# Formatting check disabled to avoid changes to existing code
# - name: Run Ruff formatter check
# run: |
# echo "::group::Checking formatting with Ruff"
# ruff format --check slither/ tests/ scripts/ || FORMAT_EXIT=$?
# echo "::endgroup::"
# if [ "${FORMAT_EXIT:-0}" -ne 0 ]; then
# echo "❌ Formatting check failed. Run 'make reformat' or 'ruff format' locally to fix formatting."
# exit $FORMAT_EXIT
# fi
# echo "✅ Formatting check passed"
- name: Run yamllint
run: |
echo "::group::Running yamllint"
yamllint .github/ || YAML_EXIT=$?
echo "::endgroup::"
if [ "${YAML_EXIT:-0}" -ne 0 ]; then
echo "❌ YAML linting failed. Fix the YAML syntax errors shown above."
exit $YAML_EXIT
fi
echo "✅ YAML linting passed"