Skip to content

github: fix verify jobs to always report status #92

github: fix verify jobs to always report status

github: fix verify jobs to always report status #92

Workflow file for this run

name: 'Format Check'
on:
push:
branches:
- 'main'
pull_request:
types:
- opened
- edited
- reopened
- synchronize
branches:
- 'main'
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
jobs:
format-check:
runs-on: ubuntu-latest
strategy:
matrix:
path:
- check: 'cores/arduino/'
exclude: 'cores/arduino/api/'
- check: 'loader/'
exclude: 'loader/llext_exports\.c$'
- check: 'libraries/'
exclude: '(examples|extras|ea_malloc)'
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: false
persist-credentials: false
- name: Check for relevant file changes
id: changes
run: |
if [ "${{ github.event_name }}" == "push" ]; then
# For pushes, compare with previous commit
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
else
# For PRs, compare with base branch
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.sha }})
fi
echo "Changed files:"
echo "$CHANGED_FILES"
if echo "$CHANGED_FILES" | grep -E '\.(c|cpp|h|hpp)$'; then
echo "has_format_files=true" >> $GITHUB_OUTPUT
else
echo "has_format_files=false" >> $GITHUB_OUTPUT
fi
- name: Run clang-format check
if: steps.changes.outputs.has_format_files == 'true'
uses: jidicula/[email protected]
with:
clang-format-version: '19'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
verify-format:
name: verify-format
runs-on: ubuntu-latest
if: always()
needs: format-check
steps:
- name: Check format results
run: |
if [[ "${{ needs.format-check.result }}" == "failure" ||
"${{ needs.format-check.result }}" == "cancelled" ]]; then
echo "Format check failed or was cancelled"
exit 1
else
echo "Format check completed successfully or was skipped"
fi