From 1392efa37bb8c29e923f8e213a9a4da6f564cccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20H=C3=A9lias?= Date: Wed, 3 Apr 2024 11:11:02 +0200 Subject: [PATCH] ci: update CI workflow --- .github/stale.yml | 23 +++++++ .github/workflows/ci.yml | 134 +++++++++++++++++++++++++++------------ composer.json | 43 ++++++++----- 3 files changed, 145 insertions(+), 55 deletions(-) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..85330d8 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,23 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 + +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 + +# Issues with these labels will never be considered stale +exemptLabels: + - bug + - enhancement + - RFC + +# Label to use when marking an issue as stale +staleLabel: stale + +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. + +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a67b46..859481c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,43 +1,99 @@ -name: ci +name: PHPUnit on: - pull_request: - branches: [ master ] + push: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: - build: - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php-version: [ '7.4', '8.0', '8.1', '8.2' ] - - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: php-setup - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - - - name: composer-validate - run: composer validate - - - name: composer-cache - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.php-version }}-composer- - - - name: composer-install - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest - - - name: phpunit - run: vendor/bin/phpunit + + test: + name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}" + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.can-fail }} + + strategy: + fail-fast: false + matrix: + include: + # Lowest Deps 5.4 + - php: lowest + symfony: 5.4.* + coverage: 'none' + composer-flags: '--prefer-stable --prefer-lowest' + can-fail: false + # LTS with latest stable PHP 5.4 + - php: latest + symfony: 5.4.* + coverage: 'none' + composer-flags: '--prefer-stable' + can-fail: false + # LTS with latest stable PHP 6.4 + - php: latest + symfony: 6.4.* + coverage: 'none' + composer-flags: '--prefer-stable' + can-fail: false + # Active release + - php: latest + symfony: 7.0.* + coverage: pcov + composer-flags: '--prefer-stable' + can-fail: false + # Development release + - php: nightly + symfony: 7.1.*@dev + coverage: 'none' + composer-flags: '' + can-fail: true + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2, flex + coverage: ${{ matrix.coverage }} + ini-values: date.timezone=UTC,memory_limit=-1,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1 + env: + fail-fast: true + + - name: Set Composer stability + if: matrix.php == 'nightly' + run: "composer config minimum-stability dev" + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer- + + - name: Install Composer dependencies + run: composer update ${{ matrix.composer-flags }} --no-interaction --no-progress --optimize-autoloader + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }} + + - name: Run tests + run: composer test + + - name: Monitor coverage + if: matrix.coverage != 'none' + uses: slavcodev/coverage-monitor-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + coverage_path: coverage-report.xml + threshold_alert: 60 + threshold_warning: 80 diff --git a/composer.json b/composer.json index 083642e..7213366 100644 --- a/composer.json +++ b/composer.json @@ -1,47 +1,58 @@ { "name": "odandb/xhprof-bundle", "description": "This bundle add additional XHProf menu item in symfony debug toolbar & makes things easier to handle XHProf profiling", + "license": "MIT", "type": "symfony-bundle", "keywords": [ "symfony", + "bundle", "xhprof", "profiling", "debug", "tideways", "xhgui" ], + "authors": [ + { + "name": "Mathieu Girard", + "email": "mathieu.girard@odandb.com" + }, + { + "name": "OD&B", + "homepage": "https://www.odandb.com/" + } + ], "require": { "php": ">=7.4", "perftools/php-profiler": "^1.1", "symfony/config": "^5.4 || ^6.4 || ^7.0", "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0", "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0", + "symfony/http-foundation": "^5.4 || ^6.4 || ^7.0", "symfony/http-kernel": "^5.4 || ^6.4 || ^7.0" }, "require-dev": { - "symfony/phpunit-bridge": "^6.2" + "phpunit/phpunit": "^9.5", + "symfony/phpunit-bridge": "^7.0" }, "suggest": { "perftools/xhgui": "To view the profiling results in a web interface" }, - "license": "MIT", - "config": { - "sort-packages": true - }, "autoload": { "psr-4": { - "Odandb\\XhprofBundle\\": "src/", - "Odandb\\XhprofBundle\\Tests\\": "tests/" + "Odandb\\XhprofBundle\\": "src/" } }, - "authors": [ - { - "name": "Mathieu Girard", - "email": "mathieu.girard@odandb.com" - }, - { - "name": "OD&B", - "homepage": "https://www.odandb.com/" + "autoload-dev": { + "psr-4": { + "Odandb\\XhprofBundle\\Tests\\": "tests/" } - ] + }, + "config": { + "sort-packages": true + }, + "scripts": { + "test": "vendor/bin/phpunit --coverage-clover=coverage-report.xml" + } }