diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a65635c..64c249f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -2,38 +2,68 @@ name: PHP Composer on: push: - branches: [ "main" ] + branches: ['main'] pull_request: - branches: [ "main" ] + branches: ['main'] permissions: contents: read jobs: build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + - uses: ikalnytskyi/action-setup-postgres@v7 + with: + username: postgres + password: postgres + database: mtg-deck-builder-test + port: 5432 + postgres-version: '14' + id: postgres + + - run: psql ${{ steps.postgres.outputs.connection-uri }} -c "SELECT 1" + - run: psql service=${{ steps.postgres.outputs.service-name }} -c "SELECT 1" + - run: psql -c "SELECT 1" + env: + PGSERVICE: ${{ steps.postgres.outputs.service-name }} + + - uses: actions/checkout@v4 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 - - name: Validate composer.json and composer.lock - run: composer validate --strict + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + - name: Install dependencies + run: pnpm install - - name: Install dependencies - run: composer install --prefer-dist --no-progress + - name: Build frontend + run: pnpm build - # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" - # Docs: https://getcomposer.org/doc/articles/scripts.md + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md - - name: Run test suite - run: composer run-script test + - name: Run test suite + run: composer run-script test