Skip to content

Commit 7ec9916

Browse files
Fix GitHub Actions output format error for multiline file lists
1 parent 06edbaa commit 7ec9916

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

.github/workflows/lint_pr.yml

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v3
1111
with:
12-
fetch-depth: 0 # To get all history for git diff commands
13-
12+
fetch-depth: 0 # To get all history for git diff commands
13+
1414
- name: Get changed Python files
1515
id: changed-files
1616
run: |
@@ -31,7 +31,7 @@ jobs:
3131
CHANGED_FILES="$CHANGED_FILES $SETUP_PY_CHANGED"
3232
fi
3333
fi
34-
34+
3535
# Check if any Python files were changed and set the output accordingly
3636
if [ -z "$CHANGED_FILES" ]; then
3737
echo "No Python files changed"
@@ -40,9 +40,11 @@ jobs:
4040
else
4141
echo "Changed Python files: $CHANGED_FILES"
4242
echo "has_python_changes=true" >> $GITHUB_OUTPUT
43-
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT
43+
# Use proper delimiter formatting for GitHub Actions
44+
FILES_SINGLE_LINE=$(echo "$CHANGED_FILES" | tr '\n' ' ' | sed 's/[[:space:]]\+/ /g' | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')
45+
echo "files=$FILES_SINGLE_LINE" >> $GITHUB_OUTPUT
4446
fi
45-
47+
4648
- name: PR information
4749
if: ${{ github.event_name == 'pull_request' }}
4850
run: |
@@ -68,35 +70,35 @@ jobs:
6870
echo "No Python files were changed. Skipping linting."
6971
exit 0
7072
fi
71-
73+
7274
- uses: actions/checkout@v3
7375
with:
7476
fetch-depth: 0
75-
77+
7678
- uses: actions/setup-python@v4
7779
with:
7880
python-version: 3.12
79-
81+
8082
- uses: actions/cache@v3
8183
with:
8284
path: ~/.cache/pip
8385
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
8486
restore-keys: |
8587
${{ runner.os }}-pip-
86-
88+
8789
- name: Install dependencies
8890
run: |
8991
python -m pip install --upgrade pip
9092
pip install -r requirements-dev.txt
91-
93+
9294
# Flake8 linting
9395
- name: Lint with flake8
9496
if: ${{ matrix.tool == 'flake8' }}
9597
id: flake8
9698
run: |
9799
echo "Linting files: ${{ needs.check_changes.outputs.files }}"
98100
flake8 ${{ needs.check_changes.outputs.files }} --count --show-source --statistics
99-
101+
100102
# Format checking with isort and black
101103
- name: Format check
102104
if: ${{ matrix.tool == 'format' }}
@@ -106,27 +108,27 @@ jobs:
106108
isort --profile black --check ${{ needs.check_changes.outputs.files }}
107109
echo "Checking format with black for: ${{ needs.check_changes.outputs.files }}"
108110
black --check ${{ needs.check_changes.outputs.files }}
109-
111+
110112
# Type checking with mypy
111113
- name: Type check with mypy
112114
if: ${{ matrix.tool == 'mypy' }}
113115
id: mypy
114116
run: |
115117
echo "Type checking: ${{ needs.check_changes.outputs.files }}"
116118
mypy --ignore-missing-imports ${{ needs.check_changes.outputs.files }}
117-
119+
118120
# Run tests with pytest
119121
- name: Run tests with pytest
120122
if: ${{ matrix.tool == 'pytest' }}
121123
id: pytest
122124
run: |
123125
echo "Running pytest discovery..."
124126
python -m pytest --collect-only -v
125-
127+
126128
# First run any test files that correspond to changed files
127129
echo "Running tests for changed files..."
128130
changed_files="${{ needs.check_changes.outputs.files }}"
129-
131+
130132
# Extract module paths from changed files
131133
modules=()
132134
for file in $changed_files; do
@@ -137,13 +139,13 @@ jobs:
137139
modules+=("$module_path")
138140
fi
139141
done
140-
142+
141143
# Run tests for each module
142144
for module in "${modules[@]}"; do
143145
echo "Testing module: $module"
144146
python -m pytest -xvs tests/ -k "$module" || true
145147
done
146-
148+
147149
# Then run doctests on the changed files
148150
echo "Running doctests for changed files..."
149151
for file in $changed_files; do
@@ -152,26 +154,26 @@ jobs:
152154
python -m pytest --doctest-modules -v $file || true
153155
fi
154156
done
155-
157+
156158
# Check Python version compatibility
157159
- name: Check Python version compatibility
158160
if: ${{ matrix.tool == 'pyupgrade' }}
159161
id: pyupgrade
160162
run: pyupgrade --py312-plus ${{ needs.check_changes.outputs.files }}
161-
163+
162164
# Run tox
163165
- name: Run tox
164166
if: ${{ matrix.tool == 'tox' }}
165167
id: tox
166168
run: |
167169
echo "Running tox integration for changed files..."
168170
changed_files="${{ needs.check_changes.outputs.files }}"
169-
171+
170172
# Create a temporary tox configuration that extends the original one
171173
echo "[tox]" > tox_pr.ini
172174
echo "envlist = py312" >> tox_pr.ini
173175
echo "skip_missing_interpreters = true" >> tox_pr.ini
174-
176+
175177
echo "[testenv]" >> tox_pr.ini
176178
echo "setenv =" >> tox_pr.ini
177179
echo " COVERAGE_FILE = .coverage.{envname}" >> tox_pr.ini
@@ -182,24 +184,24 @@ jobs:
182184
echo " coverage" >> tox_pr.ini
183185
echo " python" >> tox_pr.ini
184186
echo "commands =" >> tox_pr.ini
185-
187+
186188
# Check if we have any implementation files that changed
187189
pattern_files=0
188190
test_files=0
189-
191+
190192
for file in $changed_files; do
191193
if [[ $file == patterns/* ]]; then
192194
pattern_files=1
193195
elif [[ $file == tests/* ]]; then
194196
test_files=1
195197
fi
196198
done
197-
199+
198200
# Only run targeted tests, no baseline
199201
echo " # Run specific tests for changed files" >> tox_pr.ini
200-
202+
201203
has_tests=false
202-
204+
203205
# Add coverage-focused test commands
204206
for file in $changed_files; do
205207
if [[ $file == *.py ]]; then
@@ -246,18 +248,18 @@ jobs:
246248
fi
247249
fi
248250
done
249-
251+
250252
# If we didn't find any specific tests to run, mention it
251253
if [ "$has_tests" = false ]; then
252254
echo " python -c \"print('No specific tests found for changed files. Consider adding tests.')\"" >> tox_pr.ini
253255
# Add a minimal test to avoid failure, but ensure it generates coverage data
254256
echo " coverage run -m pytest -xvs --cov=patterns --cov-append -k \"not integration\" --no-header" >> tox_pr.ini
255257
fi
256-
258+
257259
# Add coverage report command
258260
echo " coverage combine" >> tox_pr.ini
259261
echo " coverage report -m" >> tox_pr.ini
260-
262+
261263
# Run tox with the custom configuration
262264
echo "Running tox with custom PR configuration..."
263265
echo "======================== TOX CONFIG ========================"
@@ -272,7 +274,7 @@ jobs:
272274
runs-on: ubuntu-24.04
273275
steps:
274276
- uses: actions/checkout@v3
275-
277+
276278
- name: Summarize results
277279
run: |
278280
echo "## Pull Request Lint Results" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)