diff --git a/.github/workflows/ci-2.x.yml b/.github/workflows/ci-2.x.yml new file mode 100644 index 0000000..6339b60 --- /dev/null +++ b/.github/workflows/ci-2.x.yml @@ -0,0 +1,129 @@ +# Primary CI checks for Rollbar-PHP-Laravel. +# We're checking that logging within Laravel passes through the Rollbar Laravel +# integration when that integration is properly installed. We make this check +# for all supported combinations of Laravel, Rollbar, and PHP. We are not +# checking that messages are properly sent to Rollbar: that's handled by +# rollbar-php. +# +# Test with act: +# brew install act +# act -P ubuntu-latest=shivammathur/node:latest +# +# @see https://github.com/nektos/act/issues/329 +name: Rollbar-PHP-Laravel CI, version 2.x + +# Fire this action on pushes to 2.x legacy branches (the official one, as well +# as development branches within it -- hence the wildcard), and also tags for +# the legacy lineage. Also, run every day at 02:42 GMT to catch failures from +# transitive dependencies. + +on: + push: + branches: + - next/2.x/** + tags: + - v2.* + pull_request: + branches: + - next/2.x/** + schedule: + - cron: '42 2 * * *' + +jobs: + # Check that this runs on all combinations of Laravel we claim to support. + laravel-tests: + strategy: + matrix: + os: [ubuntu] + php: [7.4, 7.3, 7.2, 7.1, 7.0] + laravel: [^5.5] + env: + ROLLBAR_TOKEN: "ad865e76e7fb496fab096ac07b1dbabb" + name: Laravel ${{ matrix.laravel }} on PHP ${{ matrix.php }} (${{ matrix.os }}) + runs-on: ${{ matrix.os }}-latest + steps: + - name: Checkout the code + uses: actions/checkout@v2 + + - name: Install PHP and composer environment + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl + + - name: Create Laravel test app + run: composer create-project laravel/laravel rollbar-test-app ${{ matrix.laravel }} + + - name: Install that code using Composer rigged to look in the parent directory + working-directory: rollbar-test-app + run: | + composer config repositories.local '{"type":"path", "url":".."}' + composer require rollbar/rollbar-laravel + echo "ROLLBAR_TOKEN=${ROLLBAR_TOKEN}" >> .env + echo "GITHUB_RUN_ID=${GITHUB_RUN_ID}" >> .env + chmod 400 .env + + - name: Configure Laravel to use Rollbar and configure Rollbar to invoke logging callback + working-directory: rollbar-test-app + run: | + > config/logging.php echo ' "rollbar", + "channels" => array ( + "rollbar" => array ( + "driver" => "monolog", + "handler" => \Rollbar\Laravel\MonologHandler::class, + "access_token" => env("ROLLBAR_TOKEN"), + "level" => "debug", + // use the check_ignore filter to capture log messages for verification + "check_ignore" => "check_ignore", + ) + ) + ); + ' + touch app/helpers.php + > tmp-composer.json jq '.autoload += { "files": [ "app/helpers.php" ] }' composer.json + mv tmp-composer.json composer.json + composer dump-autoload + + - name: Define logging callback that invokes when Laravel logs through Rollbar + working-directory: rollbar-test-app + run: | + > app/helpers.php echo ' tests/Feature/LoggingTest.php echo 'assertFileExists(temp_file(), + "Rollbar check_ignore handler not invoked, suggesting an issue integrating Rollbar into Laravel."); + $this->assertSame($value, file_get_contents(temp_file()), + "check_ignore file did not contain expected value, suggesting file left by another process."); + } + } + ' + + - name: Invoke the Laravel test suite + working-directory: rollbar-test-app + run: | + ./vendor/bin/phpunit diff --git a/.github/workflows/ci-4.x.yml b/.github/workflows/ci-4.x.yml new file mode 100644 index 0000000..d8235c3 --- /dev/null +++ b/.github/workflows/ci-4.x.yml @@ -0,0 +1,129 @@ +# Primary CI checks for Rollbar-PHP-Laravel. +# We're checking that logging within Laravel passes through the Rollbar Laravel +# integration when that integration is properly installed. We make this check +# for all supported combinations of Laravel, Rollbar, and PHP. We are not +# checking that messages are properly sent to Rollbar: that's handled by +# rollbar-php. +# +# Test with act: +# brew install act +# act -P ubuntu-latest=shivammathur/node:latest +# +# @see https://github.com/nektos/act/issues/329 +name: Rollbar-PHP-Laravel CI, version 4.x + +# Fire this action on pushes to 4.x legacy branches (the official one, as well +# as development branches within it -- hence the wildcard), and also tags for +# the legacy lineage. Also, run every day at 02:42 GMT to catch failures from +# transitive dependencies. + +on: + push: + branches: + - next/4.x/** + tags: + - v4.* + pull_request: + branches: + - next/4.x/** + schedule: + - cron: '42 2 * * *' + +jobs: + # Check that this runs on all combinations of Laravel we claim to support. + laravel-tests: + strategy: + matrix: + os: [ubuntu] + php: [7.4, 7.3, 7.2, 7.1] + laravel: [^5.8, ^5.7, ^5.6] + env: + ROLLBAR_TOKEN: "ad865e76e7fb496fab096ac07b1dbabb" + name: Laravel ${{ matrix.laravel }} on PHP ${{ matrix.php }} (${{ matrix.os }}) + runs-on: ${{ matrix.os }}-latest + steps: + - name: Checkout the code + uses: actions/checkout@v2 + + - name: Install PHP and composer environment + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl + + - name: Create Laravel test app + run: composer create-project laravel/laravel rollbar-test-app ${{ matrix.laravel }} + + - name: Install that code using Composer rigged to look in the parent directory + working-directory: rollbar-test-app + run: | + composer config repositories.local '{"type":"path", "url":".."}' + composer require rollbar/rollbar-laravel + echo "ROLLBAR_TOKEN=${ROLLBAR_TOKEN}" >> .env + echo "GITHUB_RUN_ID=${GITHUB_RUN_ID}" >> .env + chmod 400 .env + + - name: Configure Laravel to use Rollbar and configure Rollbar to invoke logging callback + working-directory: rollbar-test-app + run: | + > config/logging.php echo ' "rollbar", + "channels" => array ( + "rollbar" => array ( + "driver" => "monolog", + "handler" => \Rollbar\Laravel\MonologHandler::class, + "access_token" => env("ROLLBAR_TOKEN"), + "level" => "debug", + // use the check_ignore filter to capture log messages for verification + "check_ignore" => "check_ignore", + ) + ) + ); + ' + touch app/helpers.php + > tmp-composer.json jq '.autoload += { "files": [ "app/helpers.php" ] }' composer.json + mv tmp-composer.json composer.json + composer dump-autoload + + - name: Define logging callback that invokes when Laravel logs through Rollbar + working-directory: rollbar-test-app + run: | + > app/helpers.php echo ' tests/Feature/LoggingTest.php echo 'assertFileExists(temp_file(), + "Rollbar check_ignore handler not invoked, suggesting an issue integrating Rollbar into Laravel."); + $this->assertSame($value, file_get_contents(temp_file()), + "check_ignore file did not contain expected value, suggesting file left by another process."); + } + } + ' + + - name: Invoke the Laravel test suite + working-directory: rollbar-test-app + run: | + ./vendor/bin/phpunit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4affb99..c10ea76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,37 +1,45 @@ # Primary CI checks for Rollbar-PHP-Laravel. +# We're checking that logging within Laravel passes through the Rollbar Laravel +# integration when that integration is properly installed. We make this check +# for all supported combinations of Laravel, Rollbar, and PHP. We are not +# checking that messages are properly sent to Rollbar: that's handled by +# rollbar-php. # # Test with act: # brew install act # act -P ubuntu-latest=shivammathur/node:latest # # @see https://github.com/nektos/act/issues/329 -name: Rollbar-PHP-Laravel CI +name: Rollbar-PHP-Laravel CI, master # Fire this action on pushes to main branch (master) as well as other branches -# or pull requests. Also, run every day at 02:42 GMT -- this catches failures -# from dependencies that update indepdently. +# or pull requests, excluding those in the next/ lineage. Also, run every day +# at 02:42 GMT -- this catches failures from transitive dependencies. on: push: + branches-ignore: + - next/** pull_request: + branches-ignore: + - next/** schedule: - cron: '42 2 * * *' jobs: - # Check that this runs on PHP on all versions we claim to support, on both - # UNIX-like and Windows environments, and that use both the lowest possible - # compatible version as well as the most-recent stable version. This will - # fail-fast by default, so we include our edgiest versions (currently 7.4) - # first as they're most likely to fail. - # @seealso https://freek.dev/1546 - # @seealso https://www.dereuromark.de/2019/01/04/test-composer-dependencies-with-prefer-lowest/ - php-tests: + # Check that this runs on all combinations of Laravel we claim to support. + laravel-tests: strategy: matrix: - php: [7.3, 7.2] - dependency: [stable] os: [ubuntu] - - name: PHP ${{ matrix.php }} on ${{ matrix.os }}, ${{ matrix.dependency }} dependencies preferred + php: [7.4, 7.3, 7.2] + laravel: [^8, ^7, ^6] + exclude: + # Laravel 8 requires php 7.3+, so exclude all PHP versions prior to 7.3 + - laravel: ^8 + php: 7.2 + env: + ROLLBAR_TOKEN: "ad865e76e7fb496fab096ac07b1dbabb" + name: Laravel ${{ matrix.laravel }} on PHP ${{ matrix.php }} (${{ matrix.os }}) runs-on: ${{ matrix.os }}-latest steps: - name: Checkout the code @@ -42,29 +50,80 @@ jobs: with: php-version: ${{ matrix.php }} extensions: curl - ini-values: ${{ matrix.ini }} - coverage: xdebug - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Create Laravel test app + run: composer create-project laravel/laravel rollbar-test-app ${{ matrix.laravel }} - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.dependency }}- - restore-keys: ${{ matrix.os }}-composer-${{ matrix.dependency }}- + - name: Install that code using Composer rigged to look in the parent directory + working-directory: rollbar-test-app + run: | + composer config repositories.local '{"type":"path", "url":".."}' + composer require rollbar/rollbar-laravel + echo "ROLLBAR_TOKEN=${ROLLBAR_TOKEN}" >> .env + echo "GITHUB_RUN_ID=${GITHUB_RUN_ID}" >> .env + chmod 400 .env + + - name: Configure Laravel to use Rollbar and configure Rollbar to invoke logging callback + working-directory: rollbar-test-app + run: | + > config/logging.php echo ' "rollbar", + "channels" => array ( + "rollbar" => array ( + "driver" => "monolog", + "handler" => \Rollbar\Laravel\MonologHandler::class, + "access_token" => env("ROLLBAR_TOKEN"), + "level" => "debug", + // use the check_ignore filter to capture log messages for verification + "check_ignore" => "check_ignore", + ) + ) + ); + ' + touch app/helpers.php + > tmp-composer.json jq '.autoload += { "files": [ "app/helpers.php" ] }' composer.json + mv tmp-composer.json composer.json + composer dump-autoload + + - name: Define logging callback that invokes when Laravel logs through Rollbar + working-directory: rollbar-test-app + run: | + > app/helpers.php echo ' tests/Feature/LoggingTest.php echo 'assertFileExists(temp_file(), + "Rollbar check_ignore handler not invoked, suggesting an issue integrating Rollbar into Laravel."); + $this->assertSame($value, file_get_contents(temp_file()), + "check_ignore file did not contain expected value, suggesting file left by another process."); + } + } + ' - - name: Report results - if: success() - run: ./vendor/bin/php-coveralls -v || true + - name: Invoke the Laravel test suite + working-directory: rollbar-test-app + run: | + ./vendor/bin/phpunit