@@ -85,6 +85,10 @@ inputs:
8585 run_python_build :
8686 default : true
8787 required : false
88+ auto_fix_lint :
89+ description : " automatically fix linting errors when possible and commit changes"
90+ default : false
91+ required : false
8892
8993runs :
9094 using : " composite"
@@ -161,6 +165,33 @@ runs:
161165 run : |
162166 # Run node and python in parallel
163167
168+ # Function to setup git for committing fixes
169+ setup_git_for_fixes() {
170+ git config --global user.name "github-actions[bot]"
171+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
172+ }
173+
174+ # Function to commit lint fixes
175+ commit_lint_fixes() {
176+ local changes_made="$1"
177+ if [ "$changes_made" = "true" ]; then
178+ if git diff --quiet && git diff --cached --quiet; then
179+ echo "No changes to commit after running fixes"
180+ return 0
181+ fi
182+
183+ echo "Committing lint fixes..."
184+ git add .
185+ if git diff --cached --quiet; then
186+ echo "No staged changes to commit"
187+ return 0
188+ fi
189+ git commit -m "Auto-fix: Apply linting and formatting fixes [skip ci]" || true
190+ git push || true
191+ echo "✓ Lint fixes committed and pushed"
192+ fi
193+ }
194+
164195 # Define the node sequence of commands
165196 node_job() {
166197 set -e
@@ -172,10 +203,34 @@ runs:
172203 }
173204 done
174205
175- parallel_jobs=()
206+ # Handle node linting with auto-fix capability
176207 if [ "$RUN_NODE_LINT" = "true" ]; then
177- parallel_jobs+=("yarn run lint --quiet")
208+ echo "Running node lint..."
209+ if ! yarn run lint --quiet; then
210+ if [ "$AUTO_FIX_LINT" = "true" ]; then
211+ echo "Node lint failed. Attempting to auto-fix..."
212+ setup_git_for_fixes
213+ yarn run lint:fix || echo "Warning: yarn lint:fix command failed or not available"
214+
215+ echo "Re-running node lint after fixes..."
216+ if yarn run lint --quiet; then
217+ echo "✓ Node lint passed after auto-fix"
218+ commit_lint_fixes "true"
219+ else
220+ echo "✗ Node lint still failing after auto-fix"
221+ exit 1
222+ fi
223+ else
224+ echo "✗ Node lint failed and auto-fix is disabled"
225+ exit 1
226+ fi
227+ else
228+ echo "✓ Node lint passed"
229+ fi
178230 fi
231+
232+ # Run other node tasks
233+ parallel_jobs=()
179234 if [ "$RUN_NODE_TEST" = "true" ]; then
180235 parallel_jobs+=("yarn run test")
181236 fi
@@ -189,31 +244,61 @@ runs:
189244 parallel_jobs+=("yarn playwright install --with-deps chromium")
190245 fi
191246
192- parallel --jobs $1 --lb --halt-on-error 2 --verbose ::: "${parallel_jobs[@]}"
247+ if [ ${#parallel_jobs[@]} -gt 0 ]; then
248+ parallel --jobs $1 --lb --halt-on-error 2 --verbose ::: "${parallel_jobs[@]}"
249+ fi
193250 }
194251
195252 # Define the python sequence of commands
196253 python_job() {
197254 set -e
198255 make develop
199256
200- parallel_jobs=()
257+ # Handle python linting with auto-fix capability
201258 if [ "$RUN_PYTHON_LINT" = "true" ]; then
202- parallel_jobs+=("make lint check-format")
259+ echo "Running python lint..."
260+ if ! make lint check-format; then
261+ if [ "$AUTO_FIX_LINT" = "true" ]; then
262+ echo "Python lint failed. Attempting to auto-fix..."
263+ setup_git_for_fixes
264+ make format || echo "Warning: make format command failed or not available"
265+
266+ echo "Re-running python lint after fixes..."
267+ if make lint check-format; then
268+ echo "✓ Python lint passed after auto-fix"
269+ commit_lint_fixes "true"
270+ else
271+ echo "✗ Python lint still failing after auto-fix"
272+ exit 1
273+ fi
274+ else
275+ echo "✗ Python lint failed and auto-fix is disabled"
276+ exit 1
277+ fi
278+ else
279+ echo "✓ Python lint passed"
280+ fi
203281 fi
282+
283+ # Run other python tasks
284+ parallel_jobs=()
204285 if [ "$RUN_PYTHON_TEST" = "true" ]; then
205286 parallel_jobs+=("make test")
206287 fi
207288 if [ "$RUN_PYTHON_BUILD" = "true" ]; then
208289 parallel_jobs+=("make build")
209290 fi
210291
211- parallel --jobs $1 --lb --halt-on-error 2 --verbose ::: "${parallel_jobs[@]}"
292+ if [ ${#parallel_jobs[@]} -gt 0 ]; then
293+ parallel --jobs $1 --lb --halt-on-error 2 --verbose ::: "${parallel_jobs[@]}"
294+ fi
212295 }
213296
214297 # Export the functions so they can be used by GNU parallel
215298 export -f node_job
216299 export -f python_job
300+ export -f setup_git_for_fixes
301+ export -f commit_lint_fixes
217302
218303 # If RUN_PARALLEL is set, set --jobs to 0, otherwise to 1
219304 N_JOBS=1
@@ -243,6 +328,7 @@ runs:
243328 RUN_PYTHON_LINT : ${{ inputs.run_python_lint }}
244329 RUN_PYTHON_TEST : ${{ inputs.run_python_test }}
245330 RUN_PYTHON_BUILD : ${{ inputs.run_python_build }}
331+ AUTO_FIX_LINT : ${{ inputs.auto_fix_lint }}
246332 # Node
247333 - name : Save yarn cache
248334 uses : actions/cache/save@v4
0 commit comments