|
| 1 | +name: 'Preflight Tests' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + tests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + services: |
| 13 | + postgres: |
| 14 | + image: postgres:latest |
| 15 | + env: |
| 16 | + POSTGRES_DB: tailwind_components |
| 17 | + POSTGRES_USER: tailwind_components |
| 18 | + POSTGRES_PASSWORD: tailwind_components |
| 19 | + ports: |
| 20 | + - 5432:5432 |
| 21 | + options: >- |
| 22 | + --health-cmd="pg_isready" |
| 23 | + --health-interval=5s |
| 24 | + --health-timeout=5s |
| 25 | + --health-retries=3 |
| 26 | +
|
| 27 | + steps: |
| 28 | + - name: π Checkout Code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + submodules: 'true' |
| 32 | + |
| 33 | + - name: π§© Setup Node.js |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: '24.x' |
| 37 | + |
| 38 | + - name: π¦ Install PNPM |
| 39 | + run: npm i pnpm -g |
| 40 | + |
| 41 | + - name: π Cache node_modules Directory |
| 42 | + uses: actions/cache@v4 |
| 43 | + id: node_modules-cache |
| 44 | + with: |
| 45 | + path: node_modules |
| 46 | + key: ${{ runner.OS }}-node_modules-cache-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }} |
| 47 | + |
| 48 | + - name: π Install NPM Packages |
| 49 | + if: steps.node_modules-cache.outputs.cache-hit != 'true' |
| 50 | + run: pnpm i |
| 51 | + |
| 52 | + - name: π Setup Cache Environment |
| 53 | + id: extcache |
| 54 | + uses: shivammathur/cache-extensions@v1 |
| 55 | + with: |
| 56 | + php-version: 8.3 |
| 57 | + extensions: bcmath |
| 58 | + key: php_extensions_cache |
| 59 | + |
| 60 | + - name: π Cache Extensions |
| 61 | + uses: actions/cache@v4 |
| 62 | + with: |
| 63 | + path: ${{ steps.extcache.outputs.dir }} |
| 64 | + key: ${{ steps.extcache.outputs.key }} |
| 65 | + restore-keys: ${{ steps.extcache.outputs.key }} |
| 66 | + |
| 67 | + - name: π Install PHP |
| 68 | + uses: shivammathur/setup-php@v2 |
| 69 | + with: |
| 70 | + php-version: '8.3' |
| 71 | + extensions: bcmath |
| 72 | + |
| 73 | + - name: π Get Composer Cache Directory |
| 74 | + id: composer-cache |
| 75 | + run: | |
| 76 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 77 | +
|
| 78 | + - name: π Cache PHP Dependencies |
| 79 | + uses: actions/cache@v4 |
| 80 | + id: vendor-cache |
| 81 | + with: |
| 82 | + path: vendor |
| 83 | + key: ${{ runner.OS }}-vendor-${{ hashFiles('**/composer.lock') }} |
| 84 | + |
| 85 | + - name: π Copy .env |
| 86 | + run: php -r "file_exists('.env') || copy('.env.example', '.env');" |
| 87 | + |
| 88 | + - name: π¦ Install Composer Dependencies |
| 89 | + if: steps.vendor-cache.outputs.cache-hit != 'true' |
| 90 | + run: composer install --no-interaction --prefer-dist |
| 91 | + |
| 92 | + - name: π§ Directory Permissions |
| 93 | + run: chmod -R 777 storage bootstrap/cache |
| 94 | + |
| 95 | + - name: π Generate App Key |
| 96 | + run: php artisan key:generate |
| 97 | + |
| 98 | + - name: π Build Frontend with Vite |
| 99 | + run: pnpm build |
| 100 | + |
| 101 | + - name: π Run Migrations |
| 102 | + env: |
| 103 | + DB_CONNECTION: pgsql |
| 104 | + DB_DATABASE: tailwind_components |
| 105 | + DB_PORT: 5432 |
| 106 | + DB_USERNAME: tailwind_components |
| 107 | + DB_HOST: 127.0.0.1 |
| 108 | + DB_PASSWORD: tailwind_components |
| 109 | + run: php artisan migrate:fresh --seed |
| 110 | + |
| 111 | + - name: π§ͺ Execute tests (Unit and Feature tests) via PHPUnit |
| 112 | + env: |
| 113 | + DB_CONNECTION: pgsql |
| 114 | + DB_DATABASE: tailwind_components |
| 115 | + DB_PORT: 5432 |
| 116 | + DB_USERNAME: tailwind_components |
| 117 | + DB_HOST: 127.0.0.1 |
| 118 | + DB_PASSWORD: tailwind_components |
| 119 | + run: vendor/bin/phpunit --testdox |
0 commit comments