diff --git a/.env.ci b/.env.ci index bc31893..5ceff83 100644 --- a/.env.ci +++ b/.env.ci @@ -11,9 +11,9 @@ LOG_LEVEL=debug DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=33306 -DB_DATABASE=testing -DB_USERNAME=user -DB_PASSWORD=password +DB_DATABASE=test +DB_USERNAME=root +DB_PASSWORD= SCOUT_DRIVER=collection FILESYSTEM_DISK=local diff --git a/.github/action/setup/action.yml b/.github/action/setup/action.yml new file mode 100644 index 0000000..b46c9d7 --- /dev/null +++ b/.github/action/setup/action.yml @@ -0,0 +1,79 @@ +name: Setup +description: 'Setup PHP, Composer, and NPM.' + +inputs: + php-version: + description: 'PHP version(s) to use.' + required: true + php-extensions: + description: 'PHP extensions to install.' + required: false + default: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, igbinary, msgpack, memcached, gmp, :php-psr + redis-options: + description: 'Redis options to compile with.' + required: false + default: --enable-redis --enable-redis-igbinary --enable-redis-msgpack --enable-redis-lzf --with-liblzf --enable-redis-zstd --with-libzstd --enable-redis-lz4 --with-liblz4 + redis-libs: + description: 'Redis libraries to install.' + required: false + default: liblz4-dev, liblzf-dev, libzstd-dev +runs: + using: composite + steps: + - name: Get PHP Extension Cache Hash + id: php-ext-cache-hash + run: | + concat_values="${PHP_EXTENSIONS}${REDIS_CONFIGURE_OPTS}${REDIS_LIBS}" + echo hash=$(echo $concat_values | md5sum | awk '{print $1}') >> $GITHUB_OUTPUT + shell: bash + + - name: Setup Cache Environment + id: php-ext-cache + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ input.php-version }} + extensions: ${{ input.php-extensions }} + key: ${{ runner.os }}-php-ext-${{ steps.php-ext-cache-hash.outputs.hash }} + + - name: Cache PHP Extensions + uses: actions/cache@v4 + with: + path: ${{ steps.php-ext-cache.outputs.dir }} + key: ${{ steps.php-ext-cache.outputs.key }} + restore-keys: ${{ steps.php-ext-cache.outputs.key }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ input.php-version }} + extensions: ${{ input.php-extensions }} + ini-values: error_reporting=E_ALL + tools: composer:v2 + coverage: none + env: + REDIS_CONFIGURE_OPTS: ${{ input.redis-options }} + REDIS_LIBS: liblz4-dev, liblzf-dev, libzstd-dev + + - name: Get Composer Cache Directory + id: composer-cache + run: echo dir=$(composer config cache-files-dir) >> $GITHUB_OUTPUT + shell: bash + + - name: Cache Composer Dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Get NPM Cache Directory + id: npm-cache + run: echo dir=$(npm config get cache) >> $GITHUB_OUTPUT + shell: bash + + - name: Cache NPM Dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-node- diff --git a/.github/workflows/larastan.yaml b/.github/workflows/larastan.yaml new file mode 100644 index 0000000..b43e456 --- /dev/null +++ b/.github/workflows/larastan.yaml @@ -0,0 +1,21 @@ +name: Larastan + +on: [ push, pull_request ] + +jobs: + larastan: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/action/setup + with: + php-version: 8.3 + + - name: Install Composer Dependencies + run: composer install -q --no-interaction --no-progress --prefer-dist --optimize-autoloader + + - name: Execute Code Static Analysis with Larastan + run: ./vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress --error-format=github diff --git a/.github/workflows/pint.yaml b/.github/workflows/pint.yaml new file mode 100644 index 0000000..f1ade02 --- /dev/null +++ b/.github/workflows/pint.yaml @@ -0,0 +1,33 @@ +name: Pint + +on: + push: + branches-ignore: + - main + +jobs: + pint: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/action/setup + with: + php-version: 8.3 + + - name: Install Composer Dependencies + run: composer install -q --no-interaction --no-progress --prefer-dist --optimize-autoloader + + - name: Run Pint Code Style Fixer + run: ./vendor/bin/pint + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Pint PHP Style Fixes [no ci] + commit_user_name: Pint Bot + skip_fetch: true + file_pattern: '*.php' diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml deleted file mode 100644 index 047a5ed..0000000 --- a/.github/workflows/quality.yaml +++ /dev/null @@ -1,145 +0,0 @@ -name: Quality - -on: [ push, pull_request ] - -jobs: - security-checker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: The PHP Security Checker - uses: symfonycorp/security-checker-action@v5 - - larastan: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: mbstring, dom, fileinfo - coverage: none - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install Composer Dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Prepare Laravel Environment - run: | - php -r "file_exists('.env') || copy('.env.ci', '.env');" - php artisan key:generate - php artisan optimize - - - name: Execute Code Static Analysis with Larastan - run: ./vendor/bin/phpstan analyse -c ./phpstan.neon --no-progress --error-format=github - - rector: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: mbstring, dom, fileinfo - coverage: none - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install Composer Dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Prepare Laravel Environment - run: | - php -r "file_exists('.env') || copy('.env.ci', '.env');" - php artisan key:generate - php artisan optimize - - - name: Rector Cache - uses: actions/cache@v4 - with: - path: .rector/cache - key: ${{ runner.os }}-rector-${{ github.run_id }} - restore-keys: ${{ runner.os }}-rector- - - - run: mkdir -p .rector/cache - - - name: Execute Rector Analysis - run: php vendor/bin/rector process --dry-run --config=rector.php - - # - uses: stefanzweifel/git-auto-commit-action@v5 - # with: - # commit_message: Rector Fixes [no ci] - # commit_user_name: Rector Bot - # skip_fetch: true - # file_pattern: '*.php' - - pint-fixer: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: mbstring, dom, fileinfo - coverage: none - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install Composer Dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Prepare Laravel Environment - run: | - php -r "file_exists('.env') || copy('.env.ci', '.env');" - php artisan key:generate - php artisan optimize - - - name: Run Pint Code Style Fixer - run: ./vendor/bin/pint - - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: Pint PHP Style Fixes [no ci] - commit_user_name: Pint Bot - skip_fetch: true - file_pattern: '*.php' diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml new file mode 100644 index 0000000..6d7eb04 --- /dev/null +++ b/.github/workflows/rector.yaml @@ -0,0 +1,38 @@ +name: Rector + +on: [ push, pull_request ] + +jobs: + rector: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + uses: ./.github/action/setup + with: + php-version: 8.3 + + - name: Install Composer Dependencies + run: composer install -q --no-interaction --no-progress --prefer-dist --optimize-autoloader + + - name: Rector Cache + uses: actions/cache@v4 + with: + path: .rector/cache + key: ${{ runner.os }}-rector-${{ github.run_id }} + restore-keys: ${{ runner.os }}-rector- + + - run: mkdir -p .rector/cache + + - name: Execute Rector Analysis + run: php vendor/bin/rector process --dry-run --config=rector.php + +# Disable automated changes until we have a better understanding of the impact +# - uses: stefanzweifel/git-auto-commit-action@v5 +# with: +# commit_message: Rector Fixes [no ci] +# commit_user_name: Rector Bot +# skip_fetch: true +# file_pattern: '*.php' diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml new file mode 100644 index 0000000..46f5758 --- /dev/null +++ b/.github/workflows/security.yaml @@ -0,0 +1,13 @@ +name: Security + +on: [ push, pull_request ] + +jobs: + security: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: The PHP Security Checker + uses: symfonycorp/security-checker-action@v5 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1894ee0..2ec5011 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,57 +3,31 @@ name: Tests on: [ push, pull_request ] jobs: - laravel-tests: + tests: runs-on: ubuntu-latest services: mysql: image: mysql:8.3 - env: - MYSQL_DATABASE: testing - MYSQL_USER: user - MYSQL_PASSWORD: password - MYSQL_ROOT_PASSWORD: password ports: - 33306:3306 + env: + MYSQL_DATABASE: test + MYSQL_ALLOW_EMPTY_PASSWORD: yes options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 + - name: Setup + uses: ./.github/action/setup with: - php-version: '8.3' - extensions: mbstring, dom, fileinfo - coverage: none - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + php-version: 8.3 - name: Install Composer Dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + run: composer install -q --no-interaction --no-progress --prefer-dist --optimize-autoloader - - name: Get NPM Cache Directory - id: npm-cache - run: echo "NPM_CACHE_DIR=$(npm config get cache)" >> $GITHUB_ENV - - - name: Cache NPM Dependencies - uses: actions/cache@v4 - with: - path: ${{ env.NPM_CACHE_DIR }} - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: ${{ runner.os }}-node- - - - name: Install npm dependencies + - name: Install NPM dependencies run: npm ci - name: Build Front-end Assets @@ -72,7 +46,7 @@ jobs: run: php artisan storage:link - name: Run Tests - run: php artisan test + run: php artisan test --compact - name: Display Laravel Log if: failure()