mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
ci(upstream-merge): make branding guide-only
- Remove auto-branding worktree + commit and failing guard - Keep perma-deleted guard; generate VERIFY_branding.log for guidance - verify.sh: record branding findings as notice, never fail rc; write branding log Rationale: branding should be a suggestion, not a gate. Code/maintainers can apply suggested changes explicitly in follow-ups while upstream merge is gated solely by build + API invariants.
This commit is contained in:
@@ -776,57 +776,48 @@ jobs:
|
||||
popd >/dev/null
|
||||
git worktree remove -f "$wt"
|
||||
|
||||
- name: Policy guard checks (branding, perma-deleted)
|
||||
- name: Branding report (guide-only) and perma-deleted guard
|
||||
if: steps.check_upstream.outputs.skip != 'true'
|
||||
env:
|
||||
DEFAULT_BRANCH: ${{ github.event.repository.default_branch || 'main' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Auto-fix branding introduced by upstream in user-visible strings under TUI/CLI
|
||||
# We only touch lines inside quotes/backticks and only in files changed by this merge.
|
||||
# Guide-only branding report: detect user-visible 'Codex' strings under TUI/CLI affected by this merge.
|
||||
mkdir -p .github/auto
|
||||
: > .github/auto/VERIFY_branding.log
|
||||
changed_files=$(git diff --name-only "origin/${DEFAULT_BRANCH}..origin/upstream-merge" -- 'codex-rs/tui/**' 'codex-cli/**' | tr '\n' ' ' || true)
|
||||
if [ -n "${changed_files:-}" ]; then
|
||||
wt=.wt-branding-fix
|
||||
rm -rf "$wt" && git worktree add -f "$wt" origin/upstream-merge >/dev/null
|
||||
pushd "$wt" >/dev/null
|
||||
touched=()
|
||||
for f in $changed_files; do
|
||||
[ -f "$f" ] || continue
|
||||
# Skip obvious non-source or vendored artifacts
|
||||
case "$f" in
|
||||
*.png|*.jpg|*.jpeg|*.gif|*.svg|*.pdf) continue;;
|
||||
esac
|
||||
# Replace 'Codex' with 'Code' only inside quoted/backtick strings (single-line)
|
||||
if rg -n "Codex" -- "$f" >/dev/null 2>&1; then
|
||||
python3 scripts/upstream-merge/branding_fix.py "$f" || true
|
||||
touched+=("$f")
|
||||
fi
|
||||
done
|
||||
if ! git diff --quiet -- ${touched[@]:-}; then
|
||||
git -c user.email="github-actions[bot]@users.noreply.github.com" -c user.name="github-actions[bot]" \
|
||||
commit -a -m "chore(merge): auto-rebrand user-visible strings ('Codex'→'Code') in TUI/CLI files"
|
||||
git push origin HEAD:upstream-merge
|
||||
fi
|
||||
popd >/dev/null
|
||||
git worktree remove -f "$wt" >/dev/null
|
||||
echo "[branding] scanning changed TUI/CLI files for user-visible 'Codex' strings..." | tee -a .github/auto/VERIFY_branding.log
|
||||
git diff -U0 --no-color "origin/${DEFAULT_BRANCH}..origin/upstream-merge" -- $changed_files \
|
||||
| grep -E '^\+' \
|
||||
| grep -E '"[^"]*Codex[^"]*"|'\''[^'\''']*Codex[^'\''']*'\''|`[^`]*Codex[^`]*`' \
|
||||
| grep -Evi '(codex-rs|codex-[a-z0-9_-]+|https?://|Cargo|crate|package|workspace)' \
|
||||
| sed 's/^/+ /' | tee -a .github/auto/VERIFY_branding.log || true
|
||||
echo "[branding] Note: guidance only. No changes applied or committed." | tee -a .github/auto/VERIFY_branding.log
|
||||
else
|
||||
echo "[branding] no TUI/CLI files changed vs origin/${DEFAULT_BRANCH}." | tee -a .github/auto/VERIFY_branding.log
|
||||
fi
|
||||
# docs/** changes are allowed; we may still prefer ours but do not hard-fail here.
|
||||
if git diff --name-only "origin/${DEFAULT_BRANCH}..origin/upstream-merge" -- 'docs/**' | grep -q .; then
|
||||
echo "::notice::docs/** changed on upstream-merge; ensuring agent reviews and preserves local branding where needed." >&2
|
||||
fi
|
||||
# Branding guard: user-facing strings only, in TUI/CLI code (ignore docs/ and comments)
|
||||
changed_files=$(git diff --name-only "origin/${DEFAULT_BRANCH}..origin/upstream-merge" -- 'codex-rs/tui/**' 'codex-cli/**' | tr '\n' ' ' || true)
|
||||
if [ -n "${changed_files:-}" ]; then
|
||||
if git diff -U0 --no-color "origin/${DEFAULT_BRANCH}..origin/upstream-merge" -- $changed_files \
|
||||
| grep -E '^\+' \
|
||||
| grep -E '"[^"]*Codex[^"]*"|'\''[^'\''']*Codex[^'\''']*'\''|`[^`]*Codex[^`]*`' \
|
||||
| grep -Evi '(codex-rs|codex-[a-z0-9_-]+|https?://|Cargo|crate|package|workspace)' >/dev/null 2>&1; then
|
||||
echo "Branding guard tripped: new user-visible 'Codex' strings detected in TUI/CLI code." >&2
|
||||
git diff -U0 --no-color "origin/${DEFAULT_BRANCH}..origin/upstream-merge" -- $changed_files \
|
||||
| grep -E '^\+' \
|
||||
| grep -E '"[^"]*Codex[^"]*"|'\''[^'\''']*Codex[^'\''']*'\''|`[^`]*Codex[^`]*`' \
|
||||
| sed 's/^/> /' >&2 || true
|
||||
exit 1
|
||||
# Perma-deleted guard: ensure none of perma_removed_paths exist on branch
|
||||
if command -v jq >/dev/null 2>&1 && [ -f ".github/merge-policy.json" ]; then
|
||||
mapfile -t perma < <(jq -r '.perma_removed_paths[]? // empty' .github/merge-policy.json 2>/dev/null || true)
|
||||
if [ ${#perma[@]} -gt 0 ]; then
|
||||
wt=.wt-guard
|
||||
rm -rf "$wt" && git worktree add -f "$wt" origin/upstream-merge >/dev/null
|
||||
pushd "$wt" >/dev/null
|
||||
for pat in "${perma[@]}"; do
|
||||
[ -n "${pat:-}" ] || continue
|
||||
if git ls-files -- "$pat" | grep -q .; then
|
||||
echo "Perma-deleted guard: files present matching '$pat'" >&2
|
||||
git ls-files -- "$pat" >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
popd >/dev/null
|
||||
git worktree remove -f "$wt" >/dev/null
|
||||
fi
|
||||
fi
|
||||
# Perma-deleted guard: ensure none of perma_removed_paths exist on branch
|
||||
|
||||
@@ -96,24 +96,27 @@ DEFAULT_BRANCH_LOCAL=${DEFAULT_BRANCH:-main}
|
||||
git fetch origin "$DEFAULT_BRANCH_LOCAL" >/dev/null 2>&1 || true
|
||||
range_ref="origin/${DEFAULT_BRANCH_LOCAL}..HEAD"
|
||||
changed_files=$(git diff --name-only $range_ref -- 'codex-rs/tui/**' 'codex-cli/**' | tr '\n' ' ' || true)
|
||||
branding_log=.github/auto/VERIFY_branding.log
|
||||
: > "$branding_log"
|
||||
if [ -n "${changed_files:-}" ]; then
|
||||
echo "[branding] scanning changed TUI/CLI files for user-visible 'Codex' strings relative to $range_ref" | tee -a "$branding_log"
|
||||
if git diff -U0 --no-color $range_ref -- $changed_files \
|
||||
| grep -E '^\+' \
|
||||
| grep -E '"[^"]*Codex[^"]*"|'\''[^'\''']*Codex[^'\''']*'\''|`[^`]*Codex[^`]*`' \
|
||||
| grep -Evi '(codex-rs|codex-[a-z0-9_-]+|https?://|Cargo|crate|package|workspace)' >/dev/null 2>&1; then
|
||||
echo "[branding] new user-visible 'Codex' strings detected under TUI/CLI relative to $range_ref" | tee -a "$guards_log"
|
||||
git diff -U0 --no-color $range_ref -- $changed_files \
|
||||
| grep -E '^\+' \
|
||||
| grep -E '"[^"]*Codex[^"]*"|'\''[^'\''']*Codex[^'\''']*'\''|`[^`]*Codex[^`]*`' \
|
||||
| sed 's/^/> /' | tee -a "$guards_log" || true
|
||||
status_branding="fail"
|
||||
| grep -Evi '(codex-rs|codex-[a-z0-9_-]+|https?://|Cargo|crate|package|workspace)' \
|
||||
| sed 's/^/+ /' | tee -a "$branding_log"; then
|
||||
echo "[branding] NOTE: guidance only; no changes applied." | tee -a "$branding_log"
|
||||
status_branding="notice"
|
||||
else
|
||||
echo "[branding] no user-visible 'Codex' strings detected in changed TUI/CLI files." | tee -a "$branding_log"
|
||||
fi
|
||||
else
|
||||
echo "[branding] no relevant file changes vs $range_ref; skipping" | tee -a "$guards_log"
|
||||
echo "[branding] no relevant file changes vs $range_ref; skipping" | tee -a "$branding_log"
|
||||
fi
|
||||
|
||||
rc=0
|
||||
if [[ "$status_build" != ok || "$status_api" != ok || "$status_guards" != ok || "$status_branding" != ok ]]; then
|
||||
# Branding is guide-only and does not affect rc. Fail only on build/api/guards.
|
||||
if [[ "$status_build" != ok || "$status_api" != ok || "$status_guards" != ok ]]; then
|
||||
rc=1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user