Feature Tests #91
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Feature Tests | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| APP_NAME: "Computer Science Resources" | |
| APP_ENV: testing | |
| APP_KEY: base64:7aYe15aBsSh6a2ScVwj1JfYjQKUmz9Z5X/GSe64joHA= | |
| APP_DEBUG: 'true' | |
| APP_TIMEZONE: UTC | |
| APP_URL: http://localhost | |
| DB_CONNECTION: mysql | |
| DB_HOST: 127.0.0.1 | |
| DB_PORT: 3306 | |
| DB_DATABASE: testing | |
| DB_USERNAME: root | |
| DB_PASSWORD: password | |
| jobs: | |
| # -------------------------------------------------------------- | |
| # 1. PHP dependencies setup | |
| # -------------------------------------------------------------- | |
| php-setup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP & Composer | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.3 | |
| extensions: mbstring, pdo, mysql, bcmath, tokenizer | |
| tools: composer | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| - name: Install Composer dependencies | |
| run: composer install --no-interaction --prefer-dist | |
| # -------------------------------------------------------------- | |
| # 2. Node/Vite build | |
| # -------------------------------------------------------------- | |
| frontend-setup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| - name: Cache node modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Install NPM dependencies | |
| run: npm ci | |
| - name: Build assets | |
| run: npm run build | |
| - name: Cache Vite build | |
| uses: actions/cache@v3 | |
| with: | |
| path: public/build | |
| key: ${{ runner.os }}-vite-${{ github.sha }} | |
| # -------------------------------------------------------------- | |
| # 3. Run tests | |
| # -------------------------------------------------------------- | |
| run-feature-tests: | |
| runs-on: ubuntu-latest | |
| needs: [php-setup, frontend-setup] | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: password | |
| MYSQL_DATABASE: testing | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping -h 127.0.0.1" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up PHP & Composer | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.3 | |
| extensions: mbstring, pdo, mysql, bcmath, tokenizer | |
| tools: composer | |
| - name: Install Composer dependencies | |
| run: composer install --no-interaction --prefer-dist | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| - name: Install NPM dependencies | |
| run: npm ci | |
| - name: Build assets | |
| run: npm run build | |
| - name: Wait for MySQL to be ready | |
| run: | | |
| echo "Waiting for MySQL to be ready..." | |
| until mysqladmin ping -h 127.0.0.1 -P 3306 --silent; do | |
| sleep 3 | |
| done | |
| - name: Generate app key | |
| run: php artisan key:generate --ansi | |
| - name: Run database migrations | |
| run: php artisan migrate --force | |
| - name: Run feature & unit tests | |
| run: php artisan test |