Skip to content

Commit

Permalink
bug #4 Adding windows to ci & fixing Windows binary bug (weaverryan)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the main branch.

Discussion
----------

Adding windows to ci & fixing Windows binary bug

Depends on SymfonyCasts/.github#2

* [x] Merge SymfonyCasts/.github#2 and change the CI config back to the `main` branch

Fixes #2

Commits
-------

3d7aa04 Adding windows to ci & fixing Windows binary bug
  • Loading branch information
weaverryan committed Jun 28, 2023
2 parents 0ba49f3 + 3d7aa04 commit 18d38ba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ jobs:
php-version-matrix: '["8.1", "8.2"]'
php-version-lowest: '8.1'

test_windows:
uses: SymfonyCasts/.github/.github/workflows/phpunit.yaml@main
with:
php-version-matrix: '["8.2"]'
php-version-lowest: '8.2'
runs-on: windows-latest

composer-validate:
uses: SymfonyCasts/.github/.github/workflows/composer-validate.yaml@main

Expand Down
4 changes: 2 additions & 2 deletions src/TailwindBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function downloadExecutable(): void
public static function getBinaryName(): string
{
$os = strtolower(\PHP_OS);
$machine = php_uname('m');
$machine = strtolower(php_uname('m'));

if (str_contains($os, 'darwin')) {
if ('arm64' === $machine) {
Expand Down Expand Up @@ -126,7 +126,7 @@ public static function getBinaryName(): string
if ('arm64' === $machine) {
return 'tailwindcss-windows-arm64.exe';
}
if ('x86_64' === $machine) {
if ('x86_64' === $machine || 'amd64' === $machine) {
return 'tailwindcss-windows-x64.exe';
}

Expand Down
10 changes: 8 additions & 2 deletions tests/TailwindBinaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ public function testBinaryIsDownloadedAndProcessCreated()
$binary = new TailwindBinary($binaryDownloadDir, __DIR__, null, null, $client);
$process = $binary->createProcess(['-i', 'fake.css']);
$this->assertFileExists($binaryDownloadDir.'/'.TailwindBinary::getBinaryName());

// Windows doesn't wrap arguments in quotes
$expectedTemplate = '\\' === \DIRECTORY_SEPARATOR ? '"%s" -i fake.css' : "'%s' '-i' 'fake.css'";

$this->assertSame(
sprintf("'%s' '-i' 'fake.css'", $binaryDownloadDir.'/'.TailwindBinary::getBinaryName()),
sprintf($expectedTemplate, $binaryDownloadDir.'/'.TailwindBinary::getBinaryName()),
$process->getCommandLine()
);
}
Expand All @@ -45,8 +49,10 @@ public function testCustomBinaryUsed()

$binary = new TailwindBinary('', __DIR__, 'custom-binary', null, $client);
$process = $binary->createProcess(['-i', 'fake.css']);
// on windows, arguments are not wrapped in quotes
$expected = '\\' === \DIRECTORY_SEPARATOR ? 'custom-binary -i fake.css' : "'custom-binary' '-i' 'fake.css'";
$this->assertSame(
"'custom-binary' '-i' 'fake.css'",
$expected,
$process->getCommandLine()
);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/TailwindBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

class TailwindBuilderTest extends TestCase
{
protected function tearDown(): void
public function testIntegration(): void
{
$fs = new Filesystem();
$fs->remove(__DIR__.'/fixtures/var/tailwind');
}
if (file_exists(__DIR__.'/fixtures/var/tailwind')) {
$fs->remove(__DIR__.'/fixtures/var/tailwind');
}
$fs->mkdir(__DIR__.'/fixtures/var/tailwind');

public function testIntegration(): void
{
$builder = new TailwindBuilder(
__DIR__.'/fixtures',
__DIR__.'/fixtures/app.css',
Expand Down

0 comments on commit 18d38ba

Please sign in to comment.