diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..0d031bc --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,103 @@ +name: Build + +on: + push: + branches: [ develop, master ] + pull_request: + branches: [ develop, master ] + +jobs: + build: + name: PHP ${{ matrix.name }} + strategy: + matrix: + include: + - php: 7.2 + allow_fail: false + name: 'PHP 7.2 with latest deps' + - php: 7.2 + allow_fail: false + composer_update_flags: '--prefer-lowest --prefer-stable' + name: 'PHP 7.2 with lowest stable deps' + - php: 7.3 + allow_fail: false + name: 'PHP 7.3 with latest deps' + - php: 7.3 + allow_fail: false + composer_update_flags: '--prefer-lowest --prefer-stable' + name: 'PHP 7.3 with lowest stable deps' + - php: 7.4 + allow_fail: false + name: 'PHP 7.4 with latest deps' + - php: 7.4 + allow_fail: false + composer_update_flags: '--prefer-lowest --prefer-stable' + name: 'PHP 7.4 with lowest stable deps' + - php: 8.0 + allow_fail: false + php_ini: 'xdebug.coverage_enable=On' + name: 'PHP 8.0 with latest deps' + - php: 8.0 + allow_fail: false + composer_update_flags: '--prefer-lowest --prefer-stable' + php_ini: 'xdebug.coverage_enable=On' + name: 'PHP 8.0 with lowest stable deps' + - php: 8.1 + allow_fail: true + php_ini: 'xdebug.coverage_enable=On' + name: 'PHP 8.1 with latest deps' + - php: 8.1 + allow_fail: true + composer_update_flags: '--prefer-lowest --prefer-stable' + php_ini: 'xdebug.coverage_enable=On' + name: 'PHP 8.1 with lowest stable deps' + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + ini-values: ${{ matrix.php_ini }} + + - name: Install dependencies + run: composer install ${{ matrix.composer_flags }} + continue-on-error: ${{ matrix.allow_fail }} + + - name: Update dependencies + if: matrix.composer_update_flags + run: composer update ${{ matrix.composer_update_flags }} && composer update phpunit/phpunit --with-dependencies + continue-on-error: ${{ matrix.allow_fail }} + + - name: Create log folder + run: mkdir -p build/logs; + + - name: Run unit tests + run: composer unit-tests + continue-on-error: ${{ matrix.allow_fail }} + + - name: Upload test coverage + run: php vendor/bin/php-coveralls -vvv + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + COVERALLS_FLAG_NAME: ${{ matrix.name }} + continue-on-error: ${{ matrix.allow_fail }} + + finish: + needs: build + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + run: | + curl --header "Content-Type: application/json" \ + --request POST \ + --data '{"repo_token":"${{ secrets.GITHUB_TOKEN }}","repo_name":"JsonMapper/LaravelPackage", "payload": {"build_num": "${{ github.sha }}", "status": "done"}}' \ + https://coveralls.io/webhook \ No newline at end of file diff --git a/.mergify.yml b/.mergify.yml index 2372e72..8e8cb75 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -2,7 +2,7 @@ pull_request_rules: - name: automatic merge for Dependabot pull requests conditions: - author~=^dependabot(|-preview)\[bot\]$ - - status-success=Travis CI - Pull Request + - status-success=Build actions: merge: method: squash \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 24b00c3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - -matrix: - include: - # Latest dependencies with all PHP versions - - php: 7.2 - - php: 7.2 - env: COMPOSER_UPDATE_FLAGS='--prefer-lowest --prefer-stable' - - php: 7.3 - - php: 7.3 - env: COMPOSER_UPDATE_FLAGS='--prefer-lowest --prefer-stable' - - php: 7.4 - - php: 7.4 - env: COMPOSER_UPDATE_FLAGS='--prefer-lowest --prefer-stable' - - # Ignore the platform requirements for the upcoming PHP version - - php: nightly - env: COMPOSER_FLAGS='--ignore-platform-reqs' - - php: nightly - env: - - COMPOSER_FLAGS='--ignore-platform-reqs' - COMPOSER_UPDATE_FLAGS='--prefer-lowest --prefer-stable --ignore-platform-reqs' - allow_failures: - - php: nightly - fast_finish: true - -branches: - only: - - master - - develop - -install: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev --no-interaction $COMPOSER_FLAGS - - if [[ -n $COMPOSER_UPDATE_FLAGS ]]; then php composer.phar update $COMPOSER_UPDATE_FLAGS; fi - -script: - - mkdir -p build/logs; - - composer unit-tests - -after_success: - - travis_retry php vendor/bin/php-coveralls - -notifications: - email: - - danny.vandersluijs@icloud.com \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d1bb81b..3b67b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.1.0] - 2021-01-28 +### Changed +- Migrate to GitHub actions [PR#12](https://github.com/JsonMapper/LaravelPackage/pull/12) + ## [2.0.0] - 2021-01-07 ### Changed - Update to version ^2.0 JsonMapper diff --git a/README.md b/README.md index 4c69857..e9dff55 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ For more information see the project website: https://jsonmapper.net ![GitHub](https://img.shields.io/github/license/JsonMapper/LaravelPackage) ![Packagist Version](https://img.shields.io/packagist/v/json-mapper/laravel-package) ![PHP from Packagist](https://img.shields.io/packagist/php-v/json-mapper/laravel-package) -[![Build Status](https://api.travis-ci.com/JsonMapper/LaravelPackage.svg?branch=master)](https://travis-ci.com/JsonMapper/LaravelPackage) +![Build](https://github.com/JsonMapper/LaravelPackage/workflows/Build/badge.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/JsonMapper/LaravelPackage/badge.svg?branch=master)](https://coveralls.io/github/JsonMapper/LaravelPackage?branch=master) # Why use JsonMapper diff --git a/Version b/Version index 359a5b9..50aea0e 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.0.0 \ No newline at end of file +2.1.0 \ No newline at end of file diff --git a/composer.json b/composer.json index df1f5d4..7ee1699 100644 --- a/composer.json +++ b/composer.json @@ -42,8 +42,9 @@ "require-dev": { "squizlabs/php_codesniffer": "^3.5", "phpstan/phpstan": "^0.12.19", - "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^8.0 || ^9.0", - "orchestra/testbench": "^5.3|^6.0" + "orchestra/testbench": "^5.3|^6.0", + "php-coveralls/php-coveralls": "^2.4", + "guzzlehttp/guzzle": "^6.5 || ^7.0" } } diff --git a/tests/Unit/ServiceProviderTest.php b/tests/Unit/ServiceProviderTest.php index a6fb4c5..d9f75d3 100644 --- a/tests/Unit/ServiceProviderTest.php +++ b/tests/Unit/ServiceProviderTest.php @@ -28,15 +28,16 @@ public function testBootPublishesConfig(): void } /** - * @covers \JsonMapper\LaravelPackage\ServiceProvider + * @covers \JsonMapper\LaravelPackage\ServiceProvider + * @dataProvider configOptionsDataProvider + * @param string|null $type */ - public function testRegisterMakesJsonMapperAvailableInApp(): void + public function testRegisterMakesJsonMapperAvailableInApp($type): void { $app = new \Illuminate\Foundation\Application(); - $app->offsetSet('config', new Repository()); + $app->offsetSet('config', new Repository(['json-mapper.type' => $type])); $serviceProvider = new ServiceProvider($app); - $serviceProvider->register(); self::assertTrue($app->has(JsonMapperInterface::class)); @@ -45,4 +46,13 @@ public function testRegisterMakesJsonMapperAvailableInApp(): void self::assertTrue($app->has(JsonMapper::class)); self::assertInstanceOf(JsonMapper::class, $app->make(JsonMapper::class)); } + + public function configOptionsDataProvider(): array + { + return [ + 'default' => ['default'], + 'best-fit' => ['best-fit'], + 'unspecified' => [null], + ]; + } }