Merge pull request #3823 from mdeweerd/pre-commit-wf

ci: add pre-commit.yml for GitHub Actions
This commit is contained in:
paul-gauthier 2025-05-08 15:09:16 -07:00 committed by GitHub
commit 2c1685bb36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 56 additions and 8 deletions

48
.github/workflows/pre-commit.yml vendored Normal file
View file

@ -0,0 +1,48 @@
---
name: pre-commit
on:
pull_request:
push:
workflow_dispatch:
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
RAW_LOG: pre-commit.log
CS_XML: pre-commit.xml
steps:
- run: sudo apt-get update && sudo apt-get install cppcheck uncrustify
if: false
- uses: actions/checkout@v4
- run: python -m pip install pre-commit
- uses: actions/cache/restore@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit hooks
env:
SKIP: no-commit-to-branch
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
- name: Convert Raw Log to Checkstyle format (launch action)
uses: mdeweerd/logToCheckStyle@v2025.1.1
if: ${{ failure() }}
with:
in: ${{ env.RAW_LOG }}
# out: ${{ env.CS_XML }}
- uses: actions/cache/save@v4
if: ${{ ! cancelled() }}
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Provide log as artifact
uses: actions/upload-artifact@v4
if: ${{ ! cancelled() }}
with:
name: precommit-logs
path: |
${{ env.RAW_LOG }}
${{ env.CS_XML }}
retention-days: 2

View file

@ -5,5 +5,6 @@ from .editblock_fenced_prompts import EditBlockFencedPrompts
class EditBlockFencedCoder(EditBlockCoder): class EditBlockFencedCoder(EditBlockCoder):
"""A coder that uses fenced search/replace blocks for code modifications.""" """A coder that uses fenced search/replace blocks for code modifications."""
edit_format = "diff-fenced" edit_format = "diff-fenced"
gpt_prompts = EditBlockFencedPrompts() gpt_prompts = EditBlockFencedPrompts()

View file

@ -5,6 +5,7 @@ from .help_prompts import HelpPrompts
class HelpCoder(Coder): class HelpCoder(Coder):
"""Interactive help and documentation about aider.""" """Interactive help and documentation about aider."""
edit_format = "help" edit_format = "help"
gpt_prompts = HelpPrompts() gpt_prompts = HelpPrompts()

View file

@ -1,10 +1,11 @@
import os import os
import oslex
import re import re
import shlex
import subprocess import subprocess
import sys import sys
import traceback import traceback
import warnings import warnings
import oslex
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path

View file

@ -132,7 +132,7 @@ def find_non_self_methods(path):
with open(filename, "r") as file: with open(filename, "r") as file:
try: try:
node = ast.parse(file.read(), filename=filename) node = ast.parse(file.read(), filename=filename)
except: except: # noqa: E722
pass pass
checker = SelfUsageChecker() checker = SelfUsageChecker()
checker.visit(node) checker.visit(node)

View file

@ -48,5 +48,5 @@ build-backend = "setuptools.build_meta"
write_to = "aider/_version.py" write_to = "aider/_version.py"
[tool.codespell] [tool.codespell]
skip = "*.svg,Gemfile.lock" skip = "*.svg,Gemfile.lock,tests/fixtures/*,aider/website/*"
write-changes = true write-changes = true

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# flake8: noqa: E501
""" """
Generate a celebratory SVG image for Aider reaching 30,000 GitHub stars. Generate a celebratory SVG image for Aider reaching 30,000 GitHub stars.
This creates a shareable social media graphic with confetti animation. This creates a shareable social media graphic with confetti animation.
@ -7,7 +8,6 @@ This creates a shareable social media graphic with confetti animation.
import argparse import argparse
import base64 import base64
import math import math
import os
import random import random
from pathlib import Path from pathlib import Path

View file

@ -3,7 +3,6 @@
Download Material Design Icons SVGs used in the README and save to local assets. Download Material Design Icons SVGs used in the README and save to local assets.
""" """
import os
from pathlib import Path from pathlib import Path
import requests import requests

View file

@ -1,7 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import json
import os
import re
import sys import sys
import pyte import pyte

View file

@ -155,7 +155,7 @@ def test_ai_comment_pattern():
assert ( assert (
question_js_has_bang == "?" question_js_has_bang == "?"
), "Expected at least one bang (!) comment in watch_question.js fixture" ), "Expected at least one bang (!) comment in watch_question.js fixture"
# Test Lisp fixture # Test Lisp fixture
lisp_path = fixtures_dir / "watch.lisp" lisp_path = fixtures_dir / "watch.lisp"
lisp_lines, lisp_comments, lisp_has_bang = watcher.get_ai_comments(str(lisp_path)) lisp_lines, lisp_comments, lisp_has_bang = watcher.get_ai_comments(str(lisp_path))