Skip to content

Commit

Permalink
added initial set of files
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Mar 17, 2024
0 parents commit 7a9860d
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

"on":
push:
branches:
- main
pull_request:
branches:
- main

jobs:
castor:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
cmd:
- ansi-raw
- ansi-false-false
- ansi-false-true
- ansi-true-false
- no-ansi-raw
- no-ansi-false-false
- no-ansi-false-true
- no-ansi-true-false
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 ${{ matrix.cmd }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.castor.stub.php
87 changes: 87 additions & 0 deletions castor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

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

use function Castor\run;

#[AsTask()]
function ansi_raw()
{
`docker compose --ansi=always up -d`;
`docker compose --ansi=always stop`;
}

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

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

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

#[AsTask()]
function no_ansi_raw()
{
`docker compose --ansi=never up -d`;
`docker compose --ansi=never stop`;
}


#[AsTask()]
function no_ansi_false_false()
{
$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_true_false()
{
$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: false,
tty: true,
);
run(['docker', 'compose', '--ansi=never', 'up', '-d'], context: $c);
run(['docker', 'compose', '--ansi=never', 'stop'], context: $c);
}
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.7"

services:
s1:
image: hello-world
s2:
image: hello-world
s3:
image: hello-world
s4:
image: hello-world
s5:
image: hello-world

0 comments on commit 7a9860d

Please sign in to comment.