|
| 1 | +name: 'Static code analysis and tests' |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: code-analysis-and-tests-${{ github.ref_name }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: ['push', 'pull_request', 'workflow_dispatch'] |
| 8 | + |
| 9 | +env: |
| 10 | + CLAMAV_SOCKET: '/tmp/clamd.socket' |
| 11 | + CLAMAV_HOST: 127.0.0.1 |
| 12 | + CLAMAV_PORT: 3310 |
| 13 | + |
| 14 | +jobs: |
| 15 | + static_code_analysis: |
| 16 | + runs-on: 'ubuntu-22.04' |
| 17 | + name: 'Static code analysis' |
| 18 | + steps: |
| 19 | + - name: 'Setup PHP' |
| 20 | + uses: shivammathur/setup-php@v2 |
| 21 | + with: |
| 22 | + php-version: '8.2' |
| 23 | + |
| 24 | + - name: 'Checkout' |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: 'Validate composer.json and composer.lock' |
| 28 | + run: composer validate |
| 29 | + |
| 30 | + - name: 'Install dependencies with Composer' |
| 31 | + uses: ramsey/composer-install@v3 |
| 32 | + with: |
| 33 | + dependency-versions: 'highest' |
| 34 | + composer-options: '--prefer-dist' |
| 35 | + |
| 36 | + - name: 'Check PHP coding standards' |
| 37 | + run: php vendor/bin/phpcs -np --standard=PSR2 --ignore=vendor/,tests/,var/ ./ |
| 38 | + |
| 39 | + phpunit: |
| 40 | + needs: [ static_code_analysis ] |
| 41 | + runs-on: 'ubuntu-22.04' |
| 42 | + name: 'PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}' |
| 43 | + timeout-minutes: 30 |
| 44 | + continue-on-error: true |
| 45 | + strategy: |
| 46 | + matrix: |
| 47 | + php: ['7.3', '8.1', '8.2', '8.3'] |
| 48 | + symfony: ['~5.0', '~6.0', '~7.0'] |
| 49 | + dependencies: |
| 50 | + - 'highest' |
| 51 | + exclude: |
| 52 | + - php: '7.3' |
| 53 | + symfony: '~6.0' |
| 54 | + - php: '7.3' |
| 55 | + symfony: '~7.0' |
| 56 | + - php: '8.1' |
| 57 | + symfony: '~7.0' |
| 58 | + fail-fast: false |
| 59 | + steps: |
| 60 | + - name: 'Start ClamAV daemon (clamd)' |
| 61 | + |
| 62 | + with: |
| 63 | + unix_socket: $CLAMAV_SOCKET |
| 64 | + tcp_port: $CLAMAV_PORT |
| 65 | + stream_max_length: 1M |
| 66 | + db_main: true |
| 67 | + db_daily: true |
| 68 | + |
| 69 | + - name: 'Ping clamd on TCP port $CLAMAV_PORT' |
| 70 | + run: echo PING | nc $CLAMAV_HOST $CLAMAV_PORT |
| 71 | + |
| 72 | + - name: 'Ping clamd using the Unix socket' |
| 73 | + run: echo PING | nc -U $CLAMAV_SOCKET |
| 74 | + |
| 75 | + - name: 'Checkout' |
| 76 | + uses: actions/checkout@v4 |
| 77 | + |
| 78 | + - name: 'Setup PHP' |
| 79 | + uses: shivammathur/setup-php@v2 |
| 80 | + with: |
| 81 | + php-version: '${{ matrix.php }}' |
| 82 | + coverage: 'pcov' |
| 83 | + tools: 'composer:v2' |
| 84 | + extensions: 'sockets' |
| 85 | + |
| 86 | + - name: 'Fix symfony/framework-bundle version' |
| 87 | + run: composer require --no-update symfony/framework-bundle:${{ matrix.symfony }} |
| 88 | + |
| 89 | + - name: 'Install dependencies with Composer' |
| 90 | + uses: ramsey/composer-install@v3 |
| 91 | + with: |
| 92 | + dependency-versions: '${{ matrix.dependencies }}' |
| 93 | + composer-options: '--prefer-dist' |
| 94 | + |
| 95 | + - name: 'Dump composer autoloader' |
| 96 | + run: composer dump-autoload --classmap-authoritative --no-ansi --no-interaction --no-scripts |
| 97 | + |
| 98 | + - name: 'Run phpunit tests' |
| 99 | + run: | |
| 100 | + vendor/bin/phpunit --coverage-clover=tests/build/clover.xml 2>/dev/null |
| 101 | +
|
| 102 | + - name: 'Upload coverage results to Coveralls' |
| 103 | + env: |
| 104 | + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} |
| 105 | + run: | |
| 106 | + vendor/bin/php-coveralls --coverage_clover=tests/build/clover.xml --json_path=tests/build/coveralls.json -v |
0 commit comments