-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (252 loc) · 8.2 KB
/
ci.yml
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
name: CI
on:
push:
branches:
- main
- staging
- trying
- 'renovate/*'
pull_request:
branches:
- main
jobs:
check-license-headers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check license headers
run: |
./hack/check-license-headers.sh
yamllint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: yamllint
uses: ibiqlik/action-yamllint@v3
build-and-test:
runs-on: ubuntu-latest
outputs:
awscli-hash: ${{ steps.submodule-hashes.outputs.awscli-hash }}
cfnlint-hash: ${{ steps.submodule-hashes.outputs.cfnlint-hash }}
botocore-hash: ${{ steps.submodule-hashes.outputs.botocore-hash }}
steps:
- name: Install node toolchain
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.19.x
- name: Install jsonnet
run: go install github.com/google/go-jsonnet/cmd/jsonnet@latest
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- run: npm ci
- run: npx eslint .
- name: Get submodule commit hashes
id: submodule-hashes
run: |
awscli_hash="$(git rev-parse @:index-sources/aws-cli)"
cfnlint_hash="$(git rev-parse @:index-sources/cfn-lint)"
botocore_hash="$(git rev-parse @:index-sources/botocore)"
echo "awscli-hash=${awscli_hash}" >> $GITHUB_OUTPUT
echo "cfnlint-hash=${cfnlint_hash}" >> $GITHUB_OUTPUT
echo "botocore-hash=${botocore_hash}" >> $GITHUB_OUTPUT
- name: 'aws-cli: index cache'
id: cache-awscli
uses: actions/cache@v3
with:
path: |
index-sources/aws-cli/doc/build/
extension/index/cli.js
json-indices/cli.json
key: indices-awscli-${{ steps.submodule-hashes.outputs.awscli-hash }}-${{ hashFiles('hack/generate-index-cli.py') }}
- name: 'cfn-lint: index cache'
id: cache-cfnlint
uses: actions/cache@v3
with:
path: |
extension/index/cfn.v2.js
json-indices/cfn.json
json-indices/cfn.v2.json
key: indices-cfnlint-${{ steps.submodule-hashes.outputs.cfnlint-hash }}-${{ hashFiles('hack/generate-index-cfn.py') }}
- name: 'botocore: index cache'
id: cache-botocore
uses: actions/cache@v3
with:
path: |
extension/index/api.js
json-indices/api.json
key: indices-botocore-${{ steps.submodule-hashes.outputs.botocore-hash }}-${{ hashFiles('hack/generate-index-api.py') }}
- name: 'aws-cli: Build aws-cli docs'
if: steps.cache-awscli.outputs.cache-hit != 'true'
working-directory: index-sources/aws-cli/
run: |
pip install -r requirements.txt
pip install -r requirements-docs.txt
pip install -e .
make -C doc json
- name: 'aws-cli: Generate index'
if: steps.cache-awscli.outputs.cache-hit != 'true'
run: |
hack/generate-index-cli.py
hack/generate-index-cli.py --export-as-json
- name: 'aws-cli: verify generated index (v1)'
if: steps.cache-awscli.outputs.cache-hit != 'true'
run: |
node_modules/.bin/ajv validate \
-s hack/index-schemas/cli.schema.json \
-d json-indices/cli.json
- name: 'aws-cli: verify generated index (v2)'
if: steps.cache-awscli.outputs.cache-hit != 'true'
run: |
node_modules/.bin/ajv validate \
-s hack/index-schemas/cli.v2.schema.json \
-d json-indices/cli.v2.json
- name: 'cfn-lint: Generate index'
if: steps.cache-cfnlint.outputs.cache-hit != 'true'
run: |
hack/generate-index-cfn.py
hack/generate-index-cfn.py --export-as-json
- name: 'cfn-lint: verify generated index'
if: steps.cache-cfnlint.outputs.cache-hit != 'true'
run: |
node_modules/.bin/ajv validate \
-s hack/index-schemas/cfn.schema.json \
-d json-indices/cfn.json
- name: 'botocore: Generate index'
if: steps.cache-botocore.outputs.cache-hit != 'true'
run: |
hack/generate-index-api.py
hack/generate-index-api.py --export-as-json
- name: 'botocore: verify generated index'
if: steps.cache-botocore.outputs.cache-hit != 'true'
run: |
node_modules/.bin/ajv validate \
-s hack/index-schemas/api.schema.json \
-d json-indices/api.json
- name: 'Firefox: prepare manifest'
run: make firefox
- name: 'Firefox: web-ext build'
uses: kewisch/action-web-ext@v1
id: web-ext-build-firefox
with:
cmd: build
source: extension
artifacts: web-ext-artifacts/firefox/
- name: 'Chrome: prepare manifest'
run: make chrome
- name: 'Chrome: web-ext build'
uses: kewisch/action-web-ext@v1
id: web-ext-build-chrome
with:
cmd: build
source: extension
artifacts: web-ext-artifacts/chrome/
- name: 'Edge: prepare manifest'
run: make edge
- name: 'Edge: web-ext build'
uses: kewisch/action-web-ext@v1
id: web-ext-build-edge
with:
cmd: build
source: extension
artifacts: web-ext-artifacts/edge/
- name: Upload extension-ZIPs as artifact to workflow
uses: actions/upload-artifact@v4
with:
name: aws-search-extension
path: |
${{ steps.web-ext-build-firefox.outputs.target }}
${{ steps.web-ext-build-chrome.outputs.target }}
${{ steps.web-ext-build-edge.outputs.target }}
- name: Upload JSON-indices as artifact to workflow
uses: actions/upload-artifact@v4
with:
name: indices
path: |
extension/index/*.js
json-indices/*.json
commit-indices:
runs-on: ubuntu-latest
needs:
- build-and-test
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout indices branch
uses: actions/checkout@v4
with:
ref: indices
- name: Retrieve indices
uses: actions/download-artifact@v4
with:
name: indices
- name: Move downloaded indices
run: |
rm -rf extension/ || :
mv json-indices/*.json .
rmdir json-indices/
- name: Commit updated index
run: |
function git_commit {
local file="$1"
local subject="$2"
local message="$3"
local echo_commit="$4"
local echo_nocommit="$5"
local status=0
git add "$file"
git \
-c "user.name=GitHub" \
-c "[email protected]" \
commit \
--quiet \
--author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" \
--message "$subject" \
--message "$message" \
2>/dev/null || status=$?
case "$status" in
0)
echo "$echo_commit"
;;
1)
# Couldn't create a commit because it would have been empty.
echo "$echo_nocommit"
;;
*)
echo "An unknown error has occurred, exitting!"
exit 1
;;
esac
}
git_commit \
"cli.json" \
"⌨️ cli: index updated" \
"Based on aws/aws-cli#${{ needs.build-and-test.outputs.awscli-hash }}" \
"⌨️ cli: created commit" \
"⌨️ cli: no update needed, not committing" \
;
git_commit \
"cfn.json" \
"☁️ cfn: index updated" \
"Based on aws-cloudformation/cfn-lint#${{ needs.build-and-test.outputs.cfnlint-hash }}" \
"☁️ cfn: created commit" \
"☁️ cfn: no update needed, not committing" \
;
git_commit \
"api.json" \
"📄 api: index updated" \
"Based on boto/botocore#${{ needs.build-and-test.outputs.botocore-hash }}" \
"📄 api: created commit" \
"📄 api: no update needed, not committing" \
;
git push