Repository navigation
fix(rp2040): do not infer Bluetooth-only Arduino-Pico libraries when Bluetooth is off #2263
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: LOC Gate | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| workflow_dispatch: | |
| # Auto-cancel superseded PR runs: pushing again to a feature branch | |
| # supersedes the in-flight run instead of queueing behind it. Non-PR | |
| # events key on run_id so each gets its own group -- a shared group keeps | |
| # only ONE pending run, which would silently drop queued main SHAs. | |
| concurrency: | |
| group: loc-gate.yml-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| loc-gate: | |
| name: Reject .rs files over 1000 LOC | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check .rs file line counts | |
| shell: bash | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before || '' }} | |
| run: | | |
| set -euo pipefail | |
| THRESHOLD=1000 | |
| ZERO_SHA=0000000000000000000000000000000000000000 | |
| base_ref="${BASE_SHA:-}" | |
| if [[ -n "$base_ref" && "$base_ref" != "$ZERO_SHA" ]]; then | |
| git fetch --no-tags --depth=1 origin "$base_ref" || true | |
| else | |
| base_ref="" | |
| fi | |
| base_line_count() { | |
| local file="$1" | |
| if [[ -z "$base_ref" ]] || ! git cat-file -e "${base_ref}:${file}" 2>/dev/null; then | |
| echo "" | |
| return | |
| fi | |
| git show "${base_ref}:${file}" | wc -l | tr -d ' ' | |
| } | |
| violations=0 | |
| while IFS= read -r -d '' file; do | |
| rel="${file#./}" | |
| lines=$(wc -l < "$file" | tr -d ' ') | |
| if [ "$lines" -gt "$THRESHOLD" ]; then | |
| base_lines="$(base_line_count "$rel")" | |
| if [[ -n "$base_lines" && "$base_lines" -gt "$THRESHOLD" ]]; then | |
| echo "BASELINE ${lines} ${file} (base already has ${base_lines} LOC)" | |
| continue | |
| fi | |
| echo "::error file=${file}::${file} has ${lines} LOC (limit: ${THRESHOLD})" | |
| echo "FAIL ${lines} ${file}" | |
| violations=$((violations + 1)) | |
| fi | |
| done < <(find . \ | |
| \( -path './target' -o -path './.git' \) -prune -o \ | |
| -type f -name '*.rs' -print0) | |
| if [ "$violations" -gt 0 ]; then | |
| echo "" | |
| echo "Found ${violations} new .rs file(s) over ${THRESHOLD} LOC." | |
| echo "Split new large files into smaller modules before merging." | |
| exit 1 | |
| fi | |
| echo "No newly over-limit .rs files found." |