From c06aa01abf53c0fa04c19d385dc3cb908075b286 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Wed, 11 Dec 2024 12:55:22 -0600 Subject: [PATCH] ci: add ability to run additional test tags against PRs (#5658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Intent This PR enhances our test-based workflows by making them more modular, composable, and dispatchable (is that a word?). In addition, we can now specify additional tags with an ampersand (`&critical`, etc) anywhere in PR text to run additional tests against a pull request. ### Changes Modular Workflows * Split core tests (e2e-linux, e2e-windows, unit-tests, integration-tests) into standalone workflows. * Parent workflows can now combine these tests as needed. * Added parameters/inputs to e2e workflows for tagging and filtering e2e tests. * Added bash script to handle combining Playwright tags to run a subset of tests: * Enables AND logic for tags where needed. * Handles β€œbase tags” like `@win` or `@web` Dynamic Tag Parsing * Allows tags (`&critical`, etc) in PR descriptions to be parsed and included dynamically. * Ensures at minimum that critical tests always run (even if not tagged) * Added a bash script to handle parsing PR text to pass along to e2e test runner ### QA Notes * Ran the full test suite and confirmed it passed and reports were available as expected. * Once merged, I plan to manually verify each of the workflow dispatches works as expected, but I did try to test this as much as I could already. ### Screenshots test-full-suite.yml dispatch full-suite test-e2e-linux.yml dispatch linux test-e2e-windows.yml dispatch windows test-e2e-release.yml dispatch latest-release --- .github/actions/e2e-report/action.yml | 100 ------- .github/actions/gen-report-dir/action.yml | 27 ++ .../actions/upload-report-to-s3/action.yml | 5 +- .github/pull_request_template.md | 10 +- .github/workflows/positron-full-test.yml | 264 ------------------ .../workflows/positron-merge-to-branch.yml | 196 ------------- .github/workflows/positron-pull-requests.yml | 14 - .github/workflows/test-e2e-linux.yml | 127 +++++++++ ...se-run-ubuntu.yml => test-e2e-release.yml} | 48 ++-- ...ndows-nightly.yml => test-e2e-windows.yml} | 108 ++++--- .github/workflows/test-full-suite.yml | 99 +++++++ .github/workflows/test-integration.yml | 62 ++++ .github/workflows/test-merge.yml | 42 +++ .github/workflows/test-pull-request.yml | 42 +++ .github/workflows/test-unit.yml | 57 ++++ build/secrets/.secrets.baseline | 43 ++- package.json | 2 +- playwright.config.ts | 8 + scripts/pr-tags-parse.sh | 42 +++ scripts/pr-tags-transform.sh | 64 +++++ test/e2e/helpers/test-tags.ts | 10 + 21 files changed, 710 insertions(+), 660 deletions(-) delete mode 100644 .github/actions/e2e-report/action.yml create mode 100644 .github/actions/gen-report-dir/action.yml delete mode 100644 .github/workflows/positron-full-test.yml delete mode 100644 .github/workflows/positron-merge-to-branch.yml delete mode 100644 .github/workflows/positron-pull-requests.yml create mode 100644 .github/workflows/test-e2e-linux.yml rename .github/workflows/{e2e-test-release-run-ubuntu.yml => test-e2e-release.yml} (75%) rename .github/workflows/{positron-windows-nightly.yml => test-e2e-windows.yml} (66%) create mode 100644 .github/workflows/test-full-suite.yml create mode 100644 .github/workflows/test-integration.yml create mode 100644 .github/workflows/test-merge.yml create mode 100644 .github/workflows/test-pull-request.yml create mode 100644 .github/workflows/test-unit.yml create mode 100644 scripts/pr-tags-parse.sh create mode 100644 scripts/pr-tags-transform.sh diff --git a/.github/actions/e2e-report/action.yml b/.github/actions/e2e-report/action.yml deleted file mode 100644 index 9100c55acf2..00000000000 --- a/.github/actions/e2e-report/action.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: "E2E Report" -description: "Generate and upload E2E reports, and notify stakeholders" -inputs: - aws-s3-bucket: - description: "AWS S3 bucket name" - required: true - aws-role: - description: "AWS role to assume" - required: true - junit-pattern: - description: "Pattern to match JUnit reports" - default: "junit-report-*" - blob-pattern: - description: "Pattern to match blob reports" - default: "blob-report-*" - testrail-api-key: - description: "TestRail API Key" - required: true - github-token: - description: "GitHub token for API calls" - required: true - testrail-project: - description: "TestRail project name" - default: "Positron" - testrail-title: - description: "Title for TestRail runs" - default: "E2E Test Run" - -runs: - using: "composite" - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - - - name: Install AWS CLI - shell: bash - run: | - apt-get update && apt-get install -y unzip python3-pip - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip - unzip -q /tmp/awscliv2.zip -d /tmp - /tmp/aws/install -i $HOME/aws-cli -b $HOME/bin - rm -rf /tmp/aws /tmp/awscliv2.zip - - - name: Add AWS CLI to PATH - shell: bash - run: echo "$HOME/bin" >> $GITHUB_PATH - - - name: Verify AWS CLI installation - shell: bash - run: aws --version - - - name: Download Blob Reports - uses: actions/download-artifact@v4 - with: - path: all-blob-reports - pattern: ${{ inputs.blob-pattern }} - merge-multiple: true - - - name: Merge Blobs into HTML Report - shell: bash - run: npx playwright merge-reports --reporter html ./all-blob-reports - - - name: Upload Playwright Report to S3 - uses: ./.github/actions/upload-report-to-s3 - with: - role-to-assume: ${{ inputs.aws-role }} - - - name: Send HTML Report URL to GitHub Summary - shell: bash - run: | - REPORT_URL="https://d38p2avprg8il3.cloudfront.net/${{ env.REPORT_DIR }}/index.html" - echo "Report URL: $REPORT_URL" - echo "πŸ“„ [Playwright Report]($REPORT_URL)
" > $GITHUB_STEP_SUMMARY - - - name: Download JUnit Reports - uses: actions/download-artifact@v4 - with: - path: all-junit-reports - pattern: ${{ inputs.junit-pattern }} - merge-multiple: true - - - name: Merge JUnit Reports - shell: bash - run: npm install -g junit-report-merger && npx jrm junit.xml "all-junit-reports/*.xml" - - - name: Install trcli - shell: bash - run: apt-get update && apt-get install -y python3-pip && pip3 install trcli - - - name: Upload Test Results to TestRail - shell: bash - run: | - TESTRAIL_TITLE="$(date +'%Y-%m-%d') ${{ inputs.testrail-title }} - $GITHUB_REF_NAME" - echo "TESTRAIL_TITLE=$TESTRAIL_TITLE" >> $GITHUB_ENV - trcli --host "https://posit.testrail.io/" --project "${{ inputs.testrail-project }}" --username testrailautomation@posit.co --key "${{ inputs.testrail-api-key }}" parse_junit --file "./junit.xml" --case-matcher name --title "$TESTRAIL_TITLE" --close-run diff --git a/.github/actions/gen-report-dir/action.yml b/.github/actions/gen-report-dir/action.yml new file mode 100644 index 00000000000..d13157e20a3 --- /dev/null +++ b/.github/actions/gen-report-dir/action.yml @@ -0,0 +1,27 @@ +name: "Generate Report Directory & Send to GH Summary" +description: "Generates a unique REPORT_DIR and appends the report URL to the GitHub Step summary" +inputs: + bucket-url: + description: "Base URL of the S3 bucket or CDN for the report" + required: false + default: "https://d38p2avprg8il3.cloudfront.net" +runs: + using: "composite" + steps: + - name: Generate REPORT_DIR + shell: bash + run: | + # Generate a unique REPORT_DIR + RANDOM_SUFFIX=$RANDOM + REPORT_DIR="playwright-report-${{ github.run_id }}-${RANDOM_SUFFIX}" + + # Export REPORT_DIR for downstream steps + echo "REPORT_DIR=$REPORT_DIR" >> $GITHUB_ENV + echo "Generated REPORT_DIR: $REPORT_DIR" + + # Generate the REPORT_URL + REPORT_URL="${{ inputs.bucket-url }}/$REPORT_DIR/index.html" + echo "Report URL: $REPORT_URL" + + # Append REPORT_URL to the GitHub Step summary + echo "πŸ“„ [Playwright Report]($REPORT_URL)
" >> $GITHUB_STEP_SUMMARY diff --git a/.github/actions/upload-report-to-s3/action.yml b/.github/actions/upload-report-to-s3/action.yml index 0dec03de8bc..bc69ad75ed6 100644 --- a/.github/actions/upload-report-to-s3/action.yml +++ b/.github/actions/upload-report-to-s3/action.yml @@ -4,6 +4,9 @@ inputs: role-to-assume: description: "The AWS role to assume" required: true + report-dir: + description: "The path to the directory containing the Playwright report" + required: true runs: using: "composite" @@ -19,4 +22,4 @@ runs: if: ${{ !cancelled() }} shell: bash run: | - aws s3 cp playwright-report/. s3://positron-test-reports/playwright-report-${{ github.run_id }} --recursive + aws s3 cp playwright-report/. s3://positron-test-reports/${{ inputs.report-dir }} --recursive diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 93d6686c507..e96e4357dd3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,12 +10,16 @@ main branch by either pulling or rebasing. +### Tests to Run + +`@:critical` + ### QA Notes