format-check.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Check format
  2. on:
  3. push:
  4. jobs:
  5. build:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - run: git config --global core.autocrlf false
  9. - uses: actions/checkout@v1
  10. - name: Install OS dependencies (needed for act on ubuntu-latest)
  11. run: |
  12. sudo apt update
  13. sudo apt install -y --force-yes curl xz-utils libicu-dev git
  14. - name: Cache Clang
  15. id: cache-clang
  16. uses: actions/cache@v2
  17. with:
  18. path: clang
  19. key: ${{ runner.os }}-clang
  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-12.0.1/clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz --output clang.tar.xz
  24. tar -xf clang.tar.xz
  25. mv clang+llvm-12.0.1-x86_64-linux-gnu-ubuntu- clang
  26. - name: Install dotnet
  27. uses: actions/setup-dotnet@v1
  28. with:
  29. dotnet-version: "6.0.x"
  30. include-prerelease: true
  31. - run: dotnet tool install -g dotnet-format
  32. - name: Install Node and dependenceis
  33. uses: actions/setup-node@v1
  34. with:
  35. node-version: "16"
  36. - run: npm install -g typescript typescript-formatter
  37. - name: Install JDK
  38. uses: actions/setup-java@v2
  39. with:
  40. distribution: 'zulu'
  41. java-version: "16"
  42. - name: Format
  43. run: |
  44. export CLANGFORMAT=`pwd`/clang/bin/clang-format
  45. export PATH="$PATH:/root/.dotnet/tools"
  46. ./formatters/format.sh
  47. git diff
  48. git diff > format-diff.txt
  49. - name: Archive formatting result
  50. uses: actions/upload-artifact@v2
  51. with:
  52. name: format-diff
  53. path: format-diff.txt
  54. - name: Fail on format changes
  55. run: |
  56. git ls-files -m
  57. if [[ `git ls-files -m` ]]; then echo "Detected formatting errors!" & exit 1; fi