Merge pull request #14 from Fantaskink/linter #28
This file contains 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: Replace primitive types with fixed-width types | |
on: [push, pull_request] | |
jobs: | |
lint-format-replace: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install clang-format | |
run: sudo apt-get install clang-format | |
- name: Run clang-format | |
run: | | |
find src -name '*.c' -o -name '*.h' | xargs clang-format -i --style=file | |
- name: Replace primitive types with fixed-width types | |
run: | | |
find . -name '*.c' | xargs sed -i 's/\bunsigned long\b/u64/g' | |
find . -name '*.c' | xargs sed -i 's/\blong\b/s64/g' | |
find . -name '*.c' | xargs sed -i 's/\bunsigned int\b/u32/g' | |
find . -name '*.c' | xargs sed -i 's/\bint\b/s32/g' | |
find . -name '*.c' | xargs sed -i 's/\bunsigned short\b/u16/g' | |
find . -name '*.c' | xargs sed -i 's/\bshort\b/s16/g' | |
- name: Check if any files were changed | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git diff --exit-code || (git add . && git commit -m "Replace primitives types with fixed-width types and format files" && git push) |