diff --git a/.env.ci b/.env.ci new file mode 100644 index 0000000..9be0b26 --- /dev/null +++ b/.env.ci @@ -0,0 +1,23 @@ +APP_NAME="The Forge" +APP_ENV=testing +APP_KEY= +APP_DEBUG=false +APP_URL=http://forge.test + +LOG_CHANNEL=stack +LOG_DEPRECATIONS_CHANNEL=null +LOG_LEVEL=debug + +DB_CONNECTION=mysql +DB_HOST=localhost +DB_PORT=3306 +DB_DATABASE=test +DB_USERNAME=mysql +DB_PASSWORD=mysql + +BROADCAST_DRIVER=log +FILESYSTEM_DISK=local +QUEUE_CONNECTION=sync +CACHE_DRIVER=array +EMAIL_DRIVER=array +SESSION_DRIVER=array diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4f8bc32 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,40 @@ +version: 2 +updates: + # Composer dependencies (PHP) + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "daily" + time: "15:00" # 10am EST + open-pull-requests-limit: 10 + target-branch: "develop" + labels: + - "dependencies" + assignees: + - "Refringe" + + # GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + time: "15:00" # 10am EST + open-pull-requests-limit: 10 + target-branch: "develop" + labels: + - "dependencies" + assignees: + - "Refringe" + + # npm modules (JavaScript) + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + time: "15:00" # 10am EST + open-pull-requests-limit: 10 + target-branch: "develop" + labels: + - "dependencies" + assignees: + - "Refringe" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f728c9a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,143 @@ +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: 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: 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 nunomaduro/larastan + vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress