diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 00000000..bee15adf --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,68 @@ +name: PHP Unit + +on: + pull_request: + +jobs: + phpunit: + runs-on: ubuntu-latest + + name: PHPUnit test suite + + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: jbukdev_testing + ports: + - 5432:5432 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Node and dependencies + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + - run: npm ci + + - name: Setup PHP with pecl extensions + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: phpredis,imagick + + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.github', '.env');" + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v3 + 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 --quiet --no-ansi --no-interaction --no-progress + + - name: Generate Key + run: php artisan key:generate + + - name: Setup Directory Permissions + run: chmod -R 777 storage bootstrap/cache + + - name: Setup Database + run: php artisan migrate + + - name: Execute PHPUnit Tests + run: vendor/bin/phpunit diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml new file mode 100644 index 00000000..88893a5f --- /dev/null +++ b/.github/workflows/pint.yml @@ -0,0 +1,38 @@ +name: Laravel Pint + +on: + pull_request: + +jobs: + pint: + runs-on: ubuntu-latest + + name: Laravel Pint + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP with pecl extensions + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache composer dependencies + uses: actions/cache@v3 + 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 --quiet --no-ansi --no-interaction --no-progress + + - name: Check Files with Laravel Pint + run: vendor/bin/pint --test diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 75db2288..00000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Run Tests - -on: - pull_request: - -jobs: - phpunit: - runs-on: ubuntu-20.04 - - name: PHPUnit test suite - - services: - postgres: - image: postgres:13.4 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: jbukdev_testing - ports: - - 5432:5432 - - steps: - - uses: actions/checkout@v2 - - name: Cache node modules - uses: actions/cache@v2 - with: - path: ~/.npm - key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - - name: Install npm dependencies - run: npm install - - name: Setup PHP with pecl extension - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: phpcs - - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.github', '.env');" - - name: Install dependencies - run: composer install --quiet --no-ansi --no-interaction --no-progress - - name: Generate key - run: php artisan key:generate - - name: Setup directory permissions - run: chmod -R 777 storage bootstrap/cache - - name: Setup test database - run: php artisan migrate - - name: Execute tests (Unit and Feature tests) via PHPUnit - run: vendor/bin/phpunit - - name: Run phpcs - run: phpcs