From e07df511670daf70f830b20d7fc3abd3922ca3c8 Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Thu, 28 Jan 2021 20:22:36 +0100 Subject: [PATCH 1/2] Migrate to GitHub actions (#12) * Migrate to GitHub actions * Set correct requirements for lowest stable dependencies * Hard code repo name * Correct JSON payload * Add missing testcases --- .github/workflows/build.yaml | 103 +++++++++++++++++++++++++++++ .mergify.yml | 2 +- .travis.yml | 50 -------------- CHANGELOG.md | 2 + README.md | 2 +- composer.json | 5 +- tests/Unit/ServiceProviderTest.php | 18 +++-- 7 files changed, 124 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .travis.yml 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..7cca325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- Migrate to GitHub actions [PR#12](https://github.com/JsonMapper/LaravelPackage/pull/12) ## [2.0.0] - 2021-01-07 ### Changed 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/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], + ]; + } } From 2ee448f81004ee457a30f1f7e8095cb1ed730eec Mon Sep 17 00:00:00 2001 From: Danny van der Sluijs Date: Thu, 28 Jan 2021 20:24:36 +0100 Subject: [PATCH 2/2] Prepare 2.1.0 release --- CHANGELOG.md | 2 ++ Version | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cca325..3b67b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [2.1.0] - 2021-01-28 ### Changed - Migrate to GitHub actions [PR#12](https://github.com/JsonMapper/LaravelPackage/pull/12) 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