Skip to content

Commit 04d0290

Browse files
committed
fix: doc test changed files detection
doc test incorrectly detects changes file for PR in merge queue. This fix utilize tj-actions/changed-files to correctly detect changes files in various states of PR Assisted-By: claude Signed-off-by: Jindrich Luza <jluza@redhat.com>
1 parent e0afd43 commit 04d0290

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

.github/workflows/python.yaml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,19 @@ jobs:
4040
export PATH="$HOME/.local/bin:$PATH"
4141
uv sync --dev
4242
uv run pytest --cov=. --cov-report=xml:coverage.xml
43+
- name: Get changed Python files
44+
id: changed-files
45+
uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c # v45
46+
with:
47+
files: |
48+
**/*.py
4349
- name: docstring test
50+
if: steps.changed-files.outputs.any_changed == 'true'
4451
run: |
45-
# Get list of changed python files
4652
pip install ruff
47-
FILES=$(gh pr view ${{ github.event.pull_request.number }} --json files --jq '.files.[].path')
48-
PYFILES=""
49-
for _file in ${FILES}; do
50-
echo "Checking file : $_file"
51-
if [[ $(file --mime-type "$_file" | cut -d" " -f 2) == "text/x-script.python" ]]; then
52-
PYFILES="$PYFILES $_file "
53-
else
54-
echo "Skipping non-python file: $_file"
55-
fi
56-
done
57-
if [ -z "$PYFILES" ]; then
58-
echo "No Python files changed."
59-
else
60-
echo "Running ruff on: $PYFILES"
61-
ruff check --select D ${PYFILES}
62-
fi
53+
echo "Running ruff on changed Python files:"
54+
echo "${{ steps.changed-files.outputs.all_changed_files }}"
55+
ruff check --select D ${{ steps.changed-files.outputs.all_changed_files }}
6356
- name: Upload coverage to Codecov
6457
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6
6558
with:

0 commit comments

Comments
 (0)