From 2b0d6e221fafc2c733705fe06f3eb5e08e016927 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 28 Feb 2020 15:42:17 +0530 Subject: [PATCH] Improve blackfire examples --- README.md | 3 ++- examples/blackfire-player.yml | 31 +++++++++++++++++++++++++++++++ examples/blackfire.yml | 29 ++++++++++++++--------------- 3 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 examples/blackfire-player.yml diff --git a/README.md b/README.md index 9d8c64a7..4af53b8d 100644 --- a/README.md +++ b/README.md @@ -470,6 +470,8 @@ Examples for setting up this GitHub Action with different PHP Frameworks/Package |Framework/Package|Runs on|Workflow| |--- |--- |--- | +|Blackfire|`macOS`, `ubuntu` and `windows`|[blackfire.yml](./examples/blackfire.yml "GitHub Action using Blackfire")| +|Blackfire Player|`macOS`, `ubuntu` and `windows`|[blackfire-player.yml](./examples/blackfire-player.yml "GitHub Action using Blackfire Player")| |CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")| |CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")| |CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")| @@ -491,7 +493,6 @@ Examples for setting up this GitHub Action with different PHP Frameworks/Package |Yii2 Starter Kit with `MySQL`|`ubuntu`|[yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL")| |Yii2 Starter Kit with `PostgreSQL`|`ubuntu`|[yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL")| |Zend Framework|`macOS`, `ubuntu` and `windows`|[zend-framework.yml](./examples/zend-framework.yml "GitHub Action for Zend Framework")| -|Blackfire|`macOS`, `ubuntu` and `windows`|[blackfire.yml](./examples/blackfire.yml "GitHub Action using blackfire")| ## :scroll: License diff --git a/examples/blackfire-player.yml b/examples/blackfire-player.yml new file mode 100644 index 00000000..88d1153b --- /dev/null +++ b/examples/blackfire-player.yml @@ -0,0 +1,31 @@ +# GitHub Action for Blackfire Player +name: Play a Blackfire Scenario +on: [push, pull_request] +jobs: + blackfire-player: + name: Blackfire (PHP ${{ matrix.php-versions }}) + # Add your Blackfire credentials securely using GitHub Secrets + env: + BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }} + BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }} + BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }} + BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }} + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + php-versions: ['7.2', '7.3', '7.4'] + # blackfire-player supports PHP >= 5.5 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + extensions: blackfire + tools: blackfire, blackfire-player #Setup Blackfire client, agent and player + coverage: none + - name: Play the scenario + run: blackfire-player run scenario.bkf # Refer to https://blackfire.io/docs/player/index#usage diff --git a/examples/blackfire.yml b/examples/blackfire.yml index af0ecac5..8ad7740a 100644 --- a/examples/blackfire.yml +++ b/examples/blackfire.yml @@ -1,23 +1,22 @@ -# GitHub Action for blackfire +# GitHub Action for Blackfire name: Profiling with blackfire on: [push, pull_request] jobs: - bedrock: + blackfire: name: Blackfire (PHP ${{ matrix.php-versions }}) + # Add your Blackfire credentials securely using GitHub Secrets + env: + BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }} + BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }} + BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }} + BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }} runs-on: ${{ matrix.operating-system }} - services: - blackfire: - image: blackfire/blackfire - ports: - - 8707:8707 - env: - BLACKFIRE_SERVER_ID: "" - BLACKFIRE_SERVER_TOKEN: "" strategy: fail-fast: false matrix: operating-system: [ubuntu-latest, windows-latest, macos-latest] - php-versions: ['7.1', '7.2', '7.3', '7.4'] + php-versions: ['7.2', '7.3', '7.4'] + # Blackfire supports PHP >= 5.3 on ubuntu and macos and PHP >= 5.4 on windows steps: - name: Checkout uses: actions/checkout@v2 @@ -25,8 +24,8 @@ jobs: uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} - extensions: blackfire-1.30.0 - ini-values: blackfire.agent_socket=tcp://localhost:8707 + extensions: blackfire + tools: blackfire #Setup Blackfire client and agent + coverage: none - name: Profile - # Note that blackfire agent is not installed. So an implementation with the sdk is required! - run: php your-blackfire-sdk-script.php + run: blackfire run php my-script.php # Refer to https://blackfire.io/docs/cookbooks/profiling-cli