diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml new file mode 100644 index 0000000..41cf226 --- /dev/null +++ b/.github/workflows/code_quality.yml @@ -0,0 +1,42 @@ +name: Code Quality Checks + +on: pull_request + +jobs: + code_format: + name: Code Formatting + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.12 + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + key: linux-pip-dev-${{ hashFiles('requirements-dev.txt') }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: Run code formatter + run: isort . && black . + + - name: Assert that the codebase has no dif + shell: bash + run: | + if [[ -n "$(git status --short | grep '^ [^\s]\|??')" ]]; then + echo "Unstaged/untracked files exist" + git status + git --no-pager diff + echo "Auto formatting hasn't been applied by the codebase." + exit 1 + fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 19b9f00..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -repos: - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - - - repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black diff --git a/bootstrap.ps1 b/bootstrap.ps1 index 070823a..98d5ad8 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -28,8 +28,4 @@ if (-Not (Test-Path $requirements_file)) { Write-Host "Installing dependencies from requirements-dev.txt..." pip install -r $requirements_file -# Activate pre-commit hooks -Write-Host "Installing pre-commit hooks..." -pre-commit install - Write-Host "Bootstrap process complete." diff --git a/bootstrap.sh b/bootstrap.sh index 9a4cfc7..1b9c7a5 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -25,8 +25,4 @@ fi echo "Installing dependencies from requirements-dev.txt..." pip install -r "$REQUIREMENTS_FILE" -# Activate pre-commit hooks -echo "Installing pre-commit hooks..." -pre-commit install - echo "Bootstrap process complete." diff --git a/requirements-dev.txt b/requirements-dev.txt index a09970a..110877d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,3 +2,5 @@ pre_commit==4.0.1 pyarrow-stubs==17.13 +black==24.10.0 +isort==5.13.2