Skip to content

Commit

Permalink
Merge pull request #665 from hydephp/fix-not-all-tests-running
Browse files Browse the repository at this point in the history
Internal: Fix framework tests not running in workflow
  • Loading branch information
caendesilva authored Dec 21, 2024
2 parents c5457d6 + d50235b commit 62212ac
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 38 deletions.
41 changes: 18 additions & 23 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,41 @@ jobs:

- name: Install Hyde
shell: bash
run: |
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
git clone -b master https://github.com/hydephp/hyde.git
else
git clone -b develop https://github.com/hydephp/hyde.git
fi
run: git clone -b master https://github.com/hydephp/develop.git --depth 1 runner

- name: Copy over framework source code
- name: Copy over framework code
shell: bash
run: |
mkdir -p ./hyde/packages/hyde/framework/src
rm -rf ./runner/packages/framework/src
rm -rf ./runner/packages/framework/tests
mkdir -p ./runner/packages/framework/src
mkdir -p ./runner/packages/framework/tests
# Since we can't use rsync on Windows, we need to copy the files to a temporary directory and then copy them back
if [ "${{ matrix.os }}" == "windows-latest" ]; then
# For Windows, copy to temp then back to preserve structure
mkdir ../temp
cp -r ./ ../temp
rm -rf ../temp/hyde
cp -r ../temp/. ./hyde/packages/hyde/framework/src
rm -rf ../temp/runner
cp -r ../temp/src/. ./runner/packages/framework/src
cp -r ../temp/tests/. ./runner/packages/framework/tests
else
rsync -a --exclude=hyde ./. ./hyde/packages/hyde/framework/src
# For Unix systems, use rsync
rsync -a --exclude=runner ./src/. ./runner/packages/framework/src
rsync -a --exclude=runner ./tests/. ./runner/packages/framework/tests
fi
- name: Update composer.json to load framework from local source
run: |
cd hyde
composer config repositories.framework path ./packages/hyde/framework
composer require hyde/testing:dev-master hyde/framework:dev-develop
- name: Download test runner configuration
run: cd hyde && curl https://raw.githubusercontent.com/hydephp/develop/master/packages/hyde/phpunit.xml.dist -o phpunit.xml.dist
- name: Install dependencies
run: cd runner && composer install

- name: Set environment to testing
run: cd hyde && echo "ENV=testing" > .env
run: cd runner && echo "ENV=testing" > .env
- name: Execute tests (Unit and Feature tests) via PHPUnit/Pest
run: cd hyde && vendor/bin/pest --log-junit report.xml
run: cd runner && vendor/bin/pest --log-junit report.xml
env:
ENV: testing

- name: Ping statistics server with test results
run: |
cd hyde
cd runner
curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php
php ping.php "Framework CI Matrix" ${{ secrets.OPENANALYTICS_TOKEN }}
2 changes: 1 addition & 1 deletion tests/Unit/AssetServiceUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AssetServiceUnitTest extends UnitTestCase
{
protected function setUp(): void
{
self::needsKernel();
self::setupKernel();
self::mockConfig();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/BaseFoundationCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaseFoundationCollectionTest extends UnitTestCase
{
public function testInit()
{
$this->needsKernel();
$this->setupKernel();

$booted = BaseFoundationCollectionTestClass::init(HydeKernel::getInstance())->boot();

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/BreadcrumbsComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BreadcrumbsComponentTest extends UnitTestCase
{
protected function setUp(): void
{
self::needsKernel();
self::setupKernel();
self::mockConfig();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/BuildTaskUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function testCanWriteToOutput()

public function testCreatedSiteFile()
{
self::needsKernel();
self::setupKernel();

$task = new BufferedTestBuildTask();

Expand All @@ -164,7 +164,7 @@ public function testCreatedSiteFile()

public function testCreatedSiteFileWithAbsolutePath()
{
self::needsKernel();
self::setupKernel();

$task = new BufferedTestBuildTask();

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/HtmlTestingSupportMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
{
parent::setUp();

self::needsKernel();
self::setupKernel();

$this->html ??= file_get_contents(Hyde::vendorPath('resources/views/homepages/welcome.blade.php'));
}
Expand Down
9 changes: 2 additions & 7 deletions tests/Unit/NavItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@
*/
class NavItemTest extends UnitTestCase
{
public static function setUpBeforeClass(): void
{
self::$hasSetUpKernel = false;

self::needsKernel();
self::mockConfig();
}
protected static bool $needsKernel = true;
protected static bool $needsConfig = true;

protected function setUp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/NavigationDataFactoryUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NavigationDataFactoryUnitTest extends UnitTestCase
{
protected function setUp(): void
{
self::needsKernel();
self::setupKernel();
self::mockConfig();
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/Pages/BladePageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,9 @@ public function testMatter()
{
$this->assertInstanceOf(FrontMatter::class, (new BladePage('foo'))->matter());
}

public function testGetCanonicalUrl()
{
$this->markTestSkipped('Not yet implemented');
}
}
5 changes: 5 additions & 0 deletions tests/Unit/Pages/DocumentationPageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ public function testSave()
$this->assertFileExists('_docs/foo.md');
Filesystem::unlink('_docs/foo.md');
}

public function testGetCanonicalUrl()
{
$this->markTestSkipped('Not yet implemented');
}
}
5 changes: 5 additions & 0 deletions tests/Unit/Pages/HtmlPageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,9 @@ public function testMatter()
{
$this->assertInstanceOf(FrontMatter::class, (new HtmlPage('404'))->matter());
}

public function testGetCanonicalUrl()
{
$this->markTestSkipped('Not yet implemented');
}
}
5 changes: 5 additions & 0 deletions tests/Unit/Pages/InMemoryPageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,9 @@ public function testMatter()
{
$this->assertInstanceOf(FrontMatter::class, (new InMemoryPage('404'))->matter());
}

public function testGetCanonicalUrl()
{
$this->markTestSkipped('Not yet implemented');
}
}
5 changes: 5 additions & 0 deletions tests/Unit/Pages/MarkdownPageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,9 @@ public function testSave()
$this->assertFileExists('_pages/foo.md');
Filesystem::unlink('_pages/foo.md');
}

public function testGetCanonicalUrl()
{
$this->markTestSkipped('Not yet implemented');
}
}
5 changes: 5 additions & 0 deletions tests/Unit/Pages/MarkdownPostUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,9 @@ public function testSave()
$this->assertFileExists('_posts/foo.md');
Filesystem::unlink('_posts/foo.md');
}

public function testGetCanonicalUrl()
{
$this->markTestSkipped('Not yet implemented');
}
}
2 changes: 1 addition & 1 deletion tests/Unit/UnixsumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testMethodReturnsSameValueForStringWithMixedEndOfLineSequences()

public function testMethodReturnsSameValueWhenLoadedFromFileUsingShorthand()
{
self::needsKernel();
self::setupKernel();

$string = "foo\nbar\r\nbaz\r\n";

Expand Down

0 comments on commit 62212ac

Please sign in to comment.