changes #5
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: API CI Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| - prod | |
| - qa | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| - prod | |
| - qa | |
| jobs: | |
| lint: | |
| name: "Code Quality & Static Analysis" | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: 'api' | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.1' | |
| extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite | |
| coverage: none | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: api/vendor | |
| key: ${{ runner.os }}-php-8.1-composer-${{ hashFiles('api/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-8.1-composer- | |
| - name: Install Dependencies | |
| run: composer install --prefer-dist --no-progress --no-interaction | |
| laravel-tests: | |
| name: "Tests (PHP ${{ matrix.php-version }})" | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php-version: ['8.0', '8.1', '8.2'] | |
| defaults: | |
| run: | |
| working-directory: 'api' | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite | |
| coverage: xdebug | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: api/vendor | |
| key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('api/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-${{ matrix.php-version }}-composer- | |
| - name: Create .env from secret | |
| run: echo "${{ secrets.LARAVEL_ENV_FILE }}" > .env | |
| - name: Install Dependencies | |
| run: composer install --prefer-dist --no-progress --no-interaction | |
| - name: Generate key | |
| run: php artisan key:generate | |
| - name: Directory Permissions | |
| run: chmod -R 777 storage bootstrap/cache | |
| - name: Create Database | |
| run: | | |
| mkdir -p database | |
| touch database/database.sqlite | |
| - name: Execute tests (Unit and Feature tests) via Pest/PHPUnit | |
| env: | |
| DB_CONNECTION: sqlite | |
| DB_DATABASE: database/database.sqlite | |
| XDEBUG_MODE: coverage | |
| run: php artisan test --coverage | |