diff --git a/.github/workflows/pre_commit_checks.yml b/.github/workflows/pre_commit_checks.yml new file mode 100644 index 0000000..4b32f6a --- /dev/null +++ b/.github/workflows/pre_commit_checks.yml @@ -0,0 +1,45 @@ +name: Pre-commit checks + +on: + pull_request: + push: + branches: + - develop + - main + +jobs: + pre-commit: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' # Adjust this to your desired Python version + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python3 - + + - name: Install dependencies + run: | + poetry install --with dev + + - name: Install pre-commit + run: | + poetry run pip install pre-commit + + - name: Fetch the base branch + run: | + git fetch origin ${GITHUB_BASE_REF}:${GITHUB_BASE_REF} + env: + GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }} + + - name: Run pre-commit on changed files + run: | + poetry run pre-commit run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD + env: + GITHUB_BASE_REF: ${{ github.event.pull_request.base.ref }}