name: tests on: push: branches: - production pull_request: branches: - production concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: lint: runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup uses: $/.github/actions/setup - name: Generate Wayfinder Types run: php artisan wayfinder:generate --with-form - name: Cache Rector uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: tmp/rector key: ${{ runner.os }}-rector-${{ hashFiles('composer.lock', 'rector.php') }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-rector-${{ hashFiles('composer.lock', 'rector.php') }}- ${{ runner.os }}-rector- - name: Lint run: composer test:lint types: runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup uses: $/.github/actions/setup - name: Generate Wayfinder Types run: php artisan wayfinder:generate --with-form - name: Cache PHPStan uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: tmp/phpstan key: phpstan-cache-${{ github.run_id }} restore-keys: | phpstan-cache- - name: Types run: composer test:types type-coverage: runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup uses: $/.github/actions/setup - name: Type Coverage run: composer test:type-coverage php-tests: runs-on: ubuntu-latest timeout-minutes: 15 strategy: fail-fast: false matrix: shard: [1, 2, 3, 4] services: postgres: image: pgvector/pgvector:pg18 env: POSTGRES_USER: root POSTGRES_PASSWORD: password POSTGRES_DB: testing ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 2s --health-timeout 5s --health-retries 20 env: DB_HOST: 127.0.0.1 DB_PORT: 5432 DB_USERNAME: root DB_PASSWORD: password steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Enable PostgreSQL Search Extensions run: | # Parallel test databases inherit extensions from template1. for database in testing template1; do docker exec "${{ job.services.postgres.id }}" \ psql -U root -d "$database" -v ON_ERROR_STOP=1 \ -c 'CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS pg_trgm;' done - name: Setup PHP uses: $/.github/actions/setup-php with: coverage: pcov - name: Generate Wayfinder Types run: php artisan wayfinder:generate --with-form - name: Cache Built Assets id: build-cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: public/build key: ${{ runner.os }}-build-${{ hashFiles('bun.lock', 'package.json', 'vite.config.ts', 'tsconfig.json', 'resources/**', 'routes/**', 'app/**') }} - name: Setup Frontend if: steps.build-cache.outputs.cache-hit != 'true' uses: $/.github/actions/setup-frontend - name: Build Assets if: steps.build-cache.outputs.cache-hit != 'true' run: bun run build - name: PHP Tests run: | mkdir -p tmp/coverage php vendor/bin/pest --parallel --processes=4 --ci \ --shard=${{ matrix.shard }}/4 \ --coverage-php=tmp/coverage/shard-${{ matrix.shard }}.cov - name: Upload Coverage uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: php-coverage-${{ matrix.shard }} path: tmp/coverage/shard-${{ matrix.shard }}.cov if-no-files-found: error retention-days: 1 frontend-tests: runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup uses: $/.github/actions/setup - name: Frontend Tests run: bun run test:unit tests: needs: [php-tests, frontend-tests] if: ${{ always() }} runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Check Test Jobs env: PHP_TESTS_RESULT: ${{ needs.php-tests.result }} FRONTEND_TESTS_RESULT: ${{ needs.frontend-tests.result }} run: | test "$PHP_TESTS_RESULT" = success test "$FRONTEND_TESTS_RESULT" = success - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup uses: $/.github/actions/setup-php - name: Download Coverage uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: php-coverage-* path: tmp/coverage merge-multiple: true - name: Check Coverage run: php .github/merge-coverage.php tmp/coverage