-
Notifications
You must be signed in to change notification settings - Fork 89
164 lines (140 loc) · 7.46 KB
/
check-envoy-commits.yml
File metadata and controls
164 lines (140 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: "Check Envoy commits for non-trivial merges"
on:
pull_request:
schedule:
- cron: "0 */4 * * *"
workflow_dispatch: {}
jobs:
check-envoy-commits:
runs-on: ubuntu-latest
steps:
- name: "Checkout Nighthawk"
uses: actions/checkout@v4
with:
path: nighthawk
- name: "Checkout Envoy"
uses: actions/checkout@v4
with:
repository: envoyproxy/envoy
path: envoy
- name: "Get Nighthawk's current Envoy commit"
id: get_current_envoy_commit
run: |
CURRENT_ENVOY_COMMIT=$(cat nighthawk/bazel/repositories.bzl | sed -nE 's/^ENVOY_COMMIT = "(.*)"$/\1/p')
echo "CURRENT_ENVOY_COMMIT=${CURRENT_ENVOY_COMMIT}" >> $GITHUB_ENV
- name: "Get the latest Envoy commit"
id: get_latest_envoy_commit
run: |
LATEST_ENVOY_COMMIT=$(git -C envoy rev-parse main)
echo "LATEST_ENVOY_COMMIT=${LATEST_ENVOY_COMMIT}" >> $GITHUB_ENV
- name: "Check for existing issues generated by check-envoy-commits workflow and close obsolete issues"
id: check_open_issues
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "decision=proceed" >> $GITHUB_OUTPUT
# Get all open issues created by this automation.
OPEN_ISSUES_JSON=$(gh issue list --repo ${{ github.repository }} --label "check-envoy-commits" --state open --json number,title)
if [[ -z "$OPEN_ISSUES_JSON" || "$OPEN_ISSUES_JSON" == "[]" ]]; then
echo "No known open issues found. Proceeding with analysis."
exit 0
fi
echo "Found open breakages. Checking for resolution..."
SKIP_RUN="false"
echo "$OPEN_ISSUES_JSON" | jq -c '.[]' | while read -r issue; do
ISSUE_NUMBER=$(echo "$issue" | jq -r '.number')
ENVOY_BREAK_COMMIT=$(echo "$issue" | jq -r '.title' | grep -oP '(?<=`)\w+(?=`)')
if [[ -z "$ENVOY_BREAK_COMMIT" ]]; then
continue
fi
# Use the local Envoy checkout to check if the breaking commit is an ancestor.
if git -C envoy merge-base --is-ancestor "$ENVOY_BREAK_COMMIT" "${{ env.CURRENT_ENVOY_COMMIT }}"; then
echo "Issue from Envoy commit ${ENVOY_BREAK_COMMIT} (issue #${ISSUE_NUMBER}) is resolved."
gh issue comment "$ISSUE_NUMBER" --body "The Nighthawk dependency on Envoy has been updated to \`${{ env.CURRENT_ENVOY_COMMIT }}\`, which is past the issue commit \`${ENVOY_BREAK_COMMIT}\`."
gh issue close "$ISSUE_NUMBER"
else
echo "Nighthawk's dependency has NOT moved past the known issue at ${ENVOY_BREAK_COMMIT} (issue #${ISSUE_NUMBER})."
SKIP_RUN="true"
fi
done
if [[ "$SKIP_RUN" == "true" ]]; then
echo "Skipping this run due to unresolved breakages."
echo "decision=skip" >> $GITHUB_OUTPUT
else
echo "All known breakages have been resolved or closed. Proceeding with new analysis."
fi
- name: "Check for modifications to shared files"
if: steps.check_open_issues.outputs.decision == 'proceed'
id: check_shared_files
run: |
echo "manual_merge_required=false" >> $GITHUB_OUTPUT
# Find the first commit in the range that modified a shared file.
SHARED_FILES=(
.bazelrc
.bazelversion
ci/run_envoy_docker.sh
tools/gen_compilation_database.py
tools/code_format/config.yaml);
ENVOY_MODIFIED_COMMIT=$(git -C envoy log --diff-filter=M --pretty=%H -1 ${{ env.CURRENT_ENVOY_COMMIT }}..${{ env.LATEST_ENVOY_COMMIT }} -- ${SHARED_FILES[@]})
if [[ -n "$ENVOY_MODIFIED_COMMIT" ]]; then
echo "Envoy commit ${ENVOY_MODIFIED_COMMIT} modified ${shared_file}."
echo "manual_merge_required=true" >> $GITHUB_OUTPUT
echo "ENVOY_MODIFIED_COMMIT=${ENVOY_MODIFIED_COMMIT}" >> $GITHUB_ENV
else
echo "No modifications to shared files found in the commit range."
fi
- name: "Create an issue due to modification of shared files"
if: steps.check_shared_files.outputs.manual_merge_required == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v6
with:
script: |
const { ENVOY_MODIFIED_COMMIT } = process.env;
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Non-trivial Envoy commit increment: \`${ENVOY_MODIFIED_COMMIT.substring(0, 12)}\``,
labels: ["bug", "automation", "check-envoy-commits", "manual-action-required"],
body: `An Envoy commit between the current Nighthawk dependency and latest has modified a shared file.\n\n**Envoy Commit:** \`${ENVOY_MODIFIED_COMMIT}\`\n\nA human is required to review and merge the changes from this file into Nighthawk's copy.\n\nThis workflow will be blocked until this file is updated and the corresponding Nighthawk dependency on Envoy is updated past this commit.`
});
- name: "Set up Bazel"
if: steps.check_open_issues.outputs.decision == 'proceed'
uses: bazel-contrib/setup-bazel@0.15.0
- name: "Initial build check with latest Envoy"
if: steps.check_open_issues.outputs.decision == 'proceed'
id: build_with_latest_commit
run: |
chmod +x ./nighthawk/tools/bisect-envoy.sh
./nighthawk/tools/bisect-envoy.sh ${{ env.LATEST_ENVOY_COMMIT }} "$(pwd)/nighthawk" > build_with_latest_commit.log 2>&1
continue-on-error: true
- name: "Bisect to find the first Envoy commit that causes the break"
if: steps.check_open_issues.outputs.decision == 'proceed' && steps.build_with_latest_commit.outcome == 'failure'
id: bisect
run: |
echo "Initial build failed. Starting bisection..."
git -C envoy bisect start ${{ env.LATEST_ENVOY_COMMIT }} ${{ env.CURRENT_ENVOY_COMMIT }}
BISECT_LOG_FILE=$(mktemp)
git -C envoy bisect run ./nighthawk/tools/bisect-envoy.sh "$(pwd)/nighthawk" | tee ${BISECT_LOG_FILE}
ENVOY_BREAK_COMMIT=$(grep -oP '^\w+(?=\s+is the first bad commit)' ${BISECT_LOG_FILE} || echo "NOT_FOUND")
echo "ENVOY_BREAK_COMMIT=${ENVOY_BREAK_COMMIT}" >> $GITHUB_ENV
echo "BISECT_LOG<<EOF" >> $GITHUB_OUTPUT
cat ${BISECT_LOG_FILE} >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: "Create Envoy commit increment issue"
if: steps.bisect.outcome == 'success'
id: create_issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v6
with:
script: |
const { ENVOY_BREAK_COMMIT } = process.env;
const logBody = `${{ steps.bisect.outputs.BISECT_LOG }}`;
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Non-trivial Envoy commit increment: \`${ENVOY_BREAK_COMMIT.substring(0, 12)}\``,
labels: ["bug", "automation", "check-envoy-commits"],
body: `Automated bisection identified Envoy commit \`${ENVOY_BREAK_COMMIT}\` as the first commit to break the Nighthawk build.\n\n**Bisection Log:**\n\`\`\`\n${logBody}\n\`\`\``
});