|
| 1 | +name: Code Quality |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + test: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + env: |
| 9 | + HUSKY: 0 |
| 10 | + BROADCAST_DRIVER: log |
| 11 | + CACHE_DRIVER: redis |
| 12 | + QUEUE_CONNECTION: redis |
| 13 | + SESSION_DRIVER: redis |
| 14 | + DB_CONNECTION: pgsql |
| 15 | + DB_HOST: localhost |
| 16 | + DB_PASSWORD: postgres |
| 17 | + DB_USERNAME: postgres |
| 18 | + DB_DATABASE: postgres |
| 19 | + |
| 20 | + # Docs: https://docs.github.com/en/actions/using-containerized-services |
| 21 | + services: |
| 22 | + postgres: |
| 23 | + image: postgres:latest |
| 24 | + env: |
| 25 | + POSTGRES_USER: postgres |
| 26 | + POSTGRES_PASSWORD: postgres |
| 27 | + POSTGRES_DB: postgres |
| 28 | + ports: |
| 29 | + - 5432/tcp |
| 30 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 |
| 31 | + |
| 32 | + redis: |
| 33 | + image: redis |
| 34 | + ports: |
| 35 | + - 6379/tcp |
| 36 | + options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 37 | + |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - uses: shivammathur/setup-php@v2 |
| 42 | + with: |
| 43 | + php-version: '8.3' |
| 44 | + extensions: pdo pdo_pgsql pgsql bcmath |
| 45 | + coverage: xdebug |
| 46 | + |
| 47 | + - name: Get composer cache directory |
| 48 | + id: composer-cache |
| 49 | + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 50 | + |
| 51 | + - name: Cache composer dependencies |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 55 | + # Use composer.json for key, if composer.lock is not committed. |
| 56 | + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 57 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 58 | + restore-keys: ${{ runner.os }}-composer- |
| 59 | + |
| 60 | + - name: Install Composer dependencies |
| 61 | + run: composer install --no-progress --prefer-dist --optimize-autoloader |
| 62 | + |
| 63 | + - uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version-file: '.nvmrc' |
| 66 | + cache: 'npm' |
| 67 | + |
| 68 | + - name: Install Node dependencies |
| 69 | + run: npm i --frozen-lockfile |
| 70 | + |
| 71 | + - name: Build JS |
| 72 | + run: npm run build |
| 73 | + |
| 74 | + - name: Prepare the application |
| 75 | + run: | |
| 76 | + php -r "file_exists('.env') || copy('.env.example', '.env');" |
| 77 | + php artisan key:generate |
| 78 | +
|
| 79 | + - name: Clear Config |
| 80 | + run: php artisan config:clear |
| 81 | + |
| 82 | + - name: Run Migration |
| 83 | + run: php artisan migrate -v |
| 84 | + env: |
| 85 | + DB_PORT: ${{ job.services.postgres.ports[5432] }} |
| 86 | + REDIS_PORT: ${{ job.services.redis.ports['6379'] }} |
| 87 | + |
| 88 | + - name: Test with pest |
| 89 | + run: php artisan test --coverage-text |
| 90 | + env: |
| 91 | + DB_PORT: ${{ job.services.postgres.ports[5432] }} |
| 92 | + REDIS_PORT: ${{ job.services.redis.ports['6379'] }} |
| 93 | + |
| 94 | + - name: Pint! |
| 95 | + run: vendor/bin/pint --test |
0 commit comments