Feature Tests #92
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 + cache vendor + upload as artifact | |
| # -------------------------------------------------------------- | |
| 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 | |
| - name: Upload vendor artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: vendor | |
| path: vendor | |
| # -------------------------------------------------------------- | |
| # 2. Node/Vite build + cache node_modules + upload build artifacts | |
| # -------------------------------------------------------------- | |
| 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: Upload build artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: public-build | |
| path: public/build | |
| # -------------------------------------------------------------- | |
| # 3. Run tests (depends on php-setup and frontend-setup) | |
| # -------------------------------------------------------------- | |
| 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: Download vendor artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: vendor | |
| path: vendor | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: public-build | |
| path: public/build | |
| - name: Set up PHP & Composer | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: 8.3 | |
| extensions: mbstring, pdo, mysql, bcmath, tokenizer | |
| tools: composer | |
| # Skip composer install since vendor is restored | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| # Skip npm install/build since public/build and node_modules are already ready | |
| # (If node_modules needed, consider uploading and downloading that artifact too) | |
| - 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 |