* Automate setup-go-work as a dependency for Make targets (#35476) * automate setup-go-work It's all to easy to forget to `make setup-go-work`, only to run into mysterious build failures. Let's default to doing this automatically, unless `SKIP_SETUP_GO_WORK` is true (or the legacy `IGNORE_GO_WORK_IF_EXISTS`, which was oddly named, since we can't actually ignore it.) * Make setup-go-work recipe fail-fast with set -e * ci: post success to required e2e status contexts when no relevant changes (#35880) * ci: post correct skip status from within cypress/playwright reusable workflows The 'Required Status Checks' ruleset requires e2e-test/cypress-full/enterprise and e2e-test/playwright-full/enterprise on master and release-*.* branches. When a PR has no E2E-relevant changes, the jobs were silently skipped, leaving required statuses unset and the PR permanently blocked. Architecture fix: instead of a separate skip-e2e job in the caller that hardcodes status context names, the skip logic now lives inside the reusable workflows that already own and compute those context names. Changes: - e2e-tests-cypress.yml: add should_run input (default 'true') + skip job that uses the dynamically-computed context_name when should_run == 'false' - e2e-tests-playwright.yml: same pattern - e2e-tests-ci.yml: change e2e-cypress/e2e-playwright job conditions from should_run == 'true' to PR_NUMBER != '' (always run when there's a PR), pass should_run as input to both reusable workflows * Add E2E template workflows for Cypress and Playwright * Add check-e2e-test-only action for E2E workflow * Fix: Remove circular E2E workflow file check - skip tests when only CI files change * Add pull_request trigger to E2E workflow - run automatically on PR events * Fix resolve-pr to use github.event context for automatic pull_request trigger * Fix checkout condition to work with pull_request events * Fix: Remove orphaned fi statement in check-changes script --------- Co-authored-by: yasser khan <attitude3cena.yf@gmail.com>
105 строки
3.8 KiB
YAML
105 строки
3.8 KiB
YAML
---
|
|
name: Check E2E Test Only
|
|
description: Check if PR contains only E2E test changes and determine the appropriate docker image tag
|
|
|
|
inputs:
|
|
base_sha:
|
|
description: Base commit SHA (PR base)
|
|
required: false
|
|
head_sha:
|
|
description: Head commit SHA (PR head)
|
|
required: false
|
|
pr_number:
|
|
description: PR number (used to fetch SHAs via API if base_sha/head_sha not provided)
|
|
required: false
|
|
|
|
outputs:
|
|
e2e_test_only:
|
|
description: Whether the PR contains only E2E test changes (true/false)
|
|
value: ${{ steps.check.outputs.e2e_test_only }}
|
|
image_tag:
|
|
description: Docker image tag to use (base branch ref for E2E-only, short SHA for mixed)
|
|
value: ${{ steps.check.outputs.image_tag }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: ci/check-e2e-test-only
|
|
id: check
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
INPUT_BASE_SHA: ${{ inputs.base_sha }}
|
|
INPUT_HEAD_SHA: ${{ inputs.head_sha }}
|
|
INPUT_PR_NUMBER: ${{ inputs.pr_number }}
|
|
run: |
|
|
# Resolve SHAs and base branch from PR number if not provided
|
|
BASE_REF=""
|
|
if [ -z "$INPUT_BASE_SHA" ] || [ -z "$INPUT_HEAD_SHA" ]; then
|
|
if [ -z "$INPUT_PR_NUMBER" ]; then
|
|
echo "::error::Either base_sha/head_sha or pr_number must be provided"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Resolving SHAs from PR #${INPUT_PR_NUMBER}"
|
|
PR_DATA=$(gh api "repos/${{ github.repository }}/pulls/${INPUT_PR_NUMBER}")
|
|
INPUT_BASE_SHA=$(echo "$PR_DATA" | jq -r '.base.sha')
|
|
INPUT_HEAD_SHA=$(echo "$PR_DATA" | jq -r '.head.sha')
|
|
BASE_REF=$(echo "$PR_DATA" | jq -r '.base.ref')
|
|
|
|
if [ -z "$INPUT_BASE_SHA" ] || [ "$INPUT_BASE_SHA" = "null" ] || \
|
|
[ -z "$INPUT_HEAD_SHA" ] || [ "$INPUT_HEAD_SHA" = "null" ]; then
|
|
echo "::error::Could not resolve SHAs for PR #${INPUT_PR_NUMBER}"
|
|
exit 1
|
|
fi
|
|
elif [ -n "$INPUT_PR_NUMBER" ]; then
|
|
# SHAs provided but we still need the base branch ref
|
|
BASE_REF=$(gh api "repos/${{ github.repository }}/pulls/${INPUT_PR_NUMBER}" --jq '.base.ref')
|
|
fi
|
|
|
|
# Default to master if base ref could not be determined
|
|
if [ -z "$BASE_REF" ] || [ "$BASE_REF" = "null" ]; then
|
|
BASE_REF="master"
|
|
fi
|
|
echo "PR base branch: ${BASE_REF}"
|
|
|
|
SHORT_SHA="${INPUT_HEAD_SHA::7}"
|
|
|
|
# Get changed files - try git first, fall back to API
|
|
CHANGED_FILES=$(git diff --name-only "$INPUT_BASE_SHA"..."$INPUT_HEAD_SHA" 2>/dev/null || \
|
|
gh api "repos/${{ github.repository }}/pulls/${INPUT_PR_NUMBER}/files" --jq '.[].filename' 2>/dev/null || echo "")
|
|
|
|
if [ -z "$CHANGED_FILES" ]; then
|
|
echo "::warning::Could not determine changed files, assuming not E2E-only"
|
|
echo "e2e_test_only=false" >> $GITHUB_OUTPUT
|
|
echo "image_tag=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
fi
|
|
|
|
echo "Changed files:"
|
|
echo "$CHANGED_FILES"
|
|
|
|
# Check if all files are E2E-related
|
|
E2E_TEST_ONLY="true"
|
|
while IFS= read -r file; do
|
|
[ -z "$file" ] && continue
|
|
if [[ ! "$file" =~ ^e2e-tests/ ]] && \
|
|
[[ ! "$file" =~ ^\.github/workflows/e2e- ]] && \
|
|
[[ ! "$file" =~ ^\.github/actions/ ]]; then
|
|
echo "Non-E2E file found: $file"
|
|
E2E_TEST_ONLY="false"
|
|
break
|
|
fi
|
|
done <<< "$CHANGED_FILES"
|
|
|
|
echo "E2E test only: ${E2E_TEST_ONLY}"
|
|
|
|
# Set outputs
|
|
echo "e2e_test_only=${E2E_TEST_ONLY}" >> $GITHUB_OUTPUT
|
|
if [ "$E2E_TEST_ONLY" = "true" ] && \
|
|
{ [ "$BASE_REF" = "master" ] || [[ "$BASE_REF" =~ ^release-[0-9]+\.[0-9]+$ ]]; }; then
|
|
echo "image_tag=${BASE_REF}" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "image_tag=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
fi
|