| name: pre-commit | |
| on: | |
| workflow_dispatch: | |
| push: | |
| pull_request: | |
| branches: [ master ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.0' | |
| - name: Checkout TinyUSB | |
| uses: actions/checkout@v6 | |
| - name: Get Dependencies | |
| run: | | |
| # pinned: 1.1.0 breaks mock preprocessing on this project ("Failed to read | |
| # _build/test/preprocess/.../raw/*.h for comment stripping"); revisit on next release | |
| gem install ceedling -v 1.0.1 | |
| #cd test/unit-test | |
| #ceedling test:all | |
| # the hil-test, change-impact-test and claude-scripts hooks import test/hil/helper/hil_lock.py, | |
| # which refuses to load without agentrc at the commit get_deps.py pins | |
| - name: Get the board-lock dependency | |
| run: python3 tools/get_deps.py lib/agentrc | |
| # runs --all-files, so the hil-test hook fires here regardless of its `files:` scope | |
| - name: Run pre-commit | |
| uses: pre-commit/action@v3.0.1 | |
| - name: Fuzz | |
| run: | | |
| python3 tools/get_deps.py | |
| cmake -S test/fuzz -B test/fuzz/_build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ | |
| cmake --build test/fuzz/_build --parallel | |
| ctest --test-dir test/fuzz/_build --output-on-failure | |
| pids="" | |
| for d in test/fuzz/device/*/; do | |
| h=$(basename $d) | |
| test/fuzz/_build/$h -max_total_time=10 test/fuzz/_build/corpus/$h > fuzz-$h.log 2>&1 & | |
| pids="$pids $!" | |
| done | |
| rc=0 | |
| for p in $pids; do wait $p || rc=1; done | |
| if [ $rc -ne 0 ]; then cat fuzz-*.log; else tail -n 3 fuzz-*.log; fi | |
| exit $rc |