Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions .github/scripts/tests/test_playwright_merge_group_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def test_merge_groups_upload_no_reports():
for step in steps:
if step["name"] == "Gate verified merge-group shards":
continue
if "failure() && github.event_name == 'merge_group'" in step["if"]:
continue # the #ci-cleanup alert: runs only when the queue fails
if "github.event_name == 'merge_group'" in step["if"]:
continue # queue-only Slack alerts: inline, no reports or checkout
assert "github.event_name != 'merge_group'" in step["if"], step["name"]
# A green queue run costs no artifact storage, but a broken one must still
# leave evidence: re-running it locally is a different SHA on a moving base.
Expand Down Expand Up @@ -240,3 +240,52 @@ def spec(title, status, attempts):
assert "retry pass" in summary.read_text()
assert "real failure" not in summary.read_text()
assert result.stdout.count("::warning") == 1


def test_merge_queue_flaky_tests_alert_pw_health_from_annotations():
steps = workflow("playwright-postgresql-e2e.yml")["jobs"]["playwright-summary"][
"steps"
]
build = next(s for s in steps if s.get("id") == "queue-flaky")
assert "github.event_name == 'merge_group'" in build["if"]
assert "failure()" not in build["if"], "flakes are reported on green queue runs too"
assert "C0C008ZAK0V" in build["run"] # #pw-health
# Reads what the shards already emit instead of uploading reports.
assert '"Retry pass in merge queue"' in build["run"]
assert ".github/scripts" not in build["run"]
shard_warning = next(
s for s in shard_steps() if s.get("id") == "verify-shard-coverage"
)["run"]
assert "::warning title=Retry pass in merge queue::" in shard_warning
permissions = workflow("playwright-postgresql-e2e.yml")["jobs"]["playwright-summary"][
"permissions"
]
assert permissions.get("checks") == "read"


def test_shard_reports_every_retry_pass_in_one_annotation(tmp_path):
# GitHub keeps only 10 warning annotations per step; one per test would
# silently drop the rest before the queue's #pw-health alert reads them.
coverage = next(step for step in shard_steps() if step.get("id") == "verify-shard-coverage")
report_part = coverage["run"][coverage["run"].index('results="$GITHUB_WORKSPACE'):]
output = tmp_path / "openmetadata-ui/src/main/resources/ui/playwright/output"
output.mkdir(parents=True)
titles = [f"flaky {index:02d}" for index in range(12)] + ["50% done"]
specs = [
{"title": title, "file": "Pages/X.spec.ts", "line": 1,
"tests": [{"status": "flaky", "results": [{}, {}]}]}
for title in titles
]
(output / "results.json").write_text(json.dumps({"suites": [{"specs": specs}]}))
summary = tmp_path / "summary.md"
summary.touch()
result = subprocess.run(
["bash", "-e", "-c", report_part],
env={**os.environ, "GITHUB_WORKSPACE": str(tmp_path),
"GITHUB_STEP_SUMMARY": str(summary), "SHARD_ID": "chromium-01"},
capture_output=True, text=True, check=False,
)
assert result.returncode == 0, result.stderr
[warning] = [line for line in result.stdout.splitlines() if line.startswith("::warning")]
message = warning.split("::", 2)[2].replace("%0A", "\n").replace("%25", "%")
assert sorted(line.split(" › ")[1] for line in message.splitlines()) == sorted(titles)
7 changes: 6 additions & 1 deletion .github/workflows/playwright-e2e-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,13 @@ jobs:
echo "### Passed only on retry ($SHARD_ID)" >> "$GITHUB_STEP_SUMMARY"
while read -r test; do
echo "- $test" >> "$GITHUB_STEP_SUMMARY"
echo "::warning title=Retry pass in merge queue::$test"
done <<< "$retried"
# One annotation carrying the whole list: GitHub keeps only 10 warning
# annotations per step, and the queue's #pw-health alert reads these.
# Workflow-command escaping: % -> %25, newline -> %0A.
encoded=${retried//'%'/'%25'}
encoded=${encoded//$'\n'/'%0A'}
echo "::warning title=Retry pass in merge queue::$encoded"
fi

- name: Record shard phase metrics
Expand Down
53 changes: 52 additions & 1 deletion .github/workflows/playwright-postgresql-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ jobs:
timeout-minutes: 20
permissions:
actions: read
# Reads shard annotations for the merge-queue flaky alert.
checks: read
contents: read
# For the budget-breach tracked issue (Signal Playwright budget
# breaches step below).
Expand Down Expand Up @@ -224,6 +226,55 @@ jobs:
errors: true
payload-file-path: ${{ runner.temp }}/queue-slack.json

# Queue flakes go to #pw-health with the daily main-run flakes. Each shard
# leaves one "Retry pass in merge queue" annotation listing its retry
# passes (one per line), so this reads those instead of uploading reports;
# inline for the same reason as the failure alert above.
- name: Build the merge-queue flaky message
id: queue-flaky
if: ${{ always() && !cancelled() && github.event_name == 'merge_group' }}
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
HEAD_REF: ${{ github.event.merge_group.head_ref }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
run: |
set -uo pipefail
prs=$(grep -oE 'pr-[0-9]+' <<< "$HEAD_REF" | sed 's/pr-//' | sort -u | tr '\n' ' ')
flaky=$(gh api --paginate "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT/jobs" \
--jq '.jobs[] | select(.name | contains("playwright-ci")) | .id' 2>/dev/null |
while read -r job; do
gh api --paginate "repos/$GITHUB_REPOSITORY/check-runs/$job/annotations" \
--jq '.[] | select(.title == "Retry pass in merge queue") | .message' 2>/dev/null
done | sed '/^$/d' | sort -u)
if [[ -z "$flaky" ]]; then
echo "No retry passes in this queue run."
exit 0
fi
# shellcheck disable=SC2016 # \(...) is jq interpolation, not shell
jq -n --arg channel C0C008ZAK0V --arg prs "$prs" --arg flaky "$flaky" \
--arg run "$RUN_URL" --arg repo "$REPO_URL" '
def lines($s): $s | split("\n") | map(select(length > 0));
(lines($flaky)) as $tests |
{channel: $channel, text: ([
":large_yellow_circle: *Merge queue: \($tests | length) test(s) passed only on retry*" +
(if ($prs | length) > 0 then " for " + ([$prs | split(" ")[] | select(length > 0) | "<\($repo)/pull/\(.)|#\(.)>"] | join(", ")) else "" end)
] + [$tests[:15][] | "• FLAKY `\(.)`"]
+ (if ($tests | length) > 15 then ["…and \(($tests | length) - 15) more (see the run)"] else [] end)
+ ["<\($run)|run>"] | join("\n"))}' > "$RUNNER_TEMP/queue-flaky.json"
echo "posted=true" >> "$GITHUB_OUTPUT"

- name: Post merge-queue flaky tests to Slack (pw-health)
if: ${{ always() && !cancelled() && github.event_name == 'merge_group' && steps.queue-flaky.outputs.posted == 'true' }}
continue-on-error: true
uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
with:
method: chat.postMessage
token: ${{ secrets.COLLATE_BOT_SLACK_TOKEN }}
errors: true
payload-file-path: ${{ runner.temp }}/queue-flaky.json

# SECURITY: this job runs `require('./.github/scripts/render_playwright_summary.cjs')`
# via `actions/github-script` with GITHUB_TOKEN in scope, so whichever tree we
# check out here becomes trusted code executing with token access. For fork PRs
Expand Down Expand Up @@ -346,7 +397,7 @@ jobs:
# yarn-pkg-cache-* key is written under main by
# populate-playwright-caches.yml, so this hits on every event.
- name: Restore yarn package cache
if: ${{ always() && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
if: ${{ always() && github.event_name != 'merge_group' && needs.playwright.outputs.playwright_ci_result != 'skipped' }}
continue-on-error: true
uses: actions/cache/restore@v6
with:
Expand Down
Loading