format-check.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Check format
  2. on:
  3. push:
  4. workflow_dispatch:
  5. jobs:
  6. build:
  7. runs-on: ubuntu-22.04
  8. steps:
  9. - name: Install OS dependencies (needed for act on ubuntu-latest)
  10. run: |
  11. sudo apt update
  12. sudo apt install -y --force-yes curl xz-utils libicu-dev git dos2unix libncurses5
  13. - uses: actions/checkout@v3
  14. - name: Cache Clang
  15. id: cache-clang
  16. uses: actions/cache@v3
  17. with:
  18. path: clang
  19. key: ${{ runner.os }}-clang-13-0-1
  20. - name: Install Clang
  21. if: steps.cache-clang.outputs.cache-hit != 'true'
  22. run: |
  23. curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.1/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz --output clang.tar.xz
  24. tar -xf clang.tar.xz
  25. mv clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04 clang
  26. - name: Install dotnet
  27. uses: actions/setup-dotnet@v3
  28. with:
  29. dotnet-version: "6.0.x"
  30. - run: dotnet tool install -g dotnet-format
  31. - name: Install Node and dependenceis
  32. uses: actions/setup-node@v3
  33. with:
  34. node-version: "16"
  35. - run: npm install -g typescript typescript-formatter
  36. - name: Install JDK
  37. uses: actions/setup-java@v3
  38. with:
  39. distribution: 'zulu'
  40. java-version: "16"
  41. - name: Format
  42. run: |
  43. export CLANGFORMAT=`pwd`/clang/bin/clang-format
  44. export PATH="$PATH:/root/.dotnet/tools"
  45. dotnet-format --version
  46. ./formatters/format.sh
  47. find . -type f -name '*.cs' -exec perl -pi -e 's/\r\n/\n/g' '{}' +
  48. git diff
  49. git diff > format-diff.txt
  50. - name: Archive formatting result
  51. uses: actions/upload-artifact@v4
  52. with:
  53. name: format-diff
  54. path: format-diff.txt
  55. - name: Fail on format changes
  56. run: |
  57. git ls-files -m
  58. if [[ `git ls-files -m` ]]; then echo "Detected formatting errors!" & exit 1; fi