From 94372f512afb997529528fcc55de99df6b186b26 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Sun, 29 Nov 2020 14:47:09 +0100 Subject: [PATCH] Move tests to GitHub Actions --- .gitattributes | 2 +- .github/workflows/continuous-integration.yml | 123 +++++++++++++++++++ .travis.yml | 63 ---------- README.markdown | 2 +- 4 files changed, 125 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index 3ef493a..7aa3882 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,9 @@ * text=auto /Tests export-ignore +/.github export-ignore .doctrine-project.json export-ignore .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore phpcs.xml.dist export-ignore phpunit.xml.dist export-ignore diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..04bbc35 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,123 @@ +name: "Continuous Integration" + +on: + pull_request: + branches: + - "*.x" + - "master" + push: + +env: + fail-fast: true + +jobs: + phpunit: + name: "PHPUnit" + runs-on: "${{ matrix.os }}" + + strategy: + matrix: + os: + - "ubuntu-20.04" + php-version: + - "7.2" + - "7.3" + - "7.4" + symfony-version: + - "4.4.x" + - "5.1.x" + driver-version: + - "stable" + deps: + - "normal" + include: + - deps: "low" + os: "ubuntu-20.04" + php-version: "7.2" + driver-version: "1.5.0" + symfony-version: "4.4.*" + + services: + mongodb: + image: "mongo" + ports: + - "27017:27017" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: Setup cache environment + id: extcache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-version }} + extensions: "mongodb-${{ matrix.driver-version }}" + key: "extcache-v1" + + - name: Cache extensions + uses: actions/cache@v2 + with: + path: ${{ steps.extcache.outputs.dir }} + key: ${{ steps.extcache.outputs.key }} + restore-keys: ${{ steps.extcache.outputs.key }} + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + tools: "pecl" + extensions: "mongodb-${{ matrix.driver-version }}" + coverage: "xdebug" + ini-values: "zend.assertions=1" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v2" + with: + path: "~/.composer/cache" + key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + + - name: "Install Symfony" + run: "composer require symfony/symfony:${{ matrix.symfony-version }} --no-update" + + - name: "Install dependencies with composer" + run: "composer update --no-interaction --no-progress --prefer-stable" + if: "${{ matrix.deps == 'normal' }}" + + - name: "Install lowest possible dependencies with composer" + run: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest" + if: "${{ matrix.deps == 'low' }}" + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit --coverage-clover=coverage.xml" + + - name: "Upload coverage file" + uses: "actions/upload-artifact@v2" + with: + name: "phpunit-${{ matrix.php-version }}.coverage" + path: "coverage.xml" + + upload_coverage: + name: "Upload coverage to Codecov" + runs-on: "ubuntu-20.04" + needs: + - "phpunit" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Download coverage files" + uses: "actions/download-artifact@v2" + with: + path: "reports" + + - name: "Upload to Codecov" + uses: "codecov/codecov-action@v1" + with: + directory: reports diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 72b1f25..0000000 --- a/.travis.yml +++ /dev/null @@ -1,63 +0,0 @@ -dist: xenial -language: php -sudo: false - -cache: - directories: - - $HOME/.composer/cache - -php: - - 7.2 - - 7.3 - - 7.4 - -services: mongodb - -env: - global: - - DRIVER_VERSION="stable" - - COMPOSER_FLAGS=" -n --prefer-dist --prefer-stable" - - COMPOSER_MEMORY_LIMIT=-1 - -before_install: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" - - composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master - -install: - - composer self-update - - pecl install -f mongodb-${DRIVER_VERSION} - - if [[ -z ${REQUIRE_SYMFONY_MESSENGER} ]]; then composer require --dev symfony/messenger --no-update; fi - - composer update ${COMPOSER_FLAGS} - -script: - - ./vendor/bin/phpunit ${PHPUNIT_FLAGS} - -jobs: - include: - # Tests the lowest set of dependencies - - php: 7.2 - env: LOWEST DRIVER_VERSION="1.5.0" SYMFONY_DEPRECATIONS_HELPER=weak COMPOSER_FLAGS=" -n --prefer-lowest --prefer-stable --prefer-dist" - - # Test against latest Symfony 4.3 stable - - php: 7.3 - env: SYMFONY_REQUIRE="4.3.*" REQUIRE_SYMFONY_MESSENGER - - # Test against latest Symfony 4.4 dev - - php: 7.3 - env: SYMFONY_REQUIRE="4.4.*" REQUIRE_SYMFONY_MESSENGER - - # Test against latest Symfony 5.0 dev - - php: 7.3 - env: SYMFONY_REQUIRE="5.0.*" REQUIRE_SYMFONY_MESSENGER - - # Test dev versions - - php: 7.3 - if: type = cron - env: DEV COMPOSER_FLAGS="-n --prefer-dist" - - - stage: Coverage - php: 7.3 - env: COVERAGE PHPUNIT_FLAGS="--coverage-clover=coverage.clover" REQUIRE_SYMFONY_MESSENGER - before_script: - - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} - - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi diff --git a/README.markdown b/README.markdown index 1c5f1aa..8097d62 100644 --- a/README.markdown +++ b/README.markdown @@ -4,7 +4,7 @@ DoctrineMongoDBBundle This bundle integrates the [Doctrine2 MongoDB Object Document Mapper (ODM) library](https://github.com/doctrine/mongodb-odm) into Symfony so that you can persist and retrieve objects to and from MongoDB. -[![Build Status](https://secure.travis-ci.org/doctrine/DoctrineMongoDBBundle.png?branch=master)](http://travis-ci.org/doctrine/DoctrineMongoDBBundle) +[![Build Status](https://github.com/doctrine/DoctrineMongoDBBundle/workflows/Continuous%20Integration/badge.svg)](https://github.com/doctrine/DoctrineMongoDBBundle/actions) Documentation on how to install and use this bundle is available in the Symfony [documentation](http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html).