Skip to content

Commit

Permalink
Merge pull request #29945 from julien-jean/player-next-as-player
Browse files Browse the repository at this point in the history
[player] new player version
  • Loading branch information
romainneutron committed Aug 29, 2023
2 parents 07eb040 + be1bf36 commit ebf8057
Show file tree
Hide file tree
Showing 266 changed files with 10,478 additions and 4,109 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/build_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: build_canary

on:
push:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: blackfire/player
flavor: |
latest=false
tags: |
type=raw,value=canary
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Wait for package to be available
timeout-minutes: 10
run: |
until $(curl --output /dev/null --silent --head --fail https://get.blackfire.io/blackfire-player-latest.phar); do
printf '.'
sleep 5
done
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/386,linux/arm64
build-args: |
VERSION_SUFFIX=-latest
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
18 changes: 9 additions & 9 deletions .github/workflows/build.yml → .github/workflows/build_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Get version tag
id: git_tag
run: echo ::set-output name=VERSION::-${GITHUB_REF/refs\/tags\//}
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_ENV"
-
name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v2
uses: docker/metadata-action@v4
with:
images: blackfire/player
flavor: |
Expand All @@ -30,32 +30,32 @@ jobs:
type=semver,pattern={{version}}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Wait for package to be available
timeout-minutes: 10
run: |
until $(curl --output /dev/null --silent --head --fail https://get.blackfire.io/blackfire-player${{ steps.git_tag.outputs.VERSION }}.phar); do
until $(curl --output /dev/null --silent --head --fail https://get.blackfire.io/blackfire-player-${{ env.VERSION }}.phar); do
printf '.'
sleep 5
done
-
name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/386,linux/arm64
build-args: |
VERSION_SUFFIX=${{ steps.git_tag.outputs.VERSION }}
VERSION_SUFFIX=-${{ env.VERSION }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
10 changes: 10 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

$header = <<<'EOF'
This file is part of the Blackfire Player package.
(c) Fabien Potencier <fabien@blackfire.io>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/Player')
;
Expand All @@ -18,5 +27,6 @@
'fopen_flags' => false,
'strict_param' => true,
'phpdoc_separation' => ['groups' => [['ORM\\*'], ['Assert\\*']]],
'header_comment' => ['header' => $header],
))
;
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ FROM php:8.2-cli-alpine

ARG VERSION_SUFFIX=''
ARG PHPEXTINST_VERSION=2.1.34 # https://github.com/mlocati/docker-php-extension-installer/releases

ADD "https://get.blackfire.io/blackfire-player$VERSION_SUFFIX.phar" /usr/local/bin/blackfire-player
RUN chmod +x /usr/local/bin/blackfire-player
ARG UUID_VERSION=1.2.0 # https://pecl.php.net/package/uuid

RUN curl -fsLo /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/download/${PHPEXTINST_VERSION}/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions

RUN install-php-extensions mbstring-stable intl-stable
RUN install-php-extensions \
mbstring-stable \
intl-stable \
uuid-${UUID_VERSION}

RUN touch /usr/local/etc/php/conf.d/error_reporting.ini \
&& echo 'display_errors=Off' >> /usr/local/etc/php/conf.d/error_reporting.ini \
Expand All @@ -18,4 +19,7 @@ RUN touch /usr/local/etc/php/conf.d/error_reporting.ini \

WORKDIR /app

ADD "https://get.blackfire.io/blackfire-player$VERSION_SUFFIX.phar" /usr/local/bin/blackfire-player
RUN chmod +x /usr/local/bin/blackfire-player

ENTRYPOINT ["/usr/local/bin/blackfire-player"]
7 changes: 6 additions & 1 deletion Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG COMPOSER_VERSION=2.5.8 # https://hub.docker.com/_/composer/tags
ARG PHIVE_VERSION=0.15.2 # https://github.com/phar-io/phive/releases
ARG PHPEXTINST_VERSION=2.1.34 # https://github.com/mlocati/docker-php-extension-installer/releases
ARG UUID_VERSION=1.2.0 # https://pecl.php.net/package/uuid

FROM composer:${COMPOSER_VERSION} as build_composer

Expand All @@ -9,6 +10,7 @@ FROM php:8.2-cli
ARG COMPOSER_VERSION
ARG PHIVE_VERSION
ARG PHPEXTINST_VERSION
ARG UUID_VERSION

COPY --from=build_composer /usr/bin/composer /usr/local/bin/composer

Expand All @@ -24,7 +26,10 @@ RUN echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf
RUN curl -fsLo /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/download/${PHPEXTINST_VERSION}/install-php-extensions && \
chmod +x /usr/local/bin/install-php-extensions

RUN install-php-extensions mbstring-stable intl-stable
RUN install-php-extensions \
mbstring-stable \
intl-stable \
uuid-${UUID_VERSION}

RUN curl -fsLo phive.phar "https://github.com/phar-io/phive/releases/download/${PHIVE_VERSION}/phive-${PHIVE_VERSION}.phar" && \
curl -fsLo phive.phar.asc "https://github.com/phar-io/phive/releases/download/${PHIVE_VERSION}/phive-${PHIVE_VERSION}.phar.asc" && \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ box_image = blackfire/php-internal:8.2-v1.0.7
BOX_BIN=bin/tools/box-$(box_version).phar
PHAR_DIST=bin/blackfire-player.phar

PHP=@docker run --rm -it -u `id -u`:`id -g` -v "$(HOME)/.composer:/.composer" -v "$(HOME)/.phive:/.phive" -v "$(PWD):/app" -e HOME=/ $(php_image)
PHP=@docker run --rm -it -e "PHP_CS_FIXER_IGNORE_ENV=1" -u `id -u`:`id -g` -v "$(HOME)/.composer:/.composer" -v "$(HOME)/.phive:/.phive" -v "$(PWD):/app" -e HOME=/ $(php_image)
BOX=@docker run --rm -v $(PWD):/app -w /app $(box_image)

##
Expand Down
84 changes: 84 additions & 0 deletions Player/Adapter/BlackfireSdkAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

/*
* This file is part of the Blackfire Player package.
*
* (c) Fabien Potencier <fabien@blackfire.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Blackfire\Player\Adapter;

use Blackfire\Client;
use Blackfire\ClientConfiguration;
use Blackfire\Exception\ApiException;
use Blackfire\Player\Build\Build;
use Blackfire\Player\Exception\ApiCallException;
use Blackfire\Profile;
use Blackfire\Profile\Configuration;
use Blackfire\Profile\Request;

class BlackfireSdkAdapter implements BlackfireSdkAdapterInterface
{
public function __construct(
private readonly Client $blackfireClient,
) {
}

public function getConfiguration(): ClientConfiguration
{
try {
return $this->blackfireClient->getConfiguration();
} catch (ApiException $e) {
throw $this->createApiCallException($e);
}
}

public function createRequest(string|Configuration $config = null): Request
{
try {
return $this->blackfireClient->createRequest($config);
} catch (ApiException $e) {
throw $this->createApiCallException($e);
}
}

public function updateProfile(string $uuid, string $title, array $metadata = null): bool
{
try {
return $this->blackfireClient->updateProfile($uuid, $title, $metadata);
} catch (ApiException $e) {
throw $this->createApiCallException($e);
}
}

public function getProfile(string $uuid): Profile
{
try {
return $this->blackfireClient->getProfile($uuid);
} catch (ApiException $e) {
throw $this->createApiCallException($e);
}
}

public function startBuild(string $env = null, array $options = []): Build
{
try {
$sdkBuild = $this->blackfireClient->startBuild($env, $options);

return new Build($sdkBuild->getUuid(), $sdkBuild->getUrl());
} catch (ApiException $e) {
throw $this->createApiCallException($e);
}
}

private function createApiCallException(ApiException $e): ApiCallException
{
// Remove the headers from the exception
$message = preg_replace('/ \[headers: [^\]]*\]$/', '', $e->getMessage());

return new ApiCallException($message, $e->getCode(), $e);
}
}
31 changes: 31 additions & 0 deletions Player/Adapter/BlackfireSdkAdapterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Blackfire Player package.
*
* (c) Fabien Potencier <fabien@blackfire.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Blackfire\Player\Adapter;

use Blackfire\ClientConfiguration;
use Blackfire\Player\Build\Build;
use Blackfire\Profile;
use Blackfire\Profile\Configuration;
use Blackfire\Profile\Request;

interface BlackfireSdkAdapterInterface
{
public function getConfiguration(): ClientConfiguration;

public function createRequest(string|Configuration $config = null): Request;

public function updateProfile(string $uuid, string $title, array $metadata = null): bool;

public function getProfile(string $uuid): Profile;

public function startBuild(string $env = null, array $options = []): Build;
}
21 changes: 21 additions & 0 deletions Player/Build/Build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Blackfire Player package.
*
* (c) Fabien Potencier <fabien@blackfire.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Blackfire\Player\Build;

readonly class Build
{
public function __construct(
public string $uuid,
public null|string $url = null,
) {
}
}
Loading

0 comments on commit ebf8057

Please sign in to comment.