sca.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. name: Static Code Analysis
  2. on:
  3. - pull_request
  4. - push
  5. jobs:
  6. tests:
  7. strategy:
  8. matrix:
  9. operating-system:
  10. - ubuntu-20.04
  11. php-version:
  12. - 7.4
  13. name: Static Code Analysis
  14. runs-on: ${{ matrix.operating-system }}
  15. steps:
  16. - name: Checkout code
  17. uses: actions/checkout@v2
  18. with:
  19. fetch-depth: 0
  20. - name: Setup PHP
  21. uses: shivammathur/setup-php@v2
  22. with:
  23. php-version: ${{ matrix.php-version }}
  24. - name: Get Composer cache directory
  25. id: composer-cache
  26. run: echo "::set-output name=dir::$(composer config cache-dir)"
  27. - name: Cache dependencies
  28. uses: actions/cache@v2
  29. with:
  30. path: ${{ steps.composer-cache.outputs.dir }}
  31. key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
  32. restore-keys: |
  33. composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
  34. composer-${{ runner.os }}-${{ matrix.php-version }}-
  35. composer-${{ runner.os }}-
  36. composer-
  37. - name: Install dependencies
  38. uses: nick-invision/retry@v2
  39. with:
  40. timeout_minutes: 5
  41. max_attempts: 5
  42. retry_wait_seconds: 30
  43. command: |
  44. composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
  45. - name: Report versions
  46. run: |
  47. composer info -D
  48. - name: Install dev-tools
  49. uses: nick-invision/retry@v2
  50. with:
  51. timeout_minutes: 5
  52. max_attempts: 5
  53. retry_wait_seconds: 30
  54. command: |
  55. ./dev-tools/install.sh
  56. - name: Run checks
  57. run: |
  58. ./dev-tools/check_file_permissions.sh
  59. ./dev-tools/check_trailing_spaces.sh
  60. ./dev-tools/vendor/bin/phpstan analyse
  61. ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file $(realpath .composer-require-checker.json)
  62. composer normalize --dry-run --working-dir=./dev-tools ../composer.json
  63. ./dev-tools/check_shell_scripts.sh
  64. - name: Find changed files (for pull request)
  65. if: ${{ github.event_name == 'pull_request' }}
  66. run: |
  67. git diff origin/$GITHUB_BASE_REF --name-only --diff-filter=ACMRTUXB | grep -E "\.php$" || true
  68. echo 'CHANGED_PHP_FILES<<EOF' >> $GITHUB_ENV
  69. git diff origin/$GITHUB_BASE_REF --name-only --diff-filter=ACMRTUXB | grep -E "\.php$" || true >> $GITHUB_ENV
  70. echo 'EOF' >> $GITHUB_ENV
  71. - name: Find changed files (for push)
  72. if: ${{ github.event_name != 'pull_request' }}
  73. run: |
  74. git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD | grep -E "\.php$" || true
  75. echo 'CHANGED_PHP_FILES<<EOF' >> $GITHUB_ENV
  76. git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD | grep -E "\.php$" || true >> $GITHUB_ENV
  77. echo 'EOF' >> $GITHUB_ENV
  78. - name: Validate changed files
  79. if: ${{ github.env.CHANGED_PHP_FILES }}
  80. run: |
  81. ./dev-tools/vendor/bin/phpmd `echo "$CHANGED_PHP_FILES" | xargs | sed 's/ /,/g'` text phpmd.xml
  82. - name: Check for unknown files (to be removed in 3.0)
  83. run: |
  84. # @TODO remove at 3.0
  85. git archive -o /dev/null HEAD -v 2>&1 | grep tests | grep \.php |
  86. grep -v tests/Test/AbstractFixerTestCase.php |
  87. grep -v tests/Test/AbstractIntegrationCaseFactory.php |
  88. grep -v tests/Test/AbstractIntegrationTestCase.php |
  89. grep -v tests/Test/Assert/AssertTokensTrait.php |
  90. grep -v tests/Test/IntegrationCase.php |
  91. grep -v tests/Test/IntegrationCaseFactory.php |
  92. grep -v tests/Test/IntegrationCaseFactoryInterface.php |
  93. grep -v tests/Test/InternalIntegrationCaseFactory.php |
  94. grep -v tests/Test/IsIdenticalConstraint.php |
  95. grep -v tests/TestCase.php \
  96. && (echo "UNKNOWN FILES DETECTED" && exit 1) || echo "NO UNKNOWN FILES"