diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index dbf8ce8..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,3 +0,0 @@ -coverage_clover: tests/build/clover.xml -service_name: travis-ci -json_path: tests/build/coveralls.json diff --git a/.github/workflows/code_style_and_tests.yml b/.github/workflows/code_style_and_tests.yml new file mode 100644 index 0000000..704d262 --- /dev/null +++ b/.github/workflows/code_style_and_tests.yml @@ -0,0 +1,106 @@ +name: 'Static code analysis and tests' + +concurrency: + group: code-analysis-and-tests-${{ github.ref_name }} + cancel-in-progress: true + +on: ['push', 'pull_request', 'workflow_dispatch'] + +env: + CLAMAV_SOCKET: '/tmp/clamd.socket' + CLAMAV_HOST: 127.0.0.1 + CLAMAV_PORT: 3310 + +jobs: + static_code_analysis: + runs-on: 'ubuntu-22.04' + name: 'Static code analysis' + steps: + - name: 'Setup PHP' + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Validate composer.json and composer.lock' + run: composer validate + + - name: 'Install dependencies with Composer' + uses: ramsey/composer-install@v3 + with: + dependency-versions: 'highest' + composer-options: '--prefer-dist' + + - name: 'Check PHP coding standards' + run: php vendor/bin/phpcs -np --standard=PSR2 --ignore=vendor/,tests/,var/ ./ + + phpunit: + needs: [ static_code_analysis ] + runs-on: 'ubuntu-22.04' + name: 'PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}' + timeout-minutes: 30 + continue-on-error: true + strategy: + matrix: + php: ['7.3', '8.1', '8.2', '8.3'] + symfony: ['~5.0', '~6.0', '~7.0'] + dependencies: + - 'highest' + exclude: + - php: '7.3' + symfony: '~6.0' + - php: '7.3' + symfony: '~7.0' + - php: '8.1' + symfony: '~7.0' + fail-fast: false + steps: + - name: 'Start ClamAV daemon (clamd)' + uses: toblux/start-clamd-github-action@v0.2 + with: + unix_socket: $CLAMAV_SOCKET + tcp_port: $CLAMAV_PORT + stream_max_length: 1M + db_main: true + db_daily: true + + - name: 'Ping clamd on TCP port $CLAMAV_PORT' + run: echo PING | nc $CLAMAV_HOST $CLAMAV_PORT + + - name: 'Ping clamd using the Unix socket' + run: echo PING | nc -U $CLAMAV_SOCKET + + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Setup PHP' + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php }}' + coverage: 'pcov' + tools: 'composer:v2' + extensions: 'sockets' + + - name: 'Fix symfony/framework-bundle version' + run: composer require --no-update symfony/framework-bundle:${{ matrix.symfony }} + + - name: 'Install dependencies with Composer' + uses: ramsey/composer-install@v3 + with: + dependency-versions: '${{ matrix.dependencies }}' + composer-options: '--prefer-dist' + + - name: 'Dump composer autoloader' + run: composer dump-autoload --classmap-authoritative --no-ansi --no-interaction --no-scripts + + - name: 'Run phpunit tests' + run: | + vendor/bin/phpunit --coverage-clover=tests/build/clover.xml 2>/dev/null + + - name: 'Upload coverage results to Coveralls' + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + run: | + vendor/bin/php-coveralls --coverage_clover=tests/build/clover.xml --json_path=tests/build/coveralls.json -v diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bb1c85a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -language: php -php: - - '7.3' - - '8.1' - - '8.2' - -env: - global: - - CLAMAV_SOCKET="/var/run/clamav/clamd.ctl" - - CLAMAV_HOST="127.0.0.1" - - CLAMAV_PORT="3310" - jobs: - - SYMFONY_VERSION="~7.0" - - SYMFONY_VERSION="~6.0" - - SYMFONY_VERSION="~5.0" - - SYMFONY_VERSION="~4.0" - -jobs: - exclude: - - env: SYMFONY_VERSION="~6.0" - php: '7.3' - - env: SYMFONY_VERSION="~7.0" - php: '7.3' - - env: SYMFONY_VERSION="~7.0" - php: '8.1' - -before_install: - - sudo apt-get update -qq - - sudo apt-get install -y libclamav-dev clamav clamav-daemon clamav-freshclam - -install: - - composer require --no-update symfony/framework-bundle:${SYMFONY_VERSION} - - composer install --dev --no-interaction - -before_script: - - sudo freshclam - - echo 'TCPAddr 127.0.0.1' | sudo tee -a /etc/clamav/clamd.conf - - echo 'TCPSocket 3310' | sudo tee -a /etc/clamav/clamd.conf - - sudo adduser clamav travis - - sudo /etc/init.d/clamav-daemon start - - wget -q --waitretry=1 --retry-connrefused -T 120 -O - http://${CLAMAV_HOST}:${CLAMAV_PORT} - - export XDEBUG_MODE=coverage - -script: - - vendor/bin/phpunit --coverage-clover=tests/build/clover.xml 2>/dev/null - - vendor/bin/phpcs -np --standard=PSR2 --ignore=vendor/,tests/,var/ ./ - -after_script: - - travis_retry php vendor/bin/php-coveralls -v - -cache: - directories: - - "/var/lib/clamav" - apt: true diff --git a/README.md b/README.md index 594ab71..bae8922 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ This library is a PHP client for working with a ClamAV daemon. It also provides optional Symfony integration. -[![Build Status](https://app.travis-ci.com/sineflow/clamav.svg?branch=master)](https://app.travis-ci.com/github/sineflow/clamav) +![Workflow status](https://github.com/sineflow/clamav/actions/workflows/code_style_and_tests.yml/badge.svg) # Requirements: