lint-php-cs.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # This workflow is provided via the organization template repository
  2. #
  3. # https://github.com/nextcloud/.github
  4. # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
  5. #
  6. # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
  7. # SPDX-License-Identifier: MIT
  8. name: Lint php-cs
  9. on: pull_request
  10. permissions:
  11. contents: read
  12. concurrency:
  13. group: lint-php-cs-${{ github.head_ref || github.run_id }}
  14. cancel-in-progress: true
  15. jobs:
  16. changes:
  17. runs-on: ubuntu-latest-low
  18. outputs:
  19. src: ${{ steps.changes.outputs.src}}
  20. steps:
  21. - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  22. id: changes
  23. continue-on-error: true
  24. with:
  25. filters: |
  26. src:
  27. - '.github/workflows/**'
  28. - '3rdparty/**'
  29. - '**/lib/**'
  30. - '**/tests/**'
  31. - '**/vendor-bin/**'
  32. - '.php-cs-fixer.dist.php'
  33. - 'composer.json'
  34. - 'composer.lock'
  35. - '**.php'
  36. lint:
  37. runs-on: ubuntu-latest
  38. name: PHP CS fixer lint
  39. steps:
  40. - name: Checkout
  41. uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  42. - name: Set up php8.1
  43. uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 #v2.31.1
  44. with:
  45. php-version: 8.1
  46. extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
  47. coverage: none
  48. ini-file: development
  49. env:
  50. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  51. - name: Install dependencies
  52. run: composer i
  53. - name: Lint
  54. run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
  55. summary:
  56. permissions:
  57. contents: none
  58. runs-on: ubuntu-latest-low
  59. needs: [changes, lint]
  60. if: always()
  61. # This is the summary, we just avoid to rename it so that branch protection rules still match
  62. name: php-cs
  63. steps:
  64. - name: Summary status
  65. run: if ${{ needs.changes.outputs.src != 'false' && needs.lint.result != 'success' }}; then exit 1; fi