| name: Frontend e2e test |
| |
| on: |
| push: |
| branches: |
| - "**" |
| pull_request: |
| branches: |
| - "**" |
| schedule: |
| # Run at 2:00 AM UTC every day |
| # This should be later than the update time of `apache/apisix:dev` |
| # Ref: https://github.com/apache/apisix-docker/blob/master/.github/workflows/apisix_dev_push_docker_hub.yaml#L7C15-L7C16 |
| - cron: '0 2 * * *' |
| repository_dispatch: |
| types: [e2e-test] |
| workflow_dispatch: |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| test: |
| # only run when e2e-test scheduled, workflow_dispatch, repository_dispatch |
| if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' }} |
| timeout-minutes: 40 |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v6 |
| |
| - name: Get PR Labels |
| if: ${{ github.event_name == 'pull_request' }} |
| id: get-labels |
| uses: actions/github-script@v9 |
| with: |
| script: | |
| const labels = context.payload.pull_request.labels.map(label => label.name); |
| core.setOutput("labels", labels.join(",")); |
| - name: Set image label as environment variable |
| if: ${{ github.event_name == 'pull_request' }} |
| run: | |
| export LABELS=${{ steps.get-labels.outputs.labels }} |
| echo "LABELS=${LABELS}" >> $GITHUB_ENV |
| shell: bash |
| |
| # ensure this in https://github.com/apache/infrastructure-actions/blob/main/actions.yml |
| - uses: pnpm/action-setup@v5 |
| name: Install pnpm |
| with: |
| run_install: false |
| |
| - uses: actions/setup-node@v6 |
| with: |
| node-version: "22" |
| cache: "pnpm" |
| |
| - name: Install dependencies |
| run: | |
| pnpm install --frozen-lockfile |
| |
| - name: Install Playwright Browsers |
| run: | |
| pnpm exec playwright install --with-deps |
| |
| - name: Run e2e server |
| working-directory: ./e2e/server |
| run: | |
| docker compose up -d |
| |
| - name: Waiting dashboard service to be healthy |
| working-directory: ./e2e/server |
| run: | |
| TIMEOUT=30 |
| timeout $TIMEOUT bash -c ' |
| until curl -f http://127.0.0.1:9180/ui > /dev/null 2>&1; do |
| echo "Waiting for APISIX dashboard to be ready..." |
| sleep 5 |
| done |
| ' || (echo "APISIX dashboard not ready after $TIMEOUT seconds" && exit 1) |
| |
| - name: Run e2e tests |
| run: | |
| pnpm e2e |
| |
| - uses: actions/upload-artifact@v7 |
| if: ${{ !cancelled() }} |
| with: |
| name: test-results |
| path: apps/site-e2e/test-results/ |
| retention-days: 7 |
| |
| - uses: actions/upload-artifact@v7 |
| if: ${{ !cancelled() }} |
| with: |
| name: playwright-report |
| path: playwright-report/ |
| retention-days: 7 |
| |
| - name: Print Components Logs |
| if: failure() |
| run: | |
| docker ps --format '{{.Names}}' | xargs -I{} bash -c "echo ================= {} ==================== && docker logs {} && echo ================= {} ====================" |