Skip to content

Commit

Permalink
fixed the error in the unit test for the package build
Browse files Browse the repository at this point in the history
  • Loading branch information
rosven9856 committed Oct 8, 2024
1 parent 8d35b36 commit a74d958
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ RUN chown -R php:php /usr/bin/app
COPY . /usr/bin/app
WORKDIR /usr/bin/app

ENV GITHUB_WORKSPACE=/usr/bin/app

RUN composer install

VOLUME ["/usr/bin/app"]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ docker build . --build-arg=PHP_VERSION=8.3 -t=composer-package-action

initialization
```shell
docker run --rm -e GITHUB_WORKSPACE=/usr/bin/app -v .:/usr/bin/app composer-package-action composer install
docker run --rm -v .:/usr/bin/app composer-package-action composer install
```

running
```shell
docker run --rm -e GITHUB_WORKSPACE=/usr/bin/app -v .:/usr/bin/app composer-package-action php app.php
docker run --rm -v .:/usr/bin/app composer-package-action php app.php
```

testing
```shell
docker run --rm -e GITHUB_WORKSPACE=/usr/bin/app -v .:/usr/bin/app composer-package-action composer tests
docker run --rm -v .:/usr/bin/app composer-package-action composer tests
```
9 changes: 1 addition & 8 deletions tests/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@
#[CoversClass(Action::class)]
final class ActionTest extends TestCase
{
/**
* @var string
*/
private const string DEFAULT_ENV_GITHUB_WORKSPACE = '/usr/bin/app';

private ?Action $action;

#[\Override]
protected function setUp(): void
{
putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE);
putenv('directory=.build');

$this->action = new Action();
Expand All @@ -32,7 +26,6 @@ protected function setUp(): void
#[\Override]
protected function tearDown(): void
{
putenv('GITHUB_WORKSPACE=');
putenv('directory=');

$this->removeBuildDirectory();
Expand Down Expand Up @@ -71,7 +64,7 @@ private function removeDirectory(string $dir): void
{
$dir = realpath($dir);

if (is_dir($dir)) {
if (is_dir($dir) && is_readable($dir) && is_writable($dir)) {

$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($dir),
Expand Down

0 comments on commit a74d958

Please sign in to comment.