# .github/workflows/ci.yml name: CI on: push env: node-modules-cache-name: cache-node-modules-5 composer-packages-cache-name: cache-composer-packages-5 build-artifacts-cache-name: cache-build-artifacts-5 jobs: build-matrix: runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v3 - id: set-matrix run: echo "::set-output name=matrix::{\"php-versions\":[ '8.1' ]}" install-dependencies: needs: build-matrix runs-on: ubuntu-latest strategy: matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - name: Cache node modules id: cache-node-modules uses: actions/cache@v3 with: path: | ~/.cache/Cypress ./node_modules key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.node-modules-cache-name }}-${{ hashFiles('**/package-lock.json') }} - if: steps.cache-composer-packages.outputs.cache-hit != 'true' run: npm install - name: Install Cypress run: npm i cypress - name: Verify Cypress uses: cypress-io/github-action@v4 with: runTests: false - name: Cache composer packages id: cache-composer-packages uses: actions/cache@v3 with: path: ./vendor key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.composer-packages-cache-name }}-${{ hashFiles('**/composer.lock') }} - if: steps.cache-composer-packages.outputs.cache-hit != 'true' run: composer install --no-interaction --ignore-platform-reqs --optimize-autoloader - name: Cache build artifacts id: cache-build-artifacts uses: actions/cache@v3 with: path: | ./public/css ./public/js ./public/mix-manifest.json key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.build-artifacts-cache-name }} - run: npm run prod unit-tests: needs: [ build-matrix, install-dependencies ] runs-on: ubuntu-latest strategy: matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - name: Debug run: | php --version composer --version node --version npm --version - name: Setup Environment run: | cp .env.ci .env touch ./storage/logs/laravel.log touch ./database/database.sqlite - name: Restore node modules id: cache-node-modules uses: actions/cache@v3 with: path: ./node_modules key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.node-modules-cache-name }}-${{ hashFiles('**/package-lock.json') }} - name: Restore composer packages id: cache-composer-packages uses: actions/cache@v3 with: path: ./vendor key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.composer-packages-cache-name }}-${{ hashFiles('**/composer.lock') }} - name: Restore build artifacts id: cache-build-artifacts uses: actions/cache@v3 with: path: | ./public/css ./public/js ./public/mix-manifest.json key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.build-artifacts-cache-name }} - name: Migrate Database run: php artisan migrate --force - name: Directory Permissions run: chmod -R 777 storage bootstrap/cache - name: Dump Autoloader run: composer dump-autoload - name: Run Laravel Server run: php artisan serve & - name: Execute all tests via PHPUnit id: phpunit run: vendor/bin/phpunit --testsuite Unit feature-tests: needs: [ build-matrix, install-dependencies ] runs-on: ubuntu-latest strategy: matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - name: Debug run: | php --version composer --version node --version npm --version - name: Setup Environment run: | cp .env.ci .env touch ./storage/logs/laravel.log touch ./database/database.sqlite - name: Restore node modules id: cache-node-modules uses: actions/cache@v3 with: path: ./node_modules key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.node-modules-cache-name }}-${{ hashFiles('**/package-lock.json') }} - name: Restore composer packages id: cache-composer-packages uses: actions/cache@v3 with: path: ./vendor key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.composer-packages-cache-name }}-${{ hashFiles('**/composer.lock') }} - name: Restore build artifacts id: cache-build-artifacts uses: actions/cache@v3 with: path: | ./public/css ./public/js ./public/mix-manifest.json key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.build-artifacts-cache-name }} - name: Migrate Database run: php artisan migrate --force - name: Directory Permissions run: chmod -R 777 storage bootstrap/cache - name: Dump Autoloader run: composer dump-autoload - name: Run Laravel Server run: php artisan serve & - name: Execute all tests via PHPUnit id: phpunit run: vendor/bin/phpunit --testsuite Feature cypress-tests: needs: [ build-matrix, install-dependencies ] runs-on: ubuntu-latest strategy: matrix: ${{ fromJSON(needs.build-matrix.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3 - name: Install PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - name: Debug run: | php --version composer --version node --version npm --version - name: Setup Environment run: | cp .env.cypress .env touch ./storage/logs/laravel.log touch ./database/database.sqlite - name: Restore node modules id: cache-node-modules uses: actions/cache@v3 with: path: | ~/.cache/Cypress ./node_modules key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.node-modules-cache-name }}-${{ hashFiles('**/package-lock.json') }} - name: Restore composer packages id: cache-composer-packages uses: actions/cache@v3 with: path: ./vendor key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.composer-packages-cache-name }}-${{ hashFiles('**/composer.lock') }} - name: Restore build artifacts id: cache-build-artifacts uses: actions/cache@v3 with: path: | ./public/css ./public/js ./public/mix-manifest.json key: ${{ runner.os }}-php-${{ matrix.php-versions }}-build-${{ env.build-artifacts-cache-name }} - name: Migrate Database run: php artisan migrate --force - name: Directory Permissions run: chmod -R 777 storage bootstrap/cache - name: Dump Autoloader run: composer dump-autoload - name: Run Laravel Server run: php artisan serve & - name: Run Cypress Tests id: cypress-tests uses: cypress-io/github-action@v4 with: install: false wait-on: 'http://127.0.0.1:8000' config: baseUrl=http://127.0.0.1:8000 config-file: ./cypress.config.js record: true project: ./ env: # pass the Dashboard record key as an environment variable CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # pass GitHub token to allow accurately detecting a build vs a re-run build GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # pass the project ID from the secrets through environment variable CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }} - name: Upload screenshots uses: actions/upload-artifact@v3 if: failure() with: name: ${{ github.job }}-screenshots path: cypress/screenshots - name: Upload videos uses: actions/upload-artifact@v3 if: failure() with: name: ${{ github.job }}-videos path: cypress/videos