feat: adding tests.. #19
This file contains hidden or 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
| name: Tests | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| tests: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: password | |
| POSTGRES_DB: trypost_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd="pg_isready" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd="redis-cli ping" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=3 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.4' | |
| extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, bcmath, intl, gd, redis | |
| coverage: none | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install Composer dependencies | |
| run: composer install --no-interaction --prefer-dist --optimize-autoloader | |
| - name: Install npm dependencies | |
| run: npm ci | |
| - name: Build assets | |
| run: npm run build | |
| - name: Prepare environment | |
| run: | | |
| cp .env.example .env | |
| php artisan key:generate | |
| - name: Configure test environment | |
| run: | | |
| sed -i 's/DB_DATABASE=trypost/DB_DATABASE=trypost_test/' .env | |
| sed -i 's/DB_PASSWORD=$/DB_PASSWORD=password/' .env | |
| sed -i 's/CACHE_STORE=redis/CACHE_STORE=array/' .env | |
| sed -i 's/QUEUE_CONNECTION=redis/QUEUE_CONNECTION=sync/' .env | |
| sed -i 's/SESSION_DRIVER=database/SESSION_DRIVER=array/' .env | |
| - name: Run migrations | |
| run: php artisan migrate --force | |
| - name: Run tests | |
| run: php artisan test --compact |