(fix): verified by label and playwright rerun on failed specs

This commit is contained in:
Saturnino Abril 2026-02-04 09:04:23 +08:00
parent 0263262ef4
commit 5d7c24f07a
4 changed files with 41 additions and 23 deletions

View file

@ -1,5 +1,5 @@
---
name: E2E Tests
name: E2E Tests (smoke-then-full)
on:
# Argo Events Trigger (automated):
# - Triggered by: Enterprise CI/docker-image status check (success)

View file

@ -37,7 +37,7 @@ jobs:
COMMIT_SHA: ${{ steps.pr-info.outputs.head_sha }}
run: |
# Only full tests can be overridden (smoke tests must pass)
FULL_TEST_CONTEXTS=("E2E Tests/playwright-full" "E2E Tests/cypress-full")
FULL_TEST_CONTEXTS=("E2E Tests / playwright-full" "E2E Tests / cypress-full")
for CONTEXT_NAME in "${FULL_TEST_CONTEXTS[@]}"; do
echo "Checking: $CONTEXT_NAME"

View file

@ -19,13 +19,13 @@ jobs:
GH_TOKEN: ${{ github.token }}
LABEL_AUTHOR: ${{ github.event.sender.login }}
run: |
# Check if user is a member of mattermost org
HTTP_STATUS=$(gh api orgs/mattermost/members/${LABEL_AUTHOR} --silent -i 2>/dev/null | head -1 | awk '{print $2}')
if [[ "$HTTP_STATUS" != "204" ]]; then
echo "User ${LABEL_AUTHOR} is not a member of mattermost org (status: ${HTTP_STATUS})"
# Check if user has write permission to the repository
PERMISSION=$(gh api repos/${{ github.repository }}/collaborators/${LABEL_AUTHOR}/permission --jq '.permission' 2>/dev/null || echo "none")
if [[ "$PERMISSION" != "admin" && "$PERMISSION" != "write" ]]; then
echo "User ${LABEL_AUTHOR} doesn't have write permission to the repository (permission: ${PERMISSION})"
exit 1
fi
echo "User ${LABEL_AUTHOR} is a member of mattermost org"
echo "User ${LABEL_AUTHOR} has ${PERMISSION} permission to the repository"
- name: ci/override-failed-statuses
id: override
@ -34,7 +34,7 @@ jobs:
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Only full tests can be overridden (smoke tests must pass)
FULL_TEST_CONTEXTS=("E2E Tests/playwright-full" "E2E Tests/cypress-full")
FULL_TEST_CONTEXTS=("E2E Tests / playwright-full" "E2E Tests / cypress-full")
OVERRIDDEN=""
WEBHOOK_DATA="[]"
@ -62,18 +62,12 @@ jobs:
continue
fi
# Parse and construct new message
if [[ "$CURRENT_DESC" =~ ^([0-9]+)\ failed,\ ([0-9]+)\ passed ]]; then
FAILED="${BASH_REMATCH[1]}"
PASSED="${BASH_REMATCH[2]}"
NEW_MSG="${FAILED} failed (verified), ${PASSED} passed"
elif [[ "$CURRENT_DESC" =~ ^([0-9]+)\ failed\ \([^)]+\),\ ([0-9]+)\ passed ]]; then
FAILED="${BASH_REMATCH[1]}"
PASSED="${BASH_REMATCH[2]}"
NEW_MSG="${FAILED} failed (verified), ${PASSED} passed"
else
NEW_MSG="${CURRENT_DESC} (verified)"
fi
# Prefix existing description
if [ -n "$CURRENT_DESC" ]; then
NEW_MSG="(verified) ${CURRENT_DESC}"
else
NEW_MSG="(verified)"
fi
echo " New: $NEW_MSG"

View file

@ -55,13 +55,37 @@ playwright)
# Convert comma-separated to space-separated for playwright
SPEC_ARGS=$(echo "$SPEC_FILES" | tr ',' ' ')
# Initialize playwright report and logs directory
${MME2E_DC_SERVER} exec -T -u "$MME2E_UID" -- playwright bash <<EOF
cd e2e-tests/playwright
rm -rf logs results storage_state
mkdir -p logs results
touch logs/mattermost.log
EOF
# Install dependencies
mme2e_log "Prepare Playwright: install dependencies"
${MME2E_DC_SERVER} exec -T -u "$MME2E_UID" -- playwright bash <<EOF
cd webapp/
npm install --cache /tmp/empty-cache
cd ../e2e-tests/playwright
npm install --cache /tmp/empty-cache
EOF
# Run playwright with specific spec files
LOGFILE_SUFFIX="${CI_BASE_URL//\//_}_specs"
${MME2E_DC_SERVER} exec -T -u "$MME2E_UID" -- playwright npm run test:ci -- "$SPEC_ARGS" | tee "../playwright/logs/${LOGFILE_SUFFIX}_playwright.log" || true
${MME2E_DC_SERVER} exec -T -u "$MME2E_UID" -- playwright bash -c "cd e2e-tests/playwright && npm run test:ci -- $SPEC_ARGS" | tee "../playwright/logs/${LOGFILE_SUFFIX}_playwright.log" || true
# Collect run results (if results.json exists)
if [ -f ../playwright/results/results.json ]; then
mme2e_log "Results file found at ../playwright/results/results.json"
if [ -f ../playwright/results/reporter/results.json ]; then
jq -f /dev/stdin ../playwright/results/reporter/results.json >../playwright/results/summary.json <<EOF
{
passed: .stats.expected,
failed: .stats.unexpected,
failed_expected: (.stats.skipped + .stats.flaky)
}
EOF
mme2e_log "Results file found and summary generated"
fi
# Collect server logs