From b0992fa53f3c4b34cd3f7f171e6ff92528fc4f87 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Mon, 20 Mar 2023 14:09:33 +0100 Subject: [PATCH] migrated from Travis CI to GitHub Actions --- .gitattributes | 15 +- .../install_dependencies.sh | 11 +- .github/workflows/test.yml | 143 ++++++++++++++++++ .travis.yml | 90 ----------- README.md | 2 +- Tests/config/config.yml | 2 +- Tests/config/config_hacks.php | 16 ++ phpstan-config.neon | 3 - 8 files changed, 173 insertions(+), 109 deletions(-) rename .travis_install_dependencies.sh => .github/install_dependencies.sh (67%) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 0e1189d..afa7855 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,7 @@ -/Tests export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis_install_dependencies.sh export-ignore -/.travis.yml export-ignore -/phpstan-config.neon export-ignore -/phpstan.neon.dist export-ignore -/phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.github export-ignore +/.gitignore export-ignore +/phpstan-config.neon export-ignore +/phpstan.neon.dist export-ignore +/phpunit.xml.dist export-ignore +/Tests export-ignore diff --git a/.travis_install_dependencies.sh b/.github/install_dependencies.sh similarity index 67% rename from .travis_install_dependencies.sh rename to .github/install_dependencies.sh index b3c26ed..ded8d33 100644 --- a/.travis_install_dependencies.sh +++ b/.github/install_dependencies.sh @@ -2,12 +2,6 @@ set -euv -export COMPOSER_NO_INTERACTION=1 -composer self-update - -# install Symfony Flex -composer require --no-progress --no-scripts --no-plugins symfony/flex - case "${DEPS:-}" in 'lowest') COMPOSER_UPDATE_ARGS='--prefer-lowest' @@ -22,6 +16,11 @@ case "${DEPS:-}" in if [ -n "${SYMFONY_VERSION:-}" ]; then composer config extra.symfony.require "${SYMFONY_VERSION}" + # ensure the given version is installed for all components - this is needed at least for (PHP 7.3 + Symfony 4.4) & (PHP 7.4 + Symfony 5.4) + # TODO remove as soon as PHP >= 8 is required + if [ "$(php -r 'echo PHP_MAJOR_VERSION;')" = "7" ]; then + composer require --no-update "symfony/symfony:${SYMFONY_VERSION}" + fi fi esac diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4b0a588 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,143 @@ +name: Tests + +on: + pull_request: ~ + push: ~ + +defaults: + run: + shell: bash + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }} @ ${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + test: + name: "PHP ${{ matrix.php }} - ${{ matrix.DEPS || format('Symfony {0}', matrix.SYMFONY_VERSION) }}${{ (matrix.allow-failure && ' 🔕') || '' }}" + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.allow-failure || false }} + strategy: + fail-fast: false + matrix: + include: + - + php: '7.3' + DEPS: 'lowest' + WITH_DOCTRINE_CACHE_BUNDLE: 'yes' + SYMFONY_DEPRECATIONS_HELPER: 'max[self]=2&max[indirect]=1230' + - + php: '8.2' + DEPS: 'unmodified' + WITH_STATIC_ANALYSIS: 'yes' + - + php: '7.3' + SYMFONY_VERSION: '4.4.*' + WITH_DOCTRINE_CACHE_BUNDLE: 'yes' + SYMFONY_DEPRECATIONS_HELPER: 'max[indirect]=4' + - + php: '7.4' + SYMFONY_VERSION: '5.4.*' + - + php: '8.0' + SYMFONY_VERSION: '5.4.*' + - + php: '8.1' + SYMFONY_VERSION: '5.4.*' + - + php: '8.2' + SYMFONY_VERSION: '6.3.*' + MIN_STABILITY: 'dev' + allow-failure: true + + services: + redis: + image: redis + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: set up MySQL + run: | + sudo systemctl start mysql + echo ' + CREATE DATABASE IF NOT EXISTS test; + DROP USER IF EXISTS "tester"@"localhost"; + CREATE USER "tester"@"localhost" IDENTIFIED WITH mysql_native_password BY ""; + GRANT ALL ON test.* TO "tester"@"localhost"; + FLUSH PRIVILEGES; + ' > /tmp/mysql-init.sql + mysql --user=root --password=root -e 'source /tmp/mysql-init.sql' + + - name: checkout + uses: actions/checkout@v3 + + - name: setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + extensions: mysql, redis + coverage: pcov + ini-values: memory_limit=-1 + tools: flex + env: + fail-fast: true # interrupt on extension setup error + + - name: get Composer's cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: cache Composer's package cache + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.DEPS || format('symfony-{0}', matrix.SYMFONY_VERSION) }} + + - name: install dependencies + run: bash .github/install_dependencies.sh + env: + DEPS: "${{ matrix.DEPS }}" + MIN_STABILITY: "${{ matrix.MIN_STABILITY }}" + SYMFONY_VERSION: "${{ matrix.SYMFONY_VERSION }}" + WITH_DOCTRINE_CACHE_BUNDLE: "${{ matrix.WITH_DOCTRINE_CACHE_BUNDLE }}" + + - name: show installed dependencies + run: composer show + + - name: validate composer.json + if: ${{ matrix.WITH_STATIC_ANALYSIS == 'yes' }} + run: composer validate --strict --no-check-lock + + - name: run PHPStan + if: ${{ matrix.WITH_STATIC_ANALYSIS == 'yes' }} + run: vendor/bin/phpstan analyse + + - name: run PHPUnit + run: | + mkdir -p build/logs + vendor/bin/phpunit -v --coverage-clover build/logs/clover.xml + env: + REDIS_DSN: redis://localhost:6379 + SYMFONY_DEPRECATIONS_HELPER: "${{ matrix.SYMFONY_DEPRECATIONS_HELPER }}" + + - name: upload code coverage data + if: ${{ github.repository == 'craue/CraueConfigBundle' }} + env: + COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + uses: nick-fields/retry@v2 + with: + command: | + PHP_COVERALLS_VERSION=`curl --retry 5 -Is https://github.com/php-coveralls/php-coveralls/releases/latest | grep -i 'Location:' | sed 's/.*\/tag\/\(.*\)$/\1/' | tr -d "[:cntrl:]"` + echo "using php-coveralls '${PHP_COVERALLS_VERSION}'" + wget -q "https://github.com/php-coveralls/php-coveralls/releases/download/${PHP_COVERALLS_VERSION}/php-coveralls.phar" -O php-coveralls.phar + php php-coveralls.phar -v + max_attempts: 3 + timeout_seconds: 10 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index aa40d44..0000000 --- a/.travis.yml +++ /dev/null @@ -1,90 +0,0 @@ -language: php -dist: bionic # https://docs.travis-ci.com/user/reference/overview/#which-one-do-i-use - -stages: - - smoke test 🕵️ - - test - -jobs: - include: - - stage: smoke test 🕵️ - php: 7.3 - env: DEPS='lowest' WITH_DOCTRINE_CACHE_BUNDLE='yes' SYMFONY_DEPRECATIONS_HELPER='max[self]=2&max[indirect]=1230' - - - php: 8.2 - env: DEPS='unmodified' WITH_STATIC_ANALYSIS='yes' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=1' - - - stage: test - php: 7.3 - env: SYMFONY_VERSION='4.4.*' WITH_DOCTRINE_CACHE_BUNDLE='yes' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=5' - - - php: 7.4 - env: SYMFONY_VERSION='5.4.*' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=1' - - - php: 8.0 - env: SYMFONY_VERSION='5.4.*' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=1' - - - php: 8.1 - env: SYMFONY_VERSION='5.4.*' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=1' - - - php: 8.2 - env: SYMFONY_VERSION='6.3.*' MIN_STABILITY='dev' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=1' - allow_failures: - - env: SYMFONY_VERSION='6.3.*' MIN_STABILITY='dev' SYMFONY_DEPRECATIONS_HELPER='max[indirect]=1' - fast_finish: true - -install: - # set unlimited memory_limit - - INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - echo "memory_limit = -1" >> "${INI_FILE}" - # disable Xdebug for better Composer performance - - if php -v | grep -q 'Xdebug'; then phpenv config-rm xdebug.ini; fi; - # install dependencies using Composer - - bash .travis_install_dependencies.sh - # show installed dependencies - - composer show - -before_script: - # set up MySQL - - mysql -u root -e 'CREATE DATABASE IF NOT EXISTS test;' - - mysql -u root -e 'DROP USER "travis"@"localhost";' - - mysql -u root -e 'CREATE USER "travis"@"localhost" IDENTIFIED BY "";' - - mysql -u root -e 'GRANT ALL ON test.* TO "travis"@"localhost";' - - mysql -u root -e 'FLUSH PRIVILEGES;' - # set up Redis - - echo "extension=redis.so" > redis.ini - - phpenv config-add redis.ini - # create folder for code coverage data - - mkdir -p build/logs - # install PCOV extension for quick code coverage analysis - - pecl install pcov - -script: - # validate composer.json - - if [ -n "${WITH_STATIC_ANALYSIS:-}" ]; then composer validate --strict --no-check-lock; fi; - # run PHPStan - - if [ -n "${WITH_STATIC_ANALYSIS:-}" ]; then vendor/bin/phpstan analyse; fi; - # run PHPUnit - - php vendor/phpunit/phpunit/phpunit -v --coverage-clover build/logs/clover.xml - # upload code coverage data - - | - if [ "${TRAVIS_REPO_SLUG}" = "craue/CraueConfigBundle" ]; then - PHP_COVERALLS_VERSION=`curl --retry 5 -Is https://github.com/php-coveralls/php-coveralls/releases/latest | grep -i 'Location:' | sed 's/.*\/tag\/\(.*\)$/\1/' | tr -d "[:cntrl:]"` - echo "using php-coveralls '${PHP_COVERALLS_VERSION}'" - travis_retry wget -q "https://github.com/php-coveralls/php-coveralls/releases/download/${PHP_COVERALLS_VERSION}/php-coveralls.phar" -O php-coveralls.phar - travis_retry php php-coveralls.phar -v - fi - -services: - - mysql - - redis - -notifications: - email: - on_success: always - on_failure: always - -# cache Composer's package cache -cache: - directories: - - $HOME/.composer/cache/files diff --git a/README.md b/README.md index c30ea15..00b0dfe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Information -[![Build Status](https://app.travis-ci.com/craue/CraueConfigBundle.svg?branch=master)](https://app.travis-ci.com/craue/CraueConfigBundle) +[![Tests](https://github.com/craue/CraueConfigBundle/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/craue/CraueConfigBundle/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/craue/CraueConfigBundle/badge.svg?branch=master)](https://coveralls.io/github/craue/CraueConfigBundle?branch=master) CraueConfigBundle manages configuration settings stored in the database and makes them accessible via a service in your diff --git a/Tests/config/config.yml b/Tests/config/config.yml index f804000..95255ba 100644 --- a/Tests/config/config.yml +++ b/Tests/config/config.yml @@ -9,7 +9,7 @@ doctrine: host: 127.0.0.1 port: ~ dbname: test - user: travis + user: tester password: ~ orm: auto_generate_proxy_classes: '%kernel.debug%' diff --git a/Tests/config/config_hacks.php b/Tests/config/config_hacks.php index 5d732ce..df54641 100644 --- a/Tests/config/config_hacks.php +++ b/Tests/config/config_hacks.php @@ -23,3 +23,19 @@ 'storage_id' => 'session.storage.mock_file', ], ]); + +// TODO remove as soon as Symfony >= 6 is required +if (Kernel::VERSION_ID >= 50200 && Kernel::VERSION_ID < 60000) { + $container->loadFromExtension('framework', [ + 'form' => [ + 'legacy_error_messages' => false, + ], + ]); +} + +// TODO remove as soon as Symfony >= 7 is required +if (Kernel::VERSION_ID < 70000) { + $container->loadFromExtension('framework', [ + 'http_method_override' => false, + ]); +} diff --git a/phpstan-config.neon b/phpstan-config.neon index d8995d0..1bd428d 100644 --- a/phpstan-config.neon +++ b/phpstan-config.neon @@ -11,6 +11,3 @@ parameters: - message: '#^Unsafe usage of new static\(\)\.$#' path: Entity/BaseSetting.php - - - message: '#^Strict comparison using !== between false and false will always evaluate to false\.$#' - path: Twig/Extension/ConfigTemplateExtension.php