Modernize linting and configuration setup #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| 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" | |
| 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: Run Ruff linter | |
| uses: astral-sh/ruff-action@v1 | |
| with: | |
| args: "check slither/ tests/ scripts/" | |
| # 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: Set up Python for yamllint | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install and run yamllint | |
| run: | | |
| # Use uv for fast installation | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| export PATH="$HOME/.local/bin:$PATH" | |
| uv tool install yamllint | |
| echo "::group::Running yamllint" | |
| uvx 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" |