|
| 1 | +name: UI Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [develop] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ui-tests-vms-${{ github.event.number || github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + ui-tests: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 60 |
| 17 | + name: Playwright E2E Tests |
| 18 | + |
| 19 | + services: |
| 20 | + redis-cache: |
| 21 | + image: redis:alpine |
| 22 | + ports: |
| 23 | + - 13000:6379 |
| 24 | + redis-queue: |
| 25 | + image: redis:alpine |
| 26 | + ports: |
| 27 | + - 11000:6379 |
| 28 | + mariadb: |
| 29 | + image: mariadb:10.6 |
| 30 | + env: |
| 31 | + MYSQL_ROOT_PASSWORD: root |
| 32 | + ports: |
| 33 | + - 3306:3306 |
| 34 | + options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3 |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Clone |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Setup Python |
| 41 | + uses: actions/setup-python@v5 |
| 42 | + with: |
| 43 | + python-version: "3.14" |
| 44 | + |
| 45 | + - name: Setup Node |
| 46 | + uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: 24 |
| 49 | + check-latest: true |
| 50 | + |
| 51 | + - name: Add to Hosts |
| 52 | + run: echo "127.0.0.1 vms.test" | sudo tee -a /etc/hosts |
| 53 | + |
| 54 | + - name: Cache pip |
| 55 | + uses: actions/cache@v4 |
| 56 | + with: |
| 57 | + path: ~/.cache/pip |
| 58 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }} |
| 59 | + |
| 60 | + - name: Get yarn cache directory path |
| 61 | + id: yarn-cache-dir-path |
| 62 | + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT |
| 63 | + |
| 64 | + - name: Cache yarn |
| 65 | + uses: actions/cache@v4 |
| 66 | + with: |
| 67 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 68 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 69 | + |
| 70 | + - name: Cache Playwright browsers |
| 71 | + uses: actions/cache@v4 |
| 72 | + with: |
| 73 | + path: ~/.cache/ms-playwright |
| 74 | + key: ${{ runner.os }}-playwright-${{ hashFiles('**/package.json') }} |
| 75 | + |
| 76 | + - name: Install MariaDB Client |
| 77 | + run: | |
| 78 | + sudo apt update |
| 79 | + sudo apt-get install mariadb-client |
| 80 | +
|
| 81 | + - name: Setup Bench |
| 82 | + run: | |
| 83 | + pip install frappe-bench |
| 84 | + bench init --skip-redis-config-generation --skip-assets --python "$(which python)" ~/frappe-bench |
| 85 | + mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'" |
| 86 | + mariadb --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'" |
| 87 | +
|
| 88 | + - name: Install VMS |
| 89 | + working-directory: /home/runner/frappe-bench |
| 90 | + run: | |
| 91 | + bench get-app vms $GITHUB_WORKSPACE |
| 92 | + bench setup requirements --dev |
| 93 | + bench new-site --db-root-password root --admin-password admin vms.test |
| 94 | + bench --site vms.test install-app vms |
| 95 | + bench build |
| 96 | + env: |
| 97 | + CI: "Yes" |
| 98 | + |
| 99 | + - name: Configure Site |
| 100 | + working-directory: /home/runner/frappe-bench |
| 101 | + run: | |
| 102 | + bench --site vms.test set-config allow_tests true |
| 103 | + bench --site vms.test set-config host_name "http://vms.test:8000" |
| 104 | +
|
| 105 | + - name: Start Frappe Server |
| 106 | + working-directory: /home/runner/frappe-bench |
| 107 | + run: | |
| 108 | + sed -i 's/^watch:/# watch:/g' Procfile |
| 109 | + sed -i 's/^schedule:/# schedule:/g' Procfile |
| 110 | + bench start &> bench_start.log & |
| 111 | + echo "Waiting for Frappe server to start..." |
| 112 | + timeout 60 bash -c 'until curl -s http://vms.test:8000 > /dev/null; do sleep 2; done' |
| 113 | + echo "Frappe server is ready!" |
| 114 | +
|
| 115 | + - name: Install Playwright |
| 116 | + run: | |
| 117 | + cd $GITHUB_WORKSPACE |
| 118 | + npm install |
| 119 | + npx playwright install --with-deps chromium |
| 120 | +
|
| 121 | + - name: Run Playwright Tests |
| 122 | + working-directory: ${{ github.workspace }} |
| 123 | + run: npx playwright test |
| 124 | + env: |
| 125 | + BASE_URL: http://vms.test:8000 |
| 126 | + FRAPPE_USER: Administrator |
| 127 | + FRAPPE_PASSWORD: admin |
| 128 | + |
| 129 | + - name: Upload Playwright Report |
| 130 | + uses: actions/upload-artifact@v4 |
| 131 | + if: always() |
| 132 | + with: |
| 133 | + name: playwright-report |
| 134 | + path: playwright-report/ |
| 135 | + retention-days: 7 |
| 136 | + |
| 137 | + - name: Upload Test Results |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + if: failure() |
| 140 | + with: |
| 141 | + name: test-results |
| 142 | + path: test-results/ |
| 143 | + retention-days: 7 |
| 144 | + |
| 145 | + - name: Show Bench Logs on Failure |
| 146 | + if: failure() |
| 147 | + working-directory: /home/runner/frappe-bench |
| 148 | + run: | |
| 149 | + echo "=== Bench Start Log ===" |
| 150 | + cat bench_start.log || true |
| 151 | + echo "" |
| 152 | + echo "=== Frappe Logs ===" |
| 153 | + cat logs/*.log || true |
0 commit comments