Skip to content

Commit

Permalink
Also run tests with strauss.phar
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHenryIE committed Apr 25, 2024
1 parent 8c96a2f commit 34cc59f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,32 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: fileinfo

- name: Debugging
run: |
php --version
php -m
composer --version
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run tests
run: vendor/bin/phpunit

- name: Build phar
run:
./scripts/build-phar.sh

- name: Run tests with strauss.phar
run: vendor/bin/phpunit

# TODO: get GitHub Actions annotations working again.
# run: vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer
lint:
Expand Down
20 changes: 20 additions & 0 deletions scripts/createphar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# chmod +x scripts/createphar.sh
# ./scripts/createphar.sh

rm -rf build
composer install --no-dev
wget -O phar-composer.phar https://github.com/clue/phar-composer/releases/download/v1.4.0/phar-composer-1.4.0.phar
mkdir build
cp -R vendor build/vendor
cp -R src build/src
cp -R bin build/bin
cp -R composer.json build
php -d phar.readonly=off phar-composer.phar build ./build/

rm phar-composer.phar
rm -rf build
composer install

php strauss.phar --version
13 changes: 13 additions & 0 deletions tests/Integration/Util/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
*/
class IntegrationTestCase extends TestCase
{
protected string $projectDir;

protected $testsWorkingDir;

public function setUp(): void
{
parent::setUp();

$this->projectDir = getcwd();

$this->testsWorkingDir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR
. 'strausstestdir' . DIRECTORY_SEPARATOR;

Expand All @@ -39,10 +43,19 @@ public function setUp(): void
}

@mkdir($this->testsWorkingDir);

if( file_exists($this->projectDir . '/strauss.phar')) {
echo "strauss.phar found\n";
ob_flush();
}
}

protected function runStrauss(): int
{
if( file_exists($this->projectDir . '/strauss.phar')) {
exec('php ' . $this->projectDir . '/strauss.phar', $output, $return_var);
return $return_var;
}

$inputInterfaceMock = $this->createMock(InputInterface::class);
$outputInterfaceMock = $this->createMock(OutputInterface::class);
Expand Down

0 comments on commit 34cc59f

Please sign in to comment.