|
| 1 | +name: Symfony quickstart |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + schedule: |
| 8 | + - cron: 0 6 * * * |
| 9 | + |
| 10 | +defaults: |
| 11 | + run: |
| 12 | + working-directory: Symfony quickstart |
| 13 | + |
| 14 | +jobs: |
| 15 | + Symfony-quickstart: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + env: |
| 19 | + php: 8.1 |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Setup PHP ${{ env.php }} |
| 25 | + uses: shivammathur/setup-php@v2 |
| 26 | + with: |
| 27 | + php-version: ${{ env.php }} |
| 28 | + |
| 29 | + - name: Create working directory |
| 30 | + run: mkdir --verbose "$GITHUB_WORKFLOW" |
| 31 | + working-directory: |
| 32 | + |
| 33 | + - name: Cache dependencies |
| 34 | + id: composer-cache |
| 35 | + uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: ${{ github.workflow }}/vendor |
| 38 | + key: php-quickstart-symfony-${{ env.php }} |
| 39 | + |
| 40 | + - name: Create Symfony project |
| 41 | + run: composer create-project symfony/skeleton . ^5 |
| 42 | + |
| 43 | + - name: Configure minimum stability for Amp v3. |
| 44 | + run: | |
| 45 | + composer config minimum-stability beta |
| 46 | + composer config prefer-stable true |
| 47 | +
|
| 48 | + - name: Require Steam |
| 49 | + run: composer require --with-dependencies provider/steam |
| 50 | + |
| 51 | + - name: Require Doctrine annotations |
| 52 | + run: composer require doctrine/annotations |
| 53 | + |
| 54 | + - name: Add Porter services |
| 55 | + run: | |
| 56 | + cat <<'.' >>config/services.yaml |
| 57 | + ScriptFUSION\Porter\Porter: |
| 58 | + arguments: |
| 59 | + - '@providers' |
| 60 | + |
| 61 | + providers: |
| 62 | + class: Symfony\Component\DependencyInjection\ServiceLocator |
| 63 | + arguments: |
| 64 | + - |
| 65 | + - '@ScriptFUSION\Porter\Provider\Steam\SteamProvider' |
| 66 | + |
| 67 | + ScriptFUSION\Porter\Provider\Steam\SteamProvider: ~ |
| 68 | + . |
| 69 | +
|
| 70 | + - name: Add AppListAction |
| 71 | + run: | |
| 72 | + cat <<'.' | >src/Controller/AppListAction.php sed 's/ *//' |
| 73 | + <?php |
| 74 | + declare(strict_types=1); |
| 75 | + |
| 76 | + namespace App\Controller; |
| 77 | + |
| 78 | + use ScriptFUSION\Porter\Porter; |
| 79 | + use ScriptFUSION\Porter\Provider\Steam\Resource\GetAppList; |
| 80 | + use ScriptFUSION\Porter\Specification\ImportSpecification; |
| 81 | + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 82 | + use Symfony\Component\HttpFoundation\Response; |
| 83 | + use Symfony\Component\HttpFoundation\StreamedResponse; |
| 84 | + use Symfony\Component\Routing\Annotation\Route; |
| 85 | + |
| 86 | + final class AppListAction extends AbstractController |
| 87 | + { |
| 88 | + #[Route('/')] |
| 89 | + public function __invoke(Porter $porter): Response |
| 90 | + { |
| 91 | + return new StreamedResponse( |
| 92 | + function () use ($porter): void { |
| 93 | + foreach ($porter->import(new ImportSpecification(new GetAppList())) as $app) { |
| 94 | + echo "$app[appid]\n"; |
| 95 | + } |
| 96 | + }, |
| 97 | + Response::HTTP_OK, |
| 98 | + ['content-type' => 'text/plain'], |
| 99 | + ); |
| 100 | + } |
| 101 | + } |
| 102 | + . |
| 103 | +
|
| 104 | + - name: Start web server |
| 105 | + run: sudo php -S localhost:80 public/index.php & |
| 106 | + |
| 107 | + - name: Download home page |
| 108 | + run: curl localhost | tee out |
| 109 | + |
| 110 | + - name: Test output contains over 150k lines |
| 111 | + run: | |
| 112 | + echo Lines: ${lines=$(wc --lines <out)} |
| 113 | + ((lines > 150000)) |
0 commit comments