lint.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # SuperTux
  2. # Copyright (C) 2022 HybridDog
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. name: Code Linting
  17. on:
  18. workflow_dispatch:
  19. push:
  20. branches:
  21. - master
  22. tags:
  23. - '*'
  24. paths:
  25. - 'src/**'
  26. pull_request:
  27. paths:
  28. - 'src/**'
  29. jobs:
  30. lint_cppcheck:
  31. runs-on: ubuntu-latest
  32. steps:
  33. - uses: actions/checkout@v4
  34. # The apt version of Cppcheck is outdated and apparently there are no
  35. # alternative up-to-date precompiled versions for Ubuntu,
  36. # so we compile it ourselves here.
  37. - name: Install Cppcheck
  38. run: |
  39. sudo apt-get update
  40. sudo apt-get install g++ make
  41. RELEASE_API_URL="https://api.github.com/repos/danmar/cppcheck/releases/latest"
  42. TARBALL_URL=$(curl --silent "$RELEASE_API_URL" | jq --raw-output '.tarball_url')
  43. curl --location --silent "$TARBALL_URL" | tar --extract --gzip --file=-
  44. cd danmar-cppcheck-*/
  45. make -j"$(nproc)" CXXFLAGS="-O1 -DNDEBUG"
  46. - name: Lint code with Cppcheck
  47. run: |
  48. ./danmar-cppcheck-*/cppcheck \
  49. --check-level=exhaustive \
  50. --quiet --inline-suppr --language=c++ --error-exitcode=10 \
  51. -j"$(nproc)" --std=c++17 --enable=warning,style \
  52. --suppress=useStlAlgorithm src/