diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3ab4917e..006578a0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -31,6 +31,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v4 - uses: ramsey/composer-install@v3 + - name: GH token + if: matrix.operating-system != 'windows-latest' + run: sudo composer config --global --auth github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} - name: Run PHPUnit on Windows if: matrix.operating-system == 'windows-latest' run: vendor/bin/phpunit diff --git a/src/Container.php b/src/Container.php index b756e232..74358f6b 100644 --- a/src/Container.php +++ b/src/Container.php @@ -4,7 +4,7 @@ namespace Php\Pie; -use Composer\Util\Platform; +use Composer\Util\Platform as ComposerPlatform; use Illuminate\Container\Container as IlluminateContainer; use Php\Pie\Building\Build; use Php\Pie\Building\UnixBuild; @@ -44,9 +44,13 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventDispatcher; +use function defined; +use function fopen; use function getcwd; use function str_starts_with; +use const STDIN; + /** @internal This is not public API for PIE, so should not be depended upon unless you accept the risk of BC breaks */ final class Container { @@ -54,7 +58,25 @@ public static function factory(): ContainerInterface { $container = new IlluminateContainer(); $container->instance(ContainerInterface::class, $container); - $container->instance(InputInterface::class, new ArgvInput()); + $container->singleton( + InputInterface::class, + static function () { + $input = new ArgvInput(); + + $stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r'); + $noInteractionEnv = ComposerPlatform::getEnv('COMPOSER_NO_INTERACTION'); + if ( + $noInteractionEnv === false + || $noInteractionEnv === '1' + || $stdin === false + || ! ComposerPlatform::isTty($stdin) + ) { + $input->setInteractive(false); + } + + return $input; + }, + ); $container->instance(OutputInterface::class, new ConsoleOutput()); $container->singleton(EventDispatcher::class, static function () { $displayedBanner = false; @@ -124,7 +146,7 @@ static function (ConsoleCommandEvent $event) use (&$displayedBanner): void { $container->singleton( Build::class, static function (ContainerInterface $container): Build { - if (Platform::isWindows()) { + if (ComposerPlatform::isWindows()) { return $container->get(WindowsBuild::class); } @@ -148,7 +170,7 @@ static function (ContainerInterface $container): Ini\SetupIniApproach { $container->singleton( Install::class, static function (ContainerInterface $container): Install { - if (Platform::isWindows()) { + if (ComposerPlatform::isWindows()) { return $container->get(WindowsInstall::class); } diff --git a/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php b/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php index f3a71305..df5c7c82 100644 --- a/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php +++ b/test/integration/DependencyResolver/ResolveDependencyWithComposerTest.php @@ -42,7 +42,7 @@ public static function validVersionsList(): array ['dev-main#769f906413d6d1e12152f6d34134cbcd347ca253', 'dev-main', self::DOWNLOAD_URL_1_0_1], ]; - if (PHP_VERSION_ID >= 80300 && PHP_VERSION_ID <= 80300) { + if (PHP_VERSION_ID >= 80300 && PHP_VERSION_ID <= 80399) { $versionsAndExpected[] = ['1.0.1-alpha.3@alpha', '1.0.1-alpha.3', self::DOWNLOAD_URL_1_0_1_ALPHA_3]; $versionsAndExpected[] = ['^1.0', '1.0.1', self::DOWNLOAD_URL_1_0_1]; $versionsAndExpected[] = ['^1.1.0@alpha', '1.1.0-beta.1', self::DOWNLOAD_URL_1_1_0_BETA_1]; diff --git a/test/integration/Downloading/GithubPackageReleaseAssetsTest.php b/test/integration/Downloading/GithubPackageReleaseAssetsTest.php index 4dd883c9..e95c82f8 100644 --- a/test/integration/Downloading/GithubPackageReleaseAssetsTest.php +++ b/test/integration/Downloading/GithubPackageReleaseAssetsTest.php @@ -22,6 +22,7 @@ use Php\Pie\Platform\WindowsCompiler; use Php\Pie\Platform\WindowsExtensionAssetName; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\RequiresOperatingSystemFamily; use PHPUnit\Framework\TestCase; use function getenv; @@ -30,6 +31,7 @@ #[CoversClass(GithubPackageReleaseAssets::class)] final class GithubPackageReleaseAssetsTest extends TestCase { + #[RequiresOperatingSystemFamily('Windows')] public function testDeterminingReleaseAssetUrlForWindows(): void { $phpBinaryPath = $this->createMock(PhpBinaryPath::class);