Skip to content

Commit 038a50e

Browse files
committed
fix: Add pre-commit to circle ci pipeline
Signed-off-by: Cagri Yonca <cagri@ibm.com>
1 parent 0a0dc38 commit 038a50e

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

.circleci/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ commands:
2424
circleci step halt
2525
}
2626
27+
run-precommit-on-changed-files:
28+
steps:
29+
- run:
30+
name: Run pre-commit on changed files
31+
command: |
32+
# Main branch'te tüm dosyaları kontrol et
33+
if [ "${CIRCLE_BRANCH}" = "main" ]; then
34+
echo "On main branch - checking all files"
35+
pip install pre-commit
36+
pre-commit run --all-files
37+
exit 0
38+
fi
39+
40+
# Fetch branches
41+
git fetch origin
42+
43+
# Değişen Python ve Markdown dosyalarını bul
44+
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/main...HEAD | grep -E '\.(py|md)$' || true)
45+
46+
if [ -z "$CHANGED_FILES" ]; then
47+
echo "No Python or Markdown files changed. Skipping pre-commit."
48+
exit 0
49+
fi
50+
51+
echo "Changed files:"
52+
echo "$CHANGED_FILES"
53+
54+
# Pre-commit'i sadece değişen dosyalar için çalıştır
55+
pip install pre-commit
56+
echo "$CHANGED_FILES" | xargs pre-commit run --files
57+
2758
pip-install-deps:
2859
steps:
2960
- run:
@@ -155,6 +186,11 @@ jobs:
155186
steps:
156187
- checkout
157188
- check-if-tests-needed
189+
- when:
190+
condition:
191+
equal: [ "3.13", << parameters.py-version >> ]
192+
steps:
193+
- run-precommit-on-changed-files
158194
- pip-install-deps
159195
- pip-install-tests-deps
160196
- run-tests-with-coverage-report

0 commit comments

Comments
 (0)