Skip to content

Commit 64e4ba2

Browse files
committed
ci: add standard CI requirements shadow outputs
1 parent dd0a6ab commit 64e4ba2

1 file changed

Lines changed: 140 additions & 0 deletions

File tree

.github/workflows/get-requirements.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ on:
2626
run_smart_e2e_selection:
2727
description: 'Whether the smart-e2e-selection job should run. False for non-PR events, forks, or hard E2E skips.'
2828
value: ${{ jobs.detect-changes.outputs.run_smart_e2e_selection }}
29+
locales_only:
30+
description: 'Whether every changed file is a locale translation JSON file under locales/languages.'
31+
value: ${{ jobs.detect-changes.outputs.locales_only }}
32+
locales_validation_needed:
33+
description: 'Whether the future minimal locale validation job should run for locale translation JSON-only changes.'
34+
value: ${{ jobs.detect-changes.outputs.locales_validation_needed }}
35+
standard_ci_needed:
36+
description: 'Whether standard CI is required by the changed-file classification. Shadow-only until enforcement is enabled.'
37+
value: ${{ jobs.detect-changes.outputs.standard_ci_needed }}
38+
requirements_enforced:
39+
description: 'Whether standard-CI/locales requirements enforcement is enabled for this event and target branch.'
40+
value: ${{ jobs.detect-changes.outputs.requirements_enforced }}
2941

3042
jobs:
3143
detect-changes:
@@ -40,6 +52,10 @@ jobs:
4052
changed_files: ${{ steps.set-outputs.outputs.changed_files }}
4153
block_merge_for_e2e_readiness: ${{ steps.set-outputs.outputs.block_merge }}
4254
run_smart_e2e_selection: ${{ steps.set-outputs.outputs.run_smart_e2e_selection }}
55+
locales_only: ${{ steps.set-standard-outputs.outputs.locales_only || 'false' }}
56+
locales_validation_needed: ${{ steps.set-standard-outputs.outputs.locales_validation_needed || 'false' }}
57+
standard_ci_needed: ${{ steps.skip-merge-queue.outputs.up-to-date == 'true' && 'false' || steps.set-standard-outputs.outputs.standard_ci_needed || 'true' }}
58+
requirements_enforced: ${{ steps.set-standard-outputs.outputs.requirements_enforced || 'false' }}
4359
env:
4460
# For a `pull_request` event, the head commit hash is `github.event.pull_request.head.sha`.
4561
# For a `push` event, the head commit hash is `github.sha`.
@@ -234,3 +250,127 @@ jobs:
234250
printf '%s\n' "$CHANGED"
235251
echo "GH_EOF"
236252
} >> "$GITHUB_OUTPUT"
253+
254+
- name: Compute standard CI shadow flags
255+
id: set-standard-outputs
256+
if: steps.skip-merge-queue.outputs.up-to-date != 'true'
257+
env:
258+
GITHUB_EVENT_NAME: ${{ github.event_name }}
259+
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
260+
MERGE_GROUP_BASE_REF: ${{ github.event.merge_group.base_ref }}
261+
REQUIREMENTS_ENFORCED_CONFIG: ${{ vars.MOBILE_CI_REQUIREMENTS_ENFORCED == 'true' && 'true' || 'false' }}
262+
ALL_CHANGES_COUNT: ${{ steps.filter.outputs.all_changes_count }}
263+
LOCALE_TRANSLATION_COUNT: ${{ steps.filter.outputs.locale_translation_files_count }}
264+
run: |
265+
set -euo pipefail
266+
267+
all_changes_count="${ALL_CHANGES_COUNT:-0}"
268+
locale_translation_count="${LOCALE_TRANSLATION_COUNT:-0}"
269+
270+
target_allows_enforcement=false
271+
if [[ "$GITHUB_EVENT_NAME" == "pull_request" && "$PR_BASE_REF" == "main" ]]; then
272+
target_allows_enforcement=true
273+
elif [[ "$GITHUB_EVENT_NAME" == "merge_group" && "$MERGE_GROUP_BASE_REF" == "refs/heads/main" ]]; then
274+
target_allows_enforcement=true
275+
fi
276+
277+
requirements_enforced=false
278+
if [[ "$REQUIREMENTS_ENFORCED_CONFIG" == "true" && "$target_allows_enforcement" == "true" ]]; then
279+
requirements_enforced=true
280+
fi
281+
282+
locales_only=false
283+
locales_validation_needed=false
284+
standard_ci_needed=true
285+
decision_reason="Standard CI remains required because the change set is not locale translation JSON-only."
286+
287+
if [[ "$all_changes_count" -gt 0 && "$locale_translation_count" -eq "$all_changes_count" ]]; then
288+
locales_only=true
289+
locales_validation_needed=true
290+
standard_ci_needed=false
291+
decision_reason="Only locale translation JSON files changed."
292+
elif [[ "$all_changes_count" -eq 0 ]]; then
293+
decision_reason="No changed files were reported; keep the conservative standard CI path."
294+
fi
295+
296+
{
297+
echo "locales_only=$locales_only"
298+
echo "locales_validation_needed=$locales_validation_needed"
299+
echo "standard_ci_needed=$standard_ci_needed"
300+
echo "requirements_enforced=$requirements_enforced"
301+
echo "target_allows_enforcement=$target_allows_enforcement"
302+
echo "decision_reason=$decision_reason"
303+
} >> "$GITHUB_OUTPUT"
304+
305+
- name: Summarize CI requirements decisions
306+
if: steps.skip-merge-queue.outputs.up-to-date != 'true'
307+
env:
308+
ALL_CHANGES_COUNT: ${{ steps.filter.outputs.all_changes_count }}
309+
LOCALE_TRANSLATION_COUNT: ${{ steps.filter.outputs.locale_translation_files_count }}
310+
LOCALES_ONLY: ${{ steps.set-standard-outputs.outputs.locales_only }}
311+
LOCALES_VALIDATION_NEEDED: ${{ steps.set-standard-outputs.outputs.locales_validation_needed }}
312+
STANDARD_CI_NEEDED: ${{ steps.set-standard-outputs.outputs.standard_ci_needed }}
313+
REQUIREMENTS_ENFORCED: ${{ steps.set-standard-outputs.outputs.requirements_enforced }}
314+
TARGET_ALLOWS_ENFORCEMENT: ${{ steps.set-standard-outputs.outputs.target_allows_enforcement }}
315+
DECISION_REASON: ${{ steps.set-standard-outputs.outputs.decision_reason }}
316+
SKIP_E2E: ${{ steps.set-outputs.outputs.e2e_needed != 'true' && 'true' || 'false' }}
317+
ANDROID_E2E_NEEDED: ${{ steps.set-outputs.outputs.android_final }}
318+
IOS_E2E_NEEDED: ${{ steps.set-outputs.outputs.ios_final }}
319+
RUN_SMART_E2E_SELECTION: ${{ steps.set-outputs.outputs.run_smart_e2e_selection }}
320+
BLOCK_MERGE_FOR_E2E_READINESS: ${{ steps.set-outputs.outputs.block_merge }}
321+
run: |
322+
set -euo pipefail
323+
324+
if [[ -z "${GITHUB_STEP_SUMMARY:-}" ]]; then
325+
exit 0
326+
fi
327+
328+
standard_decision="run"
329+
if [[ "$STANDARD_CI_NEEDED" == "false" ]]; then
330+
standard_decision="would skip if enforcement is enabled"
331+
fi
332+
333+
{
334+
echo "### CI requirements shadow summary"
335+
echo
336+
echo "Standard CI jobs still run in this PR. These outputs are for validation before enforcement."
337+
echo
338+
echo "| Signal | Value |"
339+
echo "|---|---|"
340+
echo "| All changed files | ${ALL_CHANGES_COUNT:-0} |"
341+
echo "| Locale translation JSON files | ${LOCALE_TRANSLATION_COUNT:-0} |"
342+
echo "| locales_only | ${LOCALES_ONLY:-false} |"
343+
echo "| locales_validation_needed | ${LOCALES_VALIDATION_NEEDED:-false} |"
344+
echo "| standard_ci_needed | ${STANDARD_CI_NEEDED:-true} |"
345+
echo "| requirements_enforced | ${REQUIREMENTS_ENFORCED:-false} |"
346+
echo "| target_allows_enforcement | ${TARGET_ALLOWS_ENFORCEMENT:-false} |"
347+
echo "| reason | ${DECISION_REASON:-n/a} |"
348+
echo
349+
echo "| E2E signal | Value |"
350+
echo "|---|---|"
351+
echo "| skip_e2e | ${SKIP_E2E:-false} |"
352+
echo "| android_e2e_needed | ${ANDROID_E2E_NEEDED:-false} |"
353+
echo "| ios_e2e_needed | ${IOS_E2E_NEEDED:-false} |"
354+
echo "| run_smart_e2e_selection | ${RUN_SMART_E2E_SELECTION:-false} |"
355+
echo "| block_merge_for_e2e_readiness | ${BLOCK_MERGE_FOR_E2E_READINESS:-false} |"
356+
echo
357+
echo "### Planned standard-CI enforcement mapping"
358+
echo
359+
echo "| Job | Shadow decision |"
360+
echo "|---|---|"
361+
for job in \
362+
check-diff \
363+
dedupe \
364+
git-safe-dependencies \
365+
scripts \
366+
js-bundle-size-check \
367+
unit-tests \
368+
component-view-tests \
369+
merge-unit-and-component-view-tests \
370+
check-workflows \
371+
sonar-cloud \
372+
sonar-cloud-quality-gate-status
373+
do
374+
echo "| \`$job\` | $standard_decision |"
375+
done
376+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)