From 593d6e5300289f2b64cc42a5b7e7b4bf0526f5cb Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sun, 26 May 2024 09:17:55 +0200 Subject: [PATCH 1/3] fix(biomejs): enable TTY only if supported --- config/services.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/services.php b/config/services.php index 91ec6d1..674c1ce 100644 --- a/config/services.php +++ b/config/services.php @@ -5,6 +5,7 @@ use Kocal\BiomeJsBundle\Command\BiomeJsCheckCommand; use Kocal\BiomeJsBundle\Command\BiomeJsCiCommand; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use Symfony\Component\Process\Process; use function Symfony\Component\DependencyInjection\Loader\Configurator\abstract_arg; use function Symfony\Component\DependencyInjection\Loader\Configurator\param; use function Symfony\Component\DependencyInjection\Loader\Configurator\service; @@ -12,7 +13,7 @@ return static function (ContainerConfigurator $container): void { $container->parameters() // Internal parameter to enable/disable TTY mode, useful for tests (if someone has a better idea, feel free to suggest it!) - ->set('biomejs.use_tty', true) + ->set('biomejs.use_tty', Process::isTtySupported()) ; $container->services() @@ -40,4 +41,4 @@ service('biomejs'), ]) ->tag('console.command'); -}; \ No newline at end of file +}; From 54d733785f12bb5bcd82f99dde9fd1b2334c479d Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sun, 26 May 2024 09:22:29 +0200 Subject: [PATCH 2/3] qa --- src/BiomeJs.php | 6 +++--- src/BiomeJsBinary.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/BiomeJs.php b/src/BiomeJs.php index 8451481..e9ee66d 100644 --- a/src/BiomeJs.php +++ b/src/BiomeJs.php @@ -17,7 +17,7 @@ public function __construct( ) { } - public function setOutput(SymfonyStyle|null $output): void + public function setOutput(?SymfonyStyle $output): void { $this->output = $output; } @@ -33,7 +33,7 @@ public function check( bool $organizeImportsEnabled, bool $staged, bool $changed, - string|null $since, + ?string $since, array $path, ): Process { $arguments = []; @@ -81,7 +81,7 @@ public function ci( bool $linterEnabled, bool $organizeImportsEnabled, bool $changed, - string|null $since, + ?string $since, array $path, ): Process { $arguments = []; diff --git a/src/BiomeJsBinary.php b/src/BiomeJsBinary.php index 8d1ea92..5030358 100644 --- a/src/BiomeJsBinary.php +++ b/src/BiomeJsBinary.php @@ -11,20 +11,20 @@ final class BiomeJsBinary { - private SymfonyStyle|null $output = null; + private ?SymfonyStyle $output = null; private HttpClientInterface $httpClient; - private string|null $cachedVersion = null; + private ?string $cachedVersion = null; public function __construct( private readonly string $cwd, private readonly string $binaryDownloadDir, - private readonly string|null $binaryVersion, - HttpClientInterface|null $httpClient = null, + private readonly ?string $binaryVersion, + ?HttpClientInterface $httpClient = null, ) { $this->httpClient = $httpClient ?? HttpClient::create(); } - public function setOutput(SymfonyStyle|null $output): void + public function setOutput(?SymfonyStyle $output): void { $this->output = $output; } From 02a2413831b6f86260b9a9510d0351472f540339 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sun, 26 May 2024 09:53:01 +0200 Subject: [PATCH 3/3] ci: add E2E tests --- .github/workflows/ci.yaml | 53 ++++++++++++++++++++++++++++++++++++++- .gitignore | 2 ++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index aa8309d..1d9022a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -99,4 +99,55 @@ jobs: run: symfony php vendor/bin/phpstan analyze - name: Run PHPUnit - run: symfony php vendor/bin/phpunit \ No newline at end of file + run: symfony php vendor/bin/phpunit + + e2e: + name: E2E + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + tools: symfony-cli + + - name: Install Composer dependencies + run: symfony composer install --prefer-dist --no-interaction --no-progress + + - name: Create a new Symfony project and install kocal/biome-js-bundle + run: | + git config --global user.email "hugo@alliau.me" + git config --global user.name "Hugo Alliaume" + symfony new my_app --webapp + cd my_app + symfony composer config minimum-stability dev + symfony composer config repositories.biome-js-bundle '{"type":"path", "url":"../","options":{"symlink":true}}' + symfony composer require 'kocal/biome-js-bundle:*' --dev + cat << EOF > biome.json + { + "files": { + "ignore": [ + "composer.json", + "assets/vendor/*", + "vendor/*", + "public/bundles/*" + ] + } + } + EOF + + - name: Run Biome CI, which should fails + run: symfony console biome:ci . + continue-on-error: true + working-directory: my_app + + - name: Run Biome Check, and apply fixes + run: symfony console biome:check . --apply + working-directory: my_app + + - name: Run Biome CI, which should now pass + run: symfony console biome:ci . + working-directory: my_app + diff --git a/.gitignore b/.gitignore index 0794651..7a6a9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /vendor/ composer.lock .phpunit.result.cache + +my_app/