Skip to content

Commit

Permalink
--
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Mar 15, 2024
1 parent bc1b2b6 commit feaff34
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 31 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ jobs:
docker compose --ansi=never stop
castor-ansi:
runs-on: ubuntu-latest
matrix:
cmd:
- ansi-false-false
- ansi-false-true
- ansi-true-false
- no-ansi-false-false
- no-ansi-false-true
- no-ansi-true-false

steps:
- name: Checkout repository
Expand All @@ -47,22 +55,4 @@ jobs:
- run: |
set -ex
castor debug
castor ansi
castor-no-ansi:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: castor

- run: |
set -ex
castor debug
castor no-ansi
castor ${{ matrix.cmd }}
66 changes: 54 additions & 12 deletions castor.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,72 @@
<?php

use Castor\Attribute\AsContext;
use Castor\Attribute\AsTask;
use Castor\Context;

use function Castor\run;

#[AsContext(default: true)]
function context(): Context
#[AsTask()]
function ansi_false_false()
{
$c = new Context(
pty: false,
tty: false,
);
run(['docker', 'compose', 'up', '-d'], context: $c);
run(['docker', 'compose', 'stop'], context: $c);
}

#[AsTask()]
function ansi_true_false()
{
$c = new Context(
pty: true,
tty: false,
);
run(['docker', 'compose', 'up', '-d'], context: $c);
run(['docker', 'compose', 'stop'], context: $c);
}

#[AsTask()]
function ansi_false_true()
{
return new Context(
// pty: false,
// tty: false,
$c = new Context(
pty: true,
tty: false,
);
run(['docker', 'compose', 'up', '-d'], context: $c);
run(['docker', 'compose', 'stop'], context: $c);
}

#[AsTask()]
function ansi()
function no_ansi_false_false()
{
run(['docker', 'compose', 'up', '-d']);
run(['docker', 'compose', 'stop']);
$c = new Context(
pty: false,
tty: false,
);
run(['docker', 'compose', '--ansi=never', 'up', '-d'], context: $c);
run(['docker', 'compose', '--ansi=never', 'stop'], context: $c);
}

#[AsTask()]
function no_ansi()
function no_ansi_true_false()
{
run(['docker', 'compose', '--ansi=never', 'up', '-d']);
run(['docker', 'compose', '--ansi=never', 'stop']);
$c = new Context(
pty: true,
tty: false,
);
run(['docker', 'compose', '--ansi=never', 'up', '-d'], context: $c);
run(['docker', 'compose', '--ansi=never', 'stop'], context: $c);
}

#[AsTask()]
function no_ansi_false_true()
{
$c = new Context(
pty: true,
tty: false,
);
run(['docker', 'compose', '--ansi=never', 'up', '-d'], context: $c);
run(['docker', 'compose', '--ansi=never', 'stop'], context: $c);
}

0 comments on commit feaff34

Please sign in to comment.