runner-e2e-tests-playwright #37
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: runner-e2e-tests-playwright | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| pmm_qa_branch: | |
| description: 'Branch for the pmm-qa repository.' | |
| type: string | |
| default: 'main' | |
| required: true | |
| pmm_test_flag: | |
| description: 'Flag to run only specific portion of the tests.' | |
| type: string | |
| required: false | |
| default: '@pmm-ps-integration' | |
| pmm_server_version: | |
| description: 'Version of the pmm server used for testing' | |
| type: string | |
| default: 'perconalab/pmm-server:3-dev-latest' | |
| required: true | |
| pmm_client_version: | |
| description: 'Version of the pmm client used for testing' | |
| type: string | |
| default: 'latest-tarball' | |
| required: true | |
| setup_services: | |
| description: 'Clients for pmm-server' | |
| type: string | |
| default: '--database ps=8.4,QUERY_SOURCE=slowlog' | |
| required: true | |
| workers: | |
| description: 'Number of workers for Playwright tests' | |
| type: number | |
| default: 4 | |
| required: false | |
| launchable_confidence: | |
| description: 'Launchable subset confidence percentage' | |
| type: string | |
| default: '100%' | |
| required: false | |
| workflow_call: | |
| inputs: | |
| pmm_qa_branch: | |
| type: string | |
| required: true | |
| pmm_test_flag: | |
| type: string | |
| required: false | |
| pmm_server_version: | |
| type: string | |
| required: true | |
| pmm_client_version: | |
| type: string | |
| required: true | |
| setup_services: | |
| type: string | |
| required: false | |
| workers: | |
| type: number | |
| required: false | |
| launchable_confidence: | |
| type: string | |
| required: false | |
| secrets: | |
| LAUNCHABLE_TOKEN: | |
| required: false | |
| jobs: | |
| tests: | |
| name: "e2e tests: ${{ inputs.pmm_test_flag || '' }}" | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 60 | |
| env: | |
| SHA: ${{ inputs.sha || 'null' }} | |
| PMM_BASE_URL: https://127.0.0.1 | |
| PMM_TEST_FLAG: ${{ inputs.pmm_test_flag }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PMM_SERVER_VERSION: ${{ inputs.pmm_server_version }} | |
| PMM_QA_BRANCH: ${{ inputs.pmm_qa_branch || github.event.inputs.pmm_qa_branch || 'main' }} | |
| PMM_QA_GIT_BRANCH: ${{ inputs.pmm_qa_branch || github.event.inputs.pmm_qa_branch || 'main' }} | |
| DOCKER_VERSION: ${{ inputs.pmm_server_version || github.event.inputs.pmm_server_version || 'perconalab/pmm-server:3-dev-latest' }} | |
| CLIENT_DOCKER_VERSION: ${{ inputs.pmm_client_image || github.event.inputs.pmm_client_image || 'perconalab/pmm-client:3-dev-latest' }} | |
| PMM_CLIENT_VERSION: ${{ inputs.pmm_client_version || github.event.inputs.pmm_client_version || 'latest-tarball' }} | |
| CLIENT_VERSION: ${{ inputs.pmm_client_version || github.event.inputs.pmm_client_version || 'latest-tarball' }} | |
| WIZARD_ARGS: ${{ inputs.setup_services || github.event.inputs.setup_services || '' }} | |
| TAGS_FOR_TESTS: ${{ inputs.tags_for_tests || github.event.inputs.tags_for_tests || '@settings-fb' }} | |
| ZEPHYR_PMM_API_KEY: ${{ secrets.ZEPHYR_PMM_API_KEY }} | |
| LAUNCHABLE_TOKEN: ${{ secrets.LAUNCHABLE_TOKEN }} | |
| ADMIN_PASSWORD: 'admin-password' | |
| WORKERS: ${{ inputs.workers || 4 }} | |
| LAUNCHABLE_CONFIDENCE: ${{ inputs.launchable_confidence || github.event.inputs.launchable_confidence || '100%' }} | |
| SUBSET_FILE_NAME: 'launchable-subset.txt' | |
| steps: | |
| - name: PMM server version ${{ inputs.pmm_server_version }} and UI tests for flag "${{ inputs.pmm_test_flag }}" on pmm-qa branch ${{ inputs.pmm_qa_branch }} | |
| if: ${{ github.event_name != 'pull_request' && env.SHA != 'null' }} | |
| uses: percona/gh-action-github-status-action@v1 | |
| continue-on-error: true | |
| with: | |
| authToken: ${{ secrets.GITHUB_TOKEN }} | |
| context: "${{ env.PMM_TEST_FLAG }} UI tests" | |
| description: "Test execution ${{ job.status }}" | |
| state: "pending" | |
| repository: ${{ github.repository }} | |
| target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| sha: ${{ env.SHA }} | |
| - name: Checkout pmm-qa repo | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| ref: ${{ env.PMM_QA_BRANCH }} | |
| repository: percona/pmm-qa | |
| path: ./pmm-qa | |
| - name: Cleanup disk space on a worker according to https://github.com/actions/runner-images/issues/2840#issuecomment-790492173 | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
| - name: Install playwright | |
| working-directory: ./pmm-qa/e2e_tests/ | |
| run: | | |
| npm ci | |
| npx playwright install-deps | |
| npx playwright install chromium | |
| - name: 'Create report name' | |
| if: always() | |
| run: | | |
| # TODO: add job id for matrix call | |
| job_tag=$(echo "${{ env.PMM_TEST_FLAG }}" | sed -e "s/@//" -e "s/|/-/g") | |
| report_name="$job_tag" | |
| echo $report_name | |
| echo "REPORT_NAME=$report_name" >> $GITHUB_ENV | |
| - name: Prepare launchable | |
| working-directory: pmm-qa/e2e_tests | |
| run: | | |
| pip3 install --user --upgrade launchable~=1.0 | |
| launchable verify || true | |
| docker pull ${{ env.DOCKER_VERSION }} || true | |
| export DOCKER_IMAGE_ID=$(docker inspect -f '{{index .RepoDigests 0}}' ${{ env.DOCKER_VERSION }} | cut -d@ -f2) || true | |
| echo "Launchable build: ${DOCKER_IMAGE_ID}" | |
| echo "Launchable confidence: ${{ env.LAUNCHABLE_CONFIDENCE }}" | |
| launchable record session --build ${DOCKER_IMAGE_ID} --test-suite "pw-ui-tests-${{ env.REPORT_NAME }}" > launchable-session.txt || true | |
| node launchable-prepare.js "${{ env.PMM_TEST_FLAG }}" | |
| cat test_list.txt | launchable subset --session $(cat launchable-session.txt) --confidence ${{ env.LAUNCHABLE_CONFIDENCE }} --use-case feature-branch playwright > launchable-subset.txt || true | |
| echo "$(cat launchable-subset.txt)" || true | |
| - name: Check if launchable subset is empty | |
| id: check_launchable_subset | |
| working-directory: pmm-qa/e2e_tests | |
| run: | | |
| SUBSET_FILE="${{ env.SUBSET_FILE_NAME }}" | |
| # Skip downstream setup/tests when subset is empty. | |
| if [ -s "$SUBSET_FILE" ]; then | |
| echo "has_subset=true" >> "$GITHUB_OUTPUT" | |
| echo "Launchable subset is not empty. Continue with setup and tests." | |
| else | |
| echo "has_subset=false" >> "$GITHUB_OUTPUT" | |
| echo "Launchable subset is empty. Downstream setup and tests will be skipped." | |
| fi | |
| - name: Skip notice | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset != 'true' }} | |
| run: echo "No tests selected by Launchable subset. Skipping setup and test execution." | |
| - name: Setup PMM Server | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' }} | |
| working-directory: ./pmm-qa/e2e_tests | |
| run: | | |
| ls | |
| docker network create pmm-qa | |
| docker volume create pmm-volume | |
| PWD=$(pwd) docker compose -f docker-compose.yml up -d | |
| timeout 120 bash -c 'until [ "$(curl -s -o /dev/null -w "%{http_code}" --user "admin:${ADMIN_PASSWORD}" http://127.0.0.1/v1/server/readyz)" = "200" ]; do sleep 5; done' | |
| - name: Setup PMM-Client | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' }} | |
| working-directory: ./pmm-qa/qa-integration/pmm_qa | |
| run: sudo bash -x pmm3-client-setup.sh --pmm_server_ip 127.0.0.1 --client_version ${{ env.PMM_CLIENT_VERSION }} --admin_password ${{ env.ADMIN_PASSWORD }} --use_metrics_mode no | |
| - name: Run Setup for E2E Tests | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' }} | |
| working-directory: ./pmm-qa/qa-integration/pmm_qa | |
| run: | | |
| python3 -m venv virtenv | |
| . virtenv/bin/activate | |
| pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install setuptools | |
| python pmm-framework.py --verbosity-level=2 --pmm-server-password=${{ env.ADMIN_PASSWORD }} ${{ env.WIZARD_ARGS }} | |
| - name: 'Run UI tests: ${{ env.PMM_TEST_FLAG }} with launchable' | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' }} | |
| working-directory: pmm-qa/e2e_tests/ | |
| run: | | |
| npx playwright test --grep "${{ env.PMM_TEST_FLAG }}" $(cat "${{ env.SUBSET_FILE_NAME }}") || true | |
| - name: Download logs | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' && always() }} | |
| working-directory: pmm-qa/e2e_tests | |
| run: | | |
| curl --insecure http://admin:${{ env.ADMIN_PASSWORD }}@127.0.0.1/logs.zip --output logs.zip | |
| unzip logs.zip -d logs | |
| - name: Record launchable test results | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' && always() }} | |
| working-directory: pmm-qa/e2e_tests | |
| run: | | |
| launchable record tests --session $(cat launchable-session.txt) playwright --json output/results.json | |
| launchable gate --session "$(cat launchable-session.txt)" | |
| - name: Record launchable logs | |
| if: ${{ steps.check_launchable_subset.outputs.has_subset == 'true' && failure() }} | |
| working-directory: pmm-qa/e2e_tests | |
| continue-on-error: true | |
| run: | | |
| launchable record attachment --session $(cat launchable-session.txt) --include "*.log" logs.zip || true | |
| - name: Generate and Attach the report | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.REPORT_NAME }} | |
| path: | | |
| ./pmm-qa/e2e_tests/playwright-report | |
| ./pmm-qa/e2e_tests/screenshots | |
| ./pmm-qa/e2e_tests/logs | |
| - name: Create status check | |
| uses: percona/gh-action-github-status-action@v1 | |
| if: ${{ github.event_name != 'pull_request' && env.SHA != 'null' && always() }} | |
| continue-on-error: true | |
| with: | |
| authToken: ${{ secrets.GITHUB_TOKEN }} | |
| context: "${{ env.PMM_TEST_FLAG }} UI tests" | |
| description: "Test execution ${{ job.status }}" | |
| state: ${{ job.status }} | |
| repository: ${{ github.repository }} | |
| target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| sha: ${{ env.SHA }} |