Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a full demo app test (#140)
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\SingleCommandApplication; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\Process\Process; | ||
|
||
require_once __DIR__.'/../vendor/autoload.php'; | ||
|
||
(new SingleCommandApplication())->setCode(function (InputInterface $input, OutputInterface $output) { | ||
$io = new SymfonyStyle($input, $output); | ||
$helper = $this->getHelper('process'); | ||
|
||
$io->section('Setting up the project...'); | ||
|
||
$projectDir = sys_get_temp_dir().'/eloquent'; | ||
$refDir = $projectDir.'-ref'; | ||
$filesystem = new Filesystem(); | ||
if ($filesystem->exists($projectDir)) $filesystem->remove($projectDir); | ||
if ($filesystem->exists($refDir)) $filesystem->remove($refDir); | ||
|
||
$helper->mustRun($output, new Process(['git', 'clone', 'https://github.com/wouterj-nl/symfony-eloquent.git', $refDir])); | ||
$filesystem->mkdir($projectDir); | ||
$helper->mustRun($output, new Process(['git', 'init'], $projectDir)); | ||
|
||
$commits = array_map( | ||
fn ($l) => explode(' ', $l, 2), | ||
array_reverse( | ||
preg_split( | ||
'/\R/', | ||
trim( | ||
(new Process(['git', 'log', '--oneline'], $refDir))->mustRun()->getOutput() | ||
) | ||
) | ||
) | ||
); | ||
|
||
$io->writeln(''); | ||
|
||
$io->section('Running the test'); | ||
|
||
$i = 1; | ||
foreach ($commits as [$commit, $msg]) { | ||
[$op, $val] = explode(': ', $msg, 2); | ||
switch ($op) { | ||
case 'PATCH': | ||
$io->text($i++.'. Patching files ('.$commit.'): '.$val); | ||
$diff = (new Process(['git', 'show', '--pretty=format:%b', $commit], $refDir))->mustRun()->getOutput(); | ||
$helper->mustRun($output, (new Process(['git', 'apply'], $projectDir))->setInput($diff)); | ||
|
||
break; | ||
case 'CMD': | ||
$io->text($i++.'. Running command: <comment>'.$val.'</>'); | ||
$helper->mustRun($output, (Process::fromShellCommandline($val, $projectDir, ['SHELL_VERBOSITY' => '0']))); | ||
|
||
break; | ||
default: | ||
throw new \LogicException('Unknown operation: '.$op); | ||
} | ||
} | ||
})->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: App test | ||
|
||
on: | ||
push: | ||
branches: [2.x] | ||
schedule: | ||
- cron: '4 3 1 * *' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
name: 'Demo application test' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: 'shivammathur/setup-php@v2' | ||
with: | ||
php-version: '8.2' | ||
extensions: xml, pdo_sqlite | ||
|
||
- name: Install dependencies | ||
uses: 'ramsey/composer-install@v2' | ||
|
||
- name: Run script | ||
run: php .github/tester.php -vvv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters