forked from google/adk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (48 loc) · 1.46 KB
/
pyink.yml
File metadata and controls
55 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Check Pyink Formatting
on:
pull_request:
paths:
- '**.py'
- 'pyproject.toml'
jobs:
pyink-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install pyink
run: |
pip install pyink
- name: Run pyink on changed files
id: run_pyink
run: |
git fetch origin ${GITHUB_BASE_REF}
CHANGED_FILES=$(git diff --diff-filter=ACMR --name-only origin/${GITHUB_BASE_REF}...HEAD | grep -E '\.py$' || true)
if [ -n "$CHANGED_FILES" ]; then
echo "Changed Python files:"
echo "$CHANGED_FILES"
echo ""
FORMATTED_FILES=$(echo "$CHANGED_FILES" | tr '\n' ' ')
# Run pyink --check
set +e
pyink --check --diff --config pyproject.toml $CHANGED_FILES
RESULT=$?
set -e
if [ $RESULT -ne 0 ]; then
echo ""
echo "❌ Pyink formatting check failed!"
echo "👉 To fix formatting, run locally:"
echo ""
echo " pyink --config pyproject.toml $FORMATTED_FILES"
echo ""
exit $RESULT
fi
else
echo "No Python files changed. Skipping pyink check."
fi