diff --git a/.env.ci b/.env.ci index 9be0b26..816800d 100644 --- a/.env.ci +++ b/.env.ci @@ -9,11 +9,11 @@ LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug DB_CONNECTION=mysql -DB_HOST=localhost -DB_PORT=3306 +DB_HOST=127.0.0.1 +DB_PORT=33306 DB_DATABASE=test -DB_USERNAME=mysql -DB_PASSWORD=mysql +DB_USERNAME=root +DB_PASSWORD= BROADCAST_DRIVER=log FILESYSTEM_DISK=local diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index dff56c5..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,159 +0,0 @@ -name: Forge CI -on: push - -jobs: - laravel-tests: - runs-on: ubuntu-latest - - services: - mysql: - image: mysql:latest - env: - MYSQL_ROOT_PASSWORD: mysql - MYSQL_DATABASE: test - MYSQL_USER: mysql - MYSQL_PASSWORD: mysql - ports: - - 3306:3306 - options: >- - --health-cmd="mysqladmin ping --silent" - --health-interval=10s - --health-timeout=5s - --health-retries=5 - - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' - - - name: Cache NPM - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm-cache- - - - name: Install NPM Packages - run: npm ci - - - name: Build Frontend - run: npm run build - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv - coverage: none - - - name: Configure Laravel Nova Authentication - shell: bash - env: - NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }} - NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }} - run: | - composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY" - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_ENV - - - name: Cache Composer Dependencies - uses: actions/cache@v3 - with: - path: ${{ env.composer_cache_dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install Composer Dependencies - run: composer install -n --prefer-dist - - - name: Prepare Laravel Application - run: | - cp .env.ci .env - php artisan key:generate - - - name: Set Application Cache Directory Permissions - run: chmod -R 777 storage bootstrap/cache - - - name: Run Database Migrations - env: - DB_CONNECTION: mysql - DB_DATABASE: test - DB_PORT: 3306 - DB_USERNAME: mysql - DB_PASSWORD: mysql - run: php artisan migrate - - - name: Execute Unit and Feature Tests - env: - DB_CONNECTION: mysql - DB_DATABASE: test - DB_PORT: 3306 - DB_USERNAME: mysql - DB_PASSWORD: mysql - run: vendor/bin/pest - - - name: Upload App Logs - if: failure() - uses: actions/upload-artifact@v2 - with: - name: app - path: storage/logs - - security-check: - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Security Checker - uses: symfonycorp/security-checker-action@v5 - - larastan: - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv - coverage: none - - - name: Configure Laravel Nova Authentication - shell: bash - env: - NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }} - NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }} - run: | - composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY" - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_ENV - - - name: Cache Composer Dependencies - uses: actions/cache@v3 - with: - path: ${{ env.composer_cache_dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install Composer Dependencies - run: composer install -n --no-dev --prefer-dist - - - name: Execute Code Static Analysis with Larastan - run: | - composer require --dev larastan/larastan - vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress diff --git a/.github/workflows/larastan.yml b/.github/workflows/larastan.yml new file mode 100644 index 0000000..c49c092 --- /dev/null +++ b/.github/workflows/larastan.yml @@ -0,0 +1,67 @@ +name: Laravel Pest Tests + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + larastan: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: none + + - name: Configure Laravel Nova Authentication + shell: bash + env: + NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }} + NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }} + run: | + composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY" + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + id: actions-cache + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Cache PHP dependencies + uses: actions/cache@v4 + id: vendor-cache + with: + path: vendor + key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} + + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.ci', '.env');" + + - name: Install Dependencies + if: steps.vendor-cache.outputs.cache-hit != 'true' + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Update Dependencies with latest stable + if: matrix.dependency-stability == 'prefer-stable' + run: composer update --prefer-stable + + - name: Execute Code Static Analysis with Larastan + run: | + composer require --dev larastan/larastan + vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml new file mode 100644 index 0000000..10cfc7f --- /dev/null +++ b/.github/workflows/pint.yml @@ -0,0 +1,67 @@ +name: Pint Code Style Fixer + +on: + pull_request: + push: + +jobs: + pint-fixer: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: none + + - name: Configure Laravel Nova Authentication + shell: bash + env: + NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }} + NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }} + run: | + composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY" + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + id: actions-cache + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Cache PHP dependencies + uses: actions/cache@v4 + id: vendor-cache + with: + path: vendor + key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} + + - name: Install Dependencies + if: steps.vendor-cache.outputs.cache-hit != 'true' + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Update Dependencies with latest stable + if: matrix.dependency-stability == 'prefer-stable' + run: composer update --prefer-stable + + - name: Pint Code Style Fixer + run: vendor/bin/pint fix + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Apply pint code style changes diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..fa1dda4 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,16 @@ +name: Security Check + +on: + pull_request: + push: + +jobs: + security-check: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Security Checker + uses: symfonycorp/security-checker-action@v5 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..e3c8b01 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,132 @@ +name: Laravel Pest Tests + +on: + pull_request: + push: + branches: + - main + - develop + +jobs: + laravel-tests: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:8.3 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: test + ports: + - 33306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=3 + + strategy: + matrix: + operating-system: [ubuntu-latest] + php-versions: ['8.3'] + dependency-stability: ['prefer-stable'] + + name: P${{ matrix.php-versions }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}} + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Cache node_modules Directory + uses: actions/cache@v4 + id: node_modules-cache + with: + path: node_modules + key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }} + + - name: Install NPM Packages + if: steps.node_modules-cache.outputs.cache-hit != 'true' + run: npm ci + + - name: Build Frontend + run: npm run build + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: none + + - name: Configure Laravel Nova Authentication + shell: bash + env: + NOVA_USERNAME: ${{ secrets.NOVA_USERNAME }} + NOVA_LICENSE_KEY: ${{ secrets.NOVA_LICENSE_KEY }} + run: | + composer config http-basic.nova.laravel.com "$NOVA_USERNAME" "$NOVA_LICENSE_KEY" + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v4 + id: actions-cache + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Cache PHP dependencies + uses: actions/cache@v4 + id: vendor-cache + with: + path: vendor + key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} + + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.ci', '.env');" + + - name: Install Dependencies + if: steps.vendor-cache.outputs.cache-hit != 'true' + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Update Dependencies with latest stable + if: matrix.dependency-stability == 'prefer-stable' + run: composer update --prefer-stable + + - name: Generate key + run: php artisan key:generate + + - name: Directory Permissions + run: chmod -R 777 storage bootstrap/cache + + - name: Run Migrations + env: + DB_CONNECTION: mysql + DB_DATABASE: test + DB_PORT: 33306 + DB_USER: root + run: php artisan migrate + + - name: Execute Unit & Feature Tests + env: + DB_CONNECTION: mysql + DB_DATABASE: test + DB_PORT: 33306 + DB_USER: root + run: vendor/bin/pest + + - name: Upload App Logs + if: failure() + uses: actions/upload-artifact@v2 + with: + name: app + path: storage/logs