GitHub Actions is a continuous integration platform that comes with GitHub.
Integrating Blackfire with GitHub Actions enables running Blackfire tests and scenarios, through PHPUnit tests, the Blackfire Player, or the Blackfire CLI Tool. It also makes it possible to trigger Blackfire builds.
Note
GitHub Actions support is available, via the setup-php action.
While this action is designed for PHP, it installs all needed components, making Blackfire usable by apps written in any language supported by Blackfire (Python, Go…).
To set up Blackfire on GitHub Actions, you need to define some secret variables in your project settings.
Define secrets for your Client credentials:
Define secrets for the Server credentials. Select the Blackfire environment which you want to use for your GitHub Actions-triggered tests:
Within your workflow, configure each job where you need Blackfire:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Blackfire via setup-php Action
uses: shivammathur/setup-php@v2
with:
# PHP Only: Setup PHP extensions, including Blackfire Probe.
# It is recommended to disable xdebug.
# Not needed for other languages.
extensions: blackfire, :xdebug
# Setup Blackfire Agent and CLI tool, and Blackfire Player
tools: blackfire, blackfire-player
env:
# Expose your Blackfire credentials stored in secrets
# as environment variables.
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 }}
# Trigger a profile using Blackfire CLI tool.
- name: Profile list-users command
env:
APP_ENV: prod
APP_DEBUG: 0
run: blackfire run php bin/console app:list-users
# Other example using Python:
#run: blackfire run python my_script.py
|
setup-php action
supports the blackfire
CLI tool. It enables to trigger a Blackfire build:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup PHP Action
uses: shivammathur/setup-php@v2
with:
# Setup Blackfire Agent and CLI tool and Blackfire Player
tools: blackfire, blackfire-player
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 }}
- name: Trigger a Blackfire Build
run: |
blackfire build-trigger <ENDPOINT> --env=<ENV-UUID> --token=<TOKEN-VALUE>
|