Skip to content

Commit e7d42b4

Browse files
authored
Merge pull request #9750 from kubernetes-sigs/revert-9748-feat/auto-bump-module
Revert "feat: auto update go module drifts"
2 parents 114a3c6 + 42258cf commit e7d42b4

File tree

3 files changed

+3
-263
lines changed

3 files changed

+3
-263
lines changed

.github/workflows/codespell.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# https://github.com/codespell-project/codespell
44
name: codespell
55
on:
6-
workflow_dispatch:
76
push:
87
branches: [ master, 'release-**' ]
98
pull_request:
Lines changed: 3 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
name: Go Module Consistency
22

33
on:
4-
workflow_dispatch:
54
push:
65
branches: [ master, 'release-**' ]
76
pull_request:
87
branches: [ master, 'release-**' ]
98

109
permissions:
1110
contents: read
12-
pull-requests: write
1311

1412
jobs:
1513
go-mod-consistency:
@@ -39,7 +37,7 @@ jobs:
3937
health-probe-proxy/go.sum
4038
kubetest2-aks/go.sum
4139
42-
- name: Run go mod tidy, vendor, and verify
40+
- name: Run go mod tidy and verify
4341
run: |
4442
set -euo pipefail
4543
modules=(
@@ -53,107 +51,14 @@ jobs:
5351
health-probe-proxy
5452
kubetest2-aks
5553
)
56-
vendor_modules=(
57-
.
58-
)
5954
for m in "${modules[@]}"; do
6055
echo ">> go mod tidy (${m})"
6156
(cd "${m}" && go mod tidy)
62-
if [[ " ${vendor_modules[*]} " == *" ${m} "* ]]; then
63-
echo ">> go mod vendor (${m})"
64-
(cd "${m}" && go mod vendor)
65-
fi
6657
echo ">> go mod verify (${m})"
6758
(cd "${m}" && go mod verify)
6859
done
6960
70-
- name: Detect go module drift
71-
id: diff
72-
run: |
73-
set -euo pipefail
74-
status_output="$(git status --porcelain)"
75-
if [ -z "${status_output}" ]; then
76-
echo "changed=false" >> "$GITHUB_OUTPUT"
77-
exit 0
78-
fi
79-
echo "changed=true" >> "$GITHUB_OUTPUT"
80-
81-
- name: Write summary
82-
if: steps.diff.outputs.changed == 'true'
83-
run: |
84-
set -euo pipefail
85-
{
86-
echo "### Go module drift detected"
87-
echo ""
88-
echo "A maintainer can apply the updates by running:"
89-
echo "- Update Go Modules (Manual): https://github.com/${GITHUB_REPOSITORY}/actions/workflows/update-go-mods.yaml"
90-
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
91-
echo "- PR: #${{ github.event.pull_request.number }}"
92-
fi
93-
echo ""
94-
echo "Diff summary:"
95-
echo '```'
96-
git diff --stat
97-
echo '```'
98-
} >> "$GITHUB_STEP_SUMMARY"
99-
100-
- name: Notify pull request
101-
if: github.event_name == 'pull_request' && steps.diff.outputs.changed == 'true'
102-
continue-on-error: true
103-
env:
104-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105-
run: |
106-
set -euo pipefail
107-
108-
pr_number="${{ github.event.pull_request.number }}"
109-
author="$(jq -r '.pull_request.user.login // empty' "${GITHUB_EVENT_PATH}")"
110-
reviewers="$(jq -r '.pull_request.requested_reviewers[].login // empty' "${GITHUB_EVENT_PATH}" | sed 's/^/@/' | paste -sd ' ' -)"
111-
teams="$(jq -r '.pull_request.requested_teams[].slug // empty' "${GITHUB_EVENT_PATH}" | sed "s|^|@${GITHUB_REPOSITORY_OWNER}/|" | paste -sd ' ' -)"
112-
113-
mentions=""
114-
if [[ -n "${author}" ]]; then
115-
mentions="@${author}"
116-
fi
117-
if [[ -n "${reviewers}" ]]; then
118-
mentions="${mentions} ${reviewers}"
119-
fi
120-
if [[ -n "${teams}" ]]; then
121-
mentions="${mentions} ${teams}"
122-
fi
123-
mentions="$(printf '%s' "${mentions}" | xargs || true)"
124-
125-
marker="<!-- go-mod-drift -->"
126-
workflow_url="https://github.com/${GITHUB_REPOSITORY}/actions/workflows/update-go-mods.yaml"
127-
diffstat="$(git diff --stat)"
128-
129-
body="$(printf '%s\n' \
130-
"${marker}" \
131-
"${mentions}" \
132-
"" \
133-
"Go module files are out of date for this PR (go.mod/go.sum and/or vendor)." \
134-
"" \
135-
"A maintainer can apply the generated updates by running:" \
136-
"- Workflow: ${workflow_url}" \
137-
"- Input: pr_number=${pr_number}" \
138-
"" \
139-
"Note: commits pushed by GitHub Actions using GITHUB_TOKEN don't auto-trigger other push/pull_request workflows, so checks may need to be manually re-run." \
140-
"" \
141-
"Diff summary:" \
142-
"${diffstat}" \
143-
)"
144-
145-
comment_id="$(gh api "repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" --paginate | jq -r --arg marker "${marker}" '.[] | select(.user.login=="github-actions[bot]" and (.body | contains($marker))) | .id' | head -n 1)"
146-
if [[ -n "${comment_id}" && "${comment_id}" != "null" ]]; then
147-
gh api -X PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${comment_id}" -f body="${body}" >/dev/null
148-
exit 0
149-
fi
150-
151-
gh api -X POST "repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" -f body="${body}" >/dev/null
152-
153-
- name: Fail on go module drift
154-
if: steps.diff.outputs.changed == 'true'
61+
- name: Fail on uncommitted changes
15562
run: |
156-
set -euo pipefail
157-
git status --porcelain
15863
git diff --stat
159-
exit 1
64+
git diff --quiet

.github/workflows/update-go-mods.yaml

Lines changed: 0 additions & 164 deletions
This file was deleted.

0 commit comments

Comments
 (0)