123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- name: Static Code Analysis
- on:
- - pull_request
- - push
- jobs:
- tests:
- strategy:
- fail-fast: false
- matrix:
- operating-system:
- - ubuntu-20.04
- php-version:
- - 7.4
- name: Static Code Analysis
- runs-on: ${{ matrix.operating-system }}
- steps:
- - name: Checkout code
- uses: actions/checkout@v2
- with:
- fetch-depth: 0
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-version }}
- - name: Get Composer cache directory
- id: composer-cache
- run: echo "::set-output name=dir::$(composer config cache-dir)"
- - name: Cache dependencies
- uses: actions/cache@v2
- with:
- path: ${{ steps.composer-cache.outputs.dir }}
- key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }}
- restore-keys: |
- composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-
- composer-${{ runner.os }}-${{ matrix.php-version }}-
- composer-${{ runner.os }}-
- composer-
- - name: Install dependencies
- uses: nick-invision/retry@v2
- with:
- timeout_minutes: 5
- max_attempts: 5
- retry_wait_seconds: 30
- command: composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }}
- - name: Report versions
- run: composer info -D
- - name: Install dev-tools
- uses: nick-invision/retry@v2
- with:
- timeout_minutes: 5
- max_attempts: 5
- retry_wait_seconds: 30
- command: ./dev-tools/install.sh
- - name: Check - file permissions
- run: ./dev-tools/check_file_permissions.sh
- - name: Check - trailing spaces
- run: ./dev-tools/check_trailing_spaces.sh
- - name: Check - phpstan
- run: ./dev-tools/vendor/bin/phpstan analyse
- - name: Check - composer-require-checker
- run: ./dev-tools/vendor/bin/composer-require-checker check composer.json --config-file .composer-require-checker.json
- - name: Check - composer normalize
- run: composer normalize --dry-run --working-dir=./dev-tools ../composer.json
- - name: Check - shell scripts
- run: ./dev-tools/check_shell_scripts.sh
- - name: Find changed files (for pull request)
- if: ${{ github.event_name == 'pull_request' }}
- run: |
- git diff origin/$GITHUB_BASE_REF --name-only --diff-filter=ACMRTUXB | grep -E "\.php$" || true
- echo 'CHANGED_PHP_FILES<<EOF' >> $GITHUB_ENV
- git diff origin/$GITHUB_BASE_REF --name-only --diff-filter=ACMRTUXB | grep -E "\.php$" || true >> $GITHUB_ENV
- echo 'EOF' >> $GITHUB_ENV
- - name: Find changed files (for push)
- if: ${{ github.event_name != 'pull_request' }}
- run: |
- git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD | grep -E "\.php$" || true
- echo 'CHANGED_PHP_FILES<<EOF' >> $GITHUB_ENV
- git diff --name-only --diff-filter=ACMRTUXB HEAD~..HEAD | grep -E "\.php$" || true >> $GITHUB_ENV
- echo 'EOF' >> $GITHUB_ENV
- - name: Check - phpmd
- if: ${{ github.env.CHANGED_PHP_FILES }}
- run: ./dev-tools/vendor/bin/phpmd `echo "$CHANGED_PHP_FILES" | xargs | sed 's/ /,/g'` text phpmd.xml
- - name: Check - ensure test files are not present in the archive
- run: |
- git archive -o /dev/null HEAD -v 2>&1 | grep tests | grep \.php \
- && (echo "Test files detected in archive" && exit 1) || echo "No test files detected in archive"
|