lint-php-cs.yml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
  42. - name: Set up php
  43. uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # v2
  44. with:
  45. php-version: 8.1
  46. coverage: none
  47. ini-file: development
  48. env:
  49. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  50. - name: Install dependencies
  51. run: composer i
  52. - name: Lint
  53. run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
  54. summary:
  55. permissions:
  56. contents: none
  57. runs-on: ubuntu-latest-low
  58. needs: [changes, lint]
  59. if: always()
  60. # This is the summary, we just avoid to rename it so that branch protection rules still match
  61. name: php-cs
  62. steps:
  63. - name: Summary status
  64. run: if ${{ needs.changes.outputs.src != 'false' && needs.lint.result != 'success' }}; then exit 1; fi