From f3ecac1ad195a782be6f45a49cb92c2a052d6006 Mon Sep 17 00:00:00 2001 From: chichuan Date: Mon, 10 Aug 2026 11:14:23 +0800 Subject: [PATCH] ci: satisfy workflow shell lint --- .github/workflows/ci.yml | 9 +++++---- test/scripts/changelog_pr_gate_test.go | 11 +++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8933058..61dfcfce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1370,7 +1370,7 @@ jobs: if [ -z "$base_ref" ] || [ "$base_ref" = "0000000000000000000000000000000000000000" ]; then base_ref="$(git rev-parse HEAD^)" fi - candidate_ref="$(git rev-parse HEAD^{commit})" + candidate_ref="$(git rev-parse 'HEAD^{commit}')" if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && [ "$candidate_ref" != "$PR_HEAD_SHA" ]; then echo "Compatibility checkout $candidate_ref does not match PR head $PR_HEAD_SHA" >&2 exit 1 @@ -1391,9 +1391,10 @@ jobs: exit 1 fi git rev-parse --verify "${stable_ref}^{commit}" >/dev/null - echo "COMPATIBILITY_BASE_REF=$base_ref" >> "$GITHUB_ENV" - echo "COMPATIBILITY_STABLE_REF=$stable_ref" >> "$GITHUB_ENV" - echo "COMPATIBILITY_CANDIDATE_REF=$candidate_ref" >> "$GITHUB_ENV" + printf '%s\n' \ + "COMPATIBILITY_BASE_REF=$base_ref" \ + "COMPATIBILITY_STABLE_REF=$stable_ref" \ + "COMPATIBILITY_CANDIDATE_REF=$candidate_ref" >> "$GITHUB_ENV" - name: Check historical commands, help, and complete CLI compatibility if: ${{ needs.lint.outputs.changelog_only != 'true' && needs.lint.outputs.docs_only != 'true' && (needs.lint.outputs.full_suite == 'true' || needs.lint.outputs.interface_sensitive == 'true') }} diff --git a/test/scripts/changelog_pr_gate_test.go b/test/scripts/changelog_pr_gate_test.go index a69cf1a1..b69e2cd6 100644 --- a/test/scripts/changelog_pr_gate_test.go +++ b/test/scripts/changelog_pr_gate_test.go @@ -412,16 +412,19 @@ func TestInterfaceIntegrityWorkflowContract(t *testing.T) { } } for _, want := range []string{ - `candidate_ref="$(git rev-parse HEAD^{commit})"`, + `candidate_ref="$(git rev-parse 'HEAD^{commit}')"`, `[ "$candidate_ref" != "$PR_HEAD_SHA" ]`, - `echo "COMPATIBILITY_BASE_REF=$base_ref" >> "$GITHUB_ENV"`, - `echo "COMPATIBILITY_STABLE_REF=$stable_ref" >> "$GITHUB_ENV"`, - `echo "COMPATIBILITY_CANDIDATE_REF=$candidate_ref" >> "$GITHUB_ENV"`, + `"COMPATIBILITY_BASE_REF=$base_ref"`, + `"COMPATIBILITY_STABLE_REF=$stable_ref"`, + `"COMPATIBILITY_CANDIDATE_REF=$candidate_ref" >> "$GITHUB_ENV"`, } { if got := strings.Count(interfaceJob, want); got != 1 { t.Errorf("Interface Integrity job contract %q count = %d, want exactly one definition", want, got) } } + if got := strings.Count(interfaceJob, `>> "$GITHUB_ENV"`); got != 1 { + t.Errorf("Interface Integrity job must append its compatibility refs to GITHUB_ENV once, got %d writes", got) + } if strings.Count(interfaceJob, "make authoritative-interface-integrity") != 1 { t.Errorf("Interface Integrity job must have exactly one compatibility decision seam") }