-
Notifications
You must be signed in to change notification settings - Fork 722
253 lines (236 loc) · 8.98 KB
/
Copy pathgerrit-merge.yml
File metadata and controls
253 lines (236 loc) · 8.98 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: gerrit-merge
on:
workflow_dispatch:
inputs:
FDIO_NAMESPACE:
description: "Executor Namespace (prod|sandbox)"
required: false
type: choice
options:
- sandbox
- prod
default: prod
GERRIT_BRANCH:
description: "Branch that change is against"
required: true
type: string
GERRIT_CHANGE_ID:
description: "The ID for the change"
required: true
type: string
GERRIT_CHANGE_NUMBER:
description: "The Gerrit number"
required: true
type: string
GERRIT_CHANGE_URL:
description: "URL to the change"
required: true
type: string
GERRIT_EVENT_TYPE:
description: "Type of Gerrit event"
required: true
type: string
GERRIT_PATCHSET_NUMBER:
description: "The patch number for the change"
required: true
type: string
GERRIT_PATCHSET_REVISION:
description: "The revision sha"
required: true
type: string
GERRIT_PROJECT:
description: "Project in Gerrit"
required: true
type: string
GERRIT_REFSPEC:
description: "Gerrit refspec of change"
required: true
type: string
defaults:
run:
shell: bash
permissions:
contents: read
actions: read
concurrency:
group: ${{ inputs.GERRIT_PROJECT }}-${{ inputs.GERRIT_BRANCH }}-${{ inputs.GERRIT_CHANGE_NUMBER }}-${{ inputs.FDIO_NAMESPACE }}
cancel-in-progress: true
jobs:
start-merge:
name: Start Merge
runs-on: ubuntu-latest
outputs:
log_prefix: ${{ steps.start-time.outputs.log_prefix }}
steps:
- name: Start Time
id: start-time
run: |
set -euxo pipefail
timestamp=$(date -u +%Y_%m_%d_%H%M%S_UTC)
branch=${{ inputs.GERRIT_BRANCH }}
branch=${branch/\//-}
log_prefix="gha-vpp-gerrit-patchset/merge-${branch}-${timestamp}-gerrit-${{ inputs.GERRIT_CHANGE_NUMBER }}-${{ inputs.GERRIT_PATCHSET_NUMBER}}"
echo "log_prefix=$log_prefix" >> "$GITHUB_OUTPUT"
echo "Gerrit Change: ${{ inputs.GERRIT_CHANGE_URL }}"
echo "Gerrit Event Type: ${{ inputs.GERRIT_EVENT_TYPE }}"
- name: Job Details
run: |
{
echo "### Gerrit Merge Handler"
echo
echo "| Field | Value |"
echo "| --- | --- |"
echo "| Gerrit change | ${{ inputs.GERRIT_CHANGE_URL }} |"
echo "| Branch | ${{ inputs.GERRIT_BRANCH }} |"
echo "| Gerrit Change ID | ${{ inputs.GERRIT_CHANGE_ID }} |"
echo "| Patchset Revision | ${{ inputs.GERRIT_PATCHSET_REVISION }} |"
echo "| Refspec | ${{ inputs.GERRIT_REFSPEC }} |"
echo "| Gerrit Event | ${{ inputs.GERRIT_EVENT_TYPE }} |"
echo "| Gerrit Comment | ${{ inputs.GERRIT_COMMENT }} |"
echo "| Namespace | ${{ inputs.FDIO_NAMESPACE }} |"
} >> "$GITHUB_STEP_SUMMARY"
- name: Clear Gerrit Vote
# yamllint disable-line rule:line-length
uses: lfreleng-actions/gerrit-review-action@a5de1d5bf17c2603ae81544dc2a455017b454ec8 # 1.1.1
with:
host: ${{ vars.GERRIT_SERVER }}
username: ${{ vars.GERRIT_SSH_REQUIRED_USER }}
key: ${{ secrets.GERRIT_SSH_REQUIRED_PRIVKEY }}
known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
vote-type: clear
comment-only: true # Just set a comment, do not vote on gerrit
merge-maketest:
name: Merge Maketest
needs:
- start-merge
uses: fdio/vpp/.github/workflows/vpp-merge-maketest.yml@c316a780f8f25c5d2386ef8fa085e90338300e3a
with:
FDIO_NAMESPACE: ${{ inputs.FDIO_NAMESPACE }}
GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
GERRIT_CHANGE_URL: ${{ inputs.GERRIT_CHANGE_URL }}
GERRIT_EVENT_TYPE: ${{ inputs.GERRIT_EVENT_TYPE }}
GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
GERRIT_REFSPEC: refs/heads/${{ inputs.GERRIT_BRANCH }}
LOG_PREFIX: ${{ needs.start-merge.outputs.log_prefix }}
secrets: inherit
detect-docs-changes:
name: Detect Docs Changes
needs:
- start-merge
runs-on:
- self-hosted
- nomad
- fdio:arch=x86_64
- fdio:class=builder
- fdio:namespace=${{ inputs.FDIO_NAMESPACE || 'prod' }}
- fdio:os=ubuntu2404
- fdio:size=csit
- fdio:workflow=${{ github.run_id }}
outputs:
docs_changed: ${{ steps.docs-changed.outputs.docs_changed }}
env:
WORKSPACE: /scratch/docker-build/vpp
GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
TUI_LINE: "*******************************************************************"
steps:
- name: Setup Environment
id: setup-executor-env
continue-on-error: true
# yamllint disable-line rule:line-length
uses: fdio/.github/.github/actions/setup-executor-env@b728d1589228e2891a4241a1bba362d76895c225
- name: Checkout VPP Gerrit Change
id: checkout-vpp
continue-on-error: true
# yamllint disable-line rule:line-length
uses: fdio/vpp/.github/actions/vpp-checkout-gerrit-change@09552c71554236d36c1eb51a1740a366019bc1a5
with:
WORKSPACE: ${{ env.WORKSPACE }}
GERRIT_BRANCH: ${{ env.GERRIT_BRANCH }}
GERRIT_REFSPEC: ${{ env.GERRIT_REFSPEC }}
TUI_LINE: ${{ env.TUI_LINE }}
- name: Detect docs changes
id: docs-changed
if: ${{ always() }}
env:
CHECKOUT_OUTCOME: ${{ steps.checkout-vpp.outcome }}
run: |
set -euxo pipefail
docs_changed="true"
if [[ "$CHECKOUT_OUTCOME" == "success" ]]; then
cd "$WORKSPACE"
if git diff-tree --no-commit-id --name-only -r --root HEAD | grep -Eq '(^docs/|\.rst$)'; then
docs_changed="true"
else
docs_changed="false"
fi
else
echo "warn: unable to checkout '${GERRIT_REFSPEC}'; defaulting docs_changed=true" >&2
fi
echo "docs_changed=$docs_changed" >> "$GITHUB_OUTPUT"
merge-docs:
name: Merge Docs
needs:
- start-merge
- detect-docs-changes
if: ${{ needs.detect-docs-changes.outputs.docs_changed == 'true' }}
uses: fdio/vpp/.github/workflows/vpp-merge-docs.yml@e5c8759e531c155d1aa983fcb0fe84fd1f004c88
with:
FDIO_NAMESPACE: ${{ inputs.FDIO_NAMESPACE }}
GERRIT_BRANCH: ${{ inputs.GERRIT_BRANCH }}
GERRIT_CHANGE_ID: ${{ inputs.GERRIT_CHANGE_ID }}
GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
GERRIT_CHANGE_URL: ${{ inputs.GERRIT_CHANGE_URL }}
GERRIT_EVENT_TYPE: ${{ inputs.GERRIT_EVENT_TYPE }}
GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
GERRIT_PATCHSET_REVISION: ${{ inputs.GERRIT_PATCHSET_REVISION }}
GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
GERRIT_REFSPEC: refs/heads/${{ inputs.GERRIT_BRANCH }}
LOG_PREFIX: ${{ needs.start-merge.outputs.log_prefix }}
secrets: inherit
final-vote:
name: Vote
if: ${{ always() }}
needs:
- start-merge
- detect-docs-changes
- merge-maketest
- merge-docs
runs-on: ubuntu-latest
env:
GERRIT_CHANGE_NUMBER: ${{ inputs.GERRIT_CHANGE_NUMBER }}
GERRIT_PATCHSET_NUMBER: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
steps:
- name: Collect workflow results
id: overall
run: |
set -euxo pipefail
docs_ok="true"
if [[ "${{ needs.detect-docs-changes.outputs.docs_changed }}" == "true" ]]; then
[[ "${{ needs.merge-docs.result }}" == "success" ]] || docs_ok="false"
fi
if [[ "${{ needs.start-merge.result }}" == "success" && \
"${{ needs.merge-maketest.result }}" == "success" && \
"$docs_ok" == "true" ]] ; then
echo "result=success" >> "$GITHUB_OUTPUT"
else
echo "result=failure" >> "$GITHUB_OUTPUT"
fi
- name: Gerrit Vote Disabled
# yamllint disable-line rule:line-length
uses: lfreleng-actions/gerrit-review-action@a5de1d5bf17c2603ae81544dc2a455017b454ec8 # 1.1.1
with:
host: ${{ vars.GERRIT_SERVER }}
username: ${{ vars.GERRIT_SSH_USER }}
key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
gerrit-change-number: ${{ env.GERRIT_CHANGE_NUMBER }}
gerrit-patchset-number: ${{ env.GERRIT_PATCHSET_NUMBER }}
vote-type: ${{ steps.overall.outputs.result }}
comment-only: true # Just set a comment, do not vote on gerrit