From 34cc59f42a11887c7fa35d54e57500ff3e74b79f Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Thu, 25 Apr 2024 10:57:48 -0700 Subject: [PATCH] Also run tests with strauss.phar --- .github/workflows/main.yml | 12 +++++++++++ scripts/createphar.sh | 20 +++++++++++++++++++ .../Integration/Util/IntegrationTestCase.php | 13 ++++++++++++ 3 files changed, 45 insertions(+) create mode 100755 scripts/createphar.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ba1e6e..c7fb511 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: diff --git a/scripts/createphar.sh b/scripts/createphar.sh new file mode 100755 index 0000000..6985224 --- /dev/null +++ b/scripts/createphar.sh @@ -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 \ No newline at end of file diff --git a/tests/Integration/Util/IntegrationTestCase.php b/tests/Integration/Util/IntegrationTestCase.php index 0fed03e..39e3ff5 100644 --- a/tests/Integration/Util/IntegrationTestCase.php +++ b/tests/Integration/Util/IntegrationTestCase.php @@ -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; @@ -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);