-
Notifications
You must be signed in to change notification settings - Fork 1.1k
192 lines (190 loc) · 7.26 KB
/
ci-manual.yaml
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
name: '[CI] Manual'
run-name: "#${{ inputs.pr_number }} - ${{ inputs.uuid }}"
on:
workflow_dispatch:
inputs:
requester:
required: true
type: string
comment_url:
required: true
type: string
uuid:
required: true
type: string
pr_number:
required: true
type: string
git_sha:
required: true
type: string
goal:
required: true
type: choice
default: "test"
options:
- "build"
- "test"
os_distros:
description: 'Operating System Distributions (comma-separated, e.g., al2,al2023)'
default: "al2,al2023"
required: false
type: string
k8s_versions:
description: 'Kubernetes Versions (comma-separated, e.g., 1.29,1.30)'
default: "1.24,1.25,1.26,1.27,1.28,1.29,1.30,1.31"
required: false
type: string
build_arguments:
required: false
type: string
jobs:
setup:
runs-on: ubuntu-latest
outputs:
git_sha_short: ${{ steps.variables.outputs.git_sha_short }}
workflow_run_url: ${{ steps.variables.outputs.workflow_run_url }}
kubernetes_versions: ${{ steps.variables.outputs.kubernetes_versions }}
build_id: ${{ steps.variables.outputs.build_id }}
ci_step_name_prefix: ${{ steps.variables.outputs.ci_step_name_prefix }}
os_distros: ${{ steps.variables.outputs.os_distros }}
steps:
- id: variables
run: |
echo "git_sha_short=$(echo ${{ inputs.git_sha }} | rev | cut -c-7 | rev)" >> $GITHUB_OUTPUT
echo "workflow_run_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_OUTPUT
echo "build_id=ci-${{ inputs.pr_number }}-${{ needs.setup.outputs.git_sha_short }}-${{ inputs.uuid }}" >> $GITHUB_OUTPUT
echo 'ci_step_name_prefix=CI:' >> $GITHUB_OUTPUT
echo "kubernetes_versions=$(jq -Rn --arg input '${{ inputs.k8s_versions }}' '($input | split(","))' | jq -c .)" >> $GITHUB_OUTPUT
echo "os_distros=$(jq -Rn --arg input '${{ inputs.os_distros }}' '($input | split(","))' | jq -c .)" >> $GITHUB_OUTPUT
notify-start:
runs-on: ubuntu-latest
needs:
- setup
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.pr_number }},
body: `@${{ inputs.requester }} roger [that](${{ inputs.comment_url }})! I've dispatched a [workflow](${{ needs.setup.outputs.workflow_run_url }}). 👍`
});
kubernetes-versions:
runs-on: ubuntu-latest
name: ${{ matrix.k8s_version }} / ${{ matrix.os_distro }}
needs:
- setup
- notify-start
permissions:
id-token: write
contents: read
strategy:
# don't bail out of all sub-tasks if one fails
fail-fast: false
matrix:
k8s_version: ${{ fromJson(needs.setup.outputs.kubernetes_versions) }}
os_distro: ${{ fromJson(needs.setup.outputs.os_distros) }}
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1
with:
ref: 'main'
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # 4.0.2
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN_CI }}
# 2.5 hours (job usually completes within 2 hours)
role-duration-seconds: 9000
- name: "${{ needs.setup.outputs.ci_step_name_prefix }} Build"
id: build
uses: ./.github/actions/ci/build
with:
git_sha: ${{ inputs.git_sha }}
k8s_version: ${{ matrix.k8s_version }}
os_distro: ${{ matrix.os_distro }}
build_id: ${{ needs.setup.outputs.build_id }}
additional_arguments: ${{ inputs.build_arguments }}
- if: ${{ inputs.goal == 'test' }}
name: "${{ needs.setup.outputs.ci_step_name_prefix }} Test"
id: test
uses: ./.github/actions/ci/kubetest2
with:
ami_id: ${{ steps.build.outputs.ami_id }}
k8s_version: ${{ matrix.k8s_version }}
os_distro: ${{ matrix.os_distro }}
build_id: ${{ needs.setup.outputs.build_id }}
aws_region: ${{ secrets.AWS_REGION }}
log_bucket: ${{ secrets.CI_LOG_BUCKET }}
notify-outcome:
if: ${{ always() }}
runs-on: ubuntu-latest
needs:
- setup
- kubernetes-versions
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
with:
script: |
const { data } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId
});
const conclusionEmojis = {
"success": "✅",
"skipped": "⏭️",
"failure": "❌",
"cancelled": "🚮"
};
const uniqueStepNames = new Set();
const stepConclusionsByJob = new Map();
const ciStepNamePrefix = "${{ needs.setup.outputs.ci_step_name_prefix }}";
for (const job of data.jobs) {
if (/^\d+\.\d+/.test(job.name)) {
for (const step of job.steps) {
if (step.name.startsWith(ciStepNamePrefix)) {
const stepName = step.name.substring(ciStepNamePrefix.length).trim();
let stepConclusions = stepConclusionsByJob.get(job.name);
if (!stepConclusions) {
stepConclusions = new Map();
stepConclusionsByJob.set(job.name, stepConclusions);
}
stepConclusions.set(stepName, step.conclusion);
uniqueStepNames.add(stepName);
}
}
}
}
const headers = [{
data: 'AMI variant',
header: true
}];
for (const stepName of uniqueStepNames.values()) {
headers.push({
data: stepName,
header: true
});
}
const rows = [];
for (const stepConclusionsForJob of [...stepConclusionsByJob.entries()].sort()) {
const job = stepConclusionsForJob[0];
const row = [job];
for (const step of stepConclusionsForJob[1].entries()) {
row.push(`${step[1]} ${conclusionEmojis[step[1]]}`);
}
rows.push(row);
}
const commentBody = core.summary
.addRaw("@${{ inputs.requester }} the <a href=${{ needs.setup.outputs.workflow_run_url }}>workflow</a> that you <a href=${{ inputs.comment_url }}>requested</a> has completed. 🎉")
.addTable([
headers,
...rows,
])
.stringify();
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ inputs.pr_number }},
body: commentBody
});