lint.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. push:
  19. branches:
  20. - master
  21. tags:
  22. - '*'
  23. paths:
  24. - 'src/**'
  25. pull_request:
  26. paths:
  27. - 'src/**'
  28. jobs:
  29. lint_cppcheck:
  30. runs-on: ubuntu-latest
  31. steps:
  32. - uses: actions/checkout@v3
  33. # The apt version of Cppcheck is outdated and apparently there are no
  34. # alternative up-to-date precompiled versions for Ubuntu,
  35. # so we compile it ourselves here.
  36. - name: Install Cppcheck
  37. run: |
  38. sudo apt-get update
  39. sudo apt-get install g++ make
  40. RELEASE_API_URL="https://api.github.com/repos/danmar/cppcheck/releases/latest"
  41. TARBALL_URL=$(curl --silent "$RELEASE_API_URL" | jq --raw-output '.tarball_url')
  42. curl --location --silent "$TARBALL_URL" | tar --extract --gzip --file=-
  43. cd danmar-cppcheck-*/
  44. make -j"$(nproc)" CXXFLAGS="-O1 -DNDEBUG"
  45. - name: Lint code with Cppcheck
  46. run: |
  47. ./danmar-cppcheck-*/cppcheck \
  48. --quiet --inline-suppr --language=c++ --error-exitcode=10 \
  49. -j"$(nproc)" --std=c++14 --enable=warning,style \
  50. --suppress=useStlAlgorithm src/