diff --git a/.github/workflows/all-static-checks.yaml b/.github/workflows/all-static-checks.yaml index 914ba2fa1ee..df96cc19546 100644 --- a/.github/workflows/all-static-checks.yaml +++ b/.github/workflows/all-static-checks.yaml @@ -8,6 +8,38 @@ on: - "main" jobs: + pre-commit: + name: Run Pre-commit Hooks + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history so 'origin/main' is available + fetch-refs: true # Ensure all refs are fetched + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Run Pre-commit + uses: pre-commit/action@v3.0.1 + with: + extra_args: | + --from-ref ${{ github.event_name == 'pull_request' && format('refs/remotes/origin/{0}', github.event.pull_request.base.ref) || 'HEAD^' }} \ + --to-ref HEAD + continue-on-error: false + check-black: + runs-on: ubuntu-latest + steps: + - name: Do Nothing + run: echo "Black is covered by pre-commit. This is a placeholder to be removed after updating branch restrictions." + + check-spdx-licenses: runs-on: ubuntu-latest steps: @@ -27,11 +59,6 @@ jobs: - uses: actions/checkout@v4 - name: Check kernel count in base metal is less than maximum run: if (( $(find tt_metal/kernels/ -type f | wc -l) > 7 )); then exit 1; fi - check-black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: psf/black@23.10.1 check-doc: runs-on: ubuntu-latest steps: