1name: BOM Check 2 3on: 4 push: 5 pull_request: 6 7# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency 8# Ensure that only one commit will be running tests at a time on each PR 9concurrency: 10 group: ${{ github.ref }}-${{ github.workflow }} 11 cancel-in-progress: true 12 13jobs: 14 bom-check: 15 if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} 16 runs-on: ubuntu-22.04 17 steps: 18 - name: Checkout 19 uses: actions/checkout@v4 20 with: 21 persist-credentials: false 22 fetch-depth: 0 23 24 - name: UTF-8 BOM 25 run: | 26 grep -oarlE -m 1 --include="*.c" --include="*.h" --include="*.rst" --include="*.txt" --include="*.mk" --include="*.py" --include="*.cmake" --include="Makefile" $'\xEF\xBB\xBF' . | while read -r line; do 27 a=$(head -c 3 "$line") 28 if [ "${a}" = $'\xEF\xBB\xBF' ]; then 29 echo "${line}" && exit 1 30 fi 31 done 32 33 - name: UTF-16LE BOM 34 run: | 35 grep -oarlE -m 1 --include="*.c" --include="*.h" --include="*.rst" --include="*.txt" --include="*.mk" --include="*.py" --include="*.cmake" --include="Makefile" $'\xFF\xFE' . | while read -r line; do 36 a=$(head -c 3 "$line") 37 if [ "${a}" = $'\xFF\xFE' ]; then 38 echo "${line}" && exit 1 39 fi 40 done 41 42 - name: UTF-16BE BOM 43 run: | 44 grep -oarlE -m 1 --include="*.c" --include="*.h" --include="*.rst" --include="*.txt" --include="*.mk" --include="*.py" --include="*.cmake" --include="Makefile" $'\xFE\xFF' . | while read -r line; do 45 a=$(head -c 3 "$line") 46 if [ "${a}" = $'\xFE\xFF' ]; then 47 echo "${line}" && exit 1 48 fi 49 done 50