feat(E2E): testing #12
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: Frontend Test | |
| on: | |
| push: | |
| paths: | |
| - '.github/workflows/frontend-test.yml' | |
| - 'web' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/frontend-test.yml' | |
| - 'web' | |
| jobs: | |
| e2e-tests: | |
| name: E2E Testing (Real APIs) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ ubuntu-latest ] | |
| php-version: [ '8.1' ] | |
| sw-version: [ '5.0.3' ] | |
| node-version: [ '20' ] | |
| env: | |
| SW_VERSION: ${{ matrix.sw-version }} | |
| MYSQL_VERSION: '8.0' | |
| PGSQL_VERSION: '14' | |
| PHP_EXTENSIONS: redis, pdo, pdo_mysql, sqlsrv, pdo_sqlsrv, pdo_odbc, bcmath, swoole-${{ matrix.sw-version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Generate PHP_EXTENSIONS Cache Key | |
| id: ext_key | |
| run: | | |
| md5=$(echo -n "${{ env.PHP_EXTENSIONS }}" | md5sum | awk '{print $1}') | |
| echo "key=${{ matrix.os }}-php-${{ matrix.php-version }}-extensions-$md5" >> $GITHUB_OUTPUT | |
| - name: Setup PHP Extensions cache environment | |
| id: php-extcache | |
| uses: shivammathur/cache-extensions@v1 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: ${{ env.PHP_EXTENSIONS }} | |
| key: ${{ steps.ext_key.outputs.key }} | |
| - name: Setup PHP Cache extensions | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.php-extcache.outputs.dir }} | |
| key: ${{ steps.php-extcache.outputs.key }} | |
| restore-keys: ${{ steps.php-extcache.outputs.key }} | |
| - name: Setup PHP TS | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| extensions: ${{ env.PHP_EXTENSIONS }} | |
| ini-values: opcache.enable_cli=0 | |
| env: | |
| phpts: ts | |
| - name: Set Swoole Shortname | |
| run: | | |
| sudo sh -c "echo swoole.use_shortname='Off' >> /etc/php/${{ matrix.php-version }}/cli/conf.d/swoole.ini" | |
| php --ri swoole | |
| - name: Get Composer Cache Directory | |
| id: composer-cache | |
| run: echo "composer_cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Setup composer cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.composer_cache_dir }} | |
| key: ${{ matrix.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ matrix.os }}-composer- | |
| - name: Setup Backend Packages | |
| run: .github/ci/requirement.install.sh | |
| - name: Setup Services | |
| run: .github/ci/setup.services.sh | |
| - name: Setup Mysql | |
| run: bash .github/ci/setup.mysql.sh | |
| - name: Run Scripts Before Test | |
| run: cp .github/ci/.env.example .env | |
| - name: Print PHP Environments | |
| run: | | |
| sudo rm -rf /etc/php/${{ matrix.php-version }}/cli/conf.d/20-xdebug.ini | |
| php -i | |
| php -m | |
| - name: Install PNPM | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'pnpm' | |
| cache-dependency-path: web/pnpm-lock.yaml | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| run: echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - uses: actions/cache@v4 | |
| name: Setup pnpm Cache | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | |
| key: ${{ matrix.os }}-pnpm-store-${{ hashFiles('web/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ matrix.os }}-pnpm-store- | |
| - name: Setup Frontend Packages | |
| working-directory: web | |
| run: .github/ci/requirement.install.sh | |
| - name: Get Playwright Version | |
| id: playwright-version | |
| working-directory: web | |
| run: echo "playwright_version=$(jq -r '.devDependencies["@playwright/test"]' package.json)" >> $GITHUB_OUTPUT | |
| - name: Setup Playwright Cache | |
| id: playwright-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ matrix.os }}-${{ steps.playwright-version.outputs.playwright_version }} | |
| - name: Install Playwright dependencies | |
| working-directory: web | |
| shell: bash | |
| run: pnpm exec playwright install --with-deps --only-shell | |
| - name: Start Backend Server | |
| working-directory: web | |
| run: .github/ci/run.start-backend-server.sh | |
| env: | |
| DB_DRIVER: mysql | |
| DB_HOST: 127.0.0.1 | |
| DB_DATABASE: mineadmin | |
| - name: Run E2E Tests | |
| working-directory: web | |
| run: .github/ci/run.test.sh | |
| - name: Upload E2E Test Report | |
| if: always() && hashFiles('web/playwright-report/index.html') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: web/playwright-report/ | |
| retention-days: 1 | |
| - name: Stop Backend Server | |
| if: always() | |
| working-directory: web | |
| run: .github/ci/run.stop-backend-server.sh |