-
Notifications
You must be signed in to change notification settings - Fork 29
250 lines (229 loc) · 8.17 KB
/
build.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
name: Build artifacts
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
packages: write
pages: write
id-token: write
jobs:
compile-binary:
name: Build executable
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.22.3'
- name: Compile executable
run: make output/kelemetry
- name: Upload executable
uses: actions/upload-artifact@v4
with:
name: kelemetry-linux-amd64
path: output/kelemetry
dot-usage:
name: Generate dependency graph and usage file
runs-on: [ubuntu-20.04]
needs: [compile-binary]
steps:
- name: Install graphviz
run: sudo apt-get install -y graphviz
- uses: actions/checkout@v3
- name: Download executable
uses: actions/download-artifact@v4
with:
name: kelemetry-linux-amd64
path: output
- run: chmod +x output/kelemetry
- name: Re-generate USAGE.txt
run: make usage
- name: Generate depgraph
run: make dot
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dot-usage
path: |
depgraph.*
USAGE.txt
build-docker:
name: Build docker image for quickstart
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- name: Build docker image
run: docker build -t kelemetry:ci .
- name: Export docker image to file
run: mkdir output && docker save -o output/kelemetry-ci.tar kelemetry:ci
- name: Upload docker image artifact
uses: actions/upload-artifact@v4
with:
name: ci-docker-image
path: output/kelemetry-ci.tar
e2e:
name: Generate demo traces
runs-on: [ubuntu-20.04]
needs: [build-docker]
steps:
- uses: actions/checkout@v3
- name: Install kind
run: wget --no-verbose -O kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/kind
- name: Start test cluster
run: make kind
- name: Install kubectl
run: |
wget --no-verbose -O kubectl https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x kubectl && \
sudo mv kubectl /usr/local/bin/kubectl
- name: Download docker image
uses: actions/download-artifact@v4
with:
name: ci-docker-image
path: local
- name: Load docker image
run: docker load -i local/kelemetry-ci.tar
- name: Start quickstartup setup
run: make quickstart KELEMETRY_IMAGE=kelemetry:ci
- name: Run e2e tests
run: |
mkdir output
OUTPUT_TRACE=$(realpath output) bash e2e/run-all.sh
- name: Upload trace output
uses: actions/upload-artifact@v4
with:
name: trace-output
path: output
build-site:
name: Build site
runs-on: [ubuntu-20.04]
needs: [compile-binary, dot-usage, e2e]
steps:
- uses: actions/download-artifact@v4
with:
name: trace-output
path: output
- name: Download Jaeger UI
run: |
mkdir -p local/jaeger-ui
wget -O - https://github.com/jaegertracing/jaeger-ui/releases/download/v1.28.1/assets.tar.gz | tar xzv -C local/jaeger-ui
mv local/jaeger-ui/packages/jaeger-ui/build/static output/static
sed 's#<base href="/"#<base href="/kelemetry/"#g' local/jaeger-ui/packages/jaeger-ui/build/index.html >spa.html
- name: Generate static SPA links
run: |
mkdir -p output/api/traces
for trace_id_file in output/trace-*/trace_id; do
trace_name=$(basename $(dirname $trace_id_file))
base_trace_id=$(cat $trace_id_file)
default_trace_id=ff21000000${base_trace_id}
cat <<EOF >output/${trace_name}/index.html
<html>
<head>
<title>Redirecting to ${trace_name}</title>
<meta http-equiv="refresh" content="0;URL='/kelemetry/trace/${default_trace_id}'" />
</head>
</html>
EOF
mkdir -p output/trace/${default_trace_id}
cp spa.html output/trace/${default_trace_id}/index.html
done
- name: Download dot-usage artifact
uses: actions/download-artifact@v4
with:
name: dot-usage
path: dot-usage
- name: Download binary artifact
uses: actions/download-artifact@v4
with:
name: kelemetry-linux-amd64
path: output/kelemetry-linux-amd64
- name: Generate index page
run: |
mv dot-usage/* output/
cat <<EOF >output/index.html
<html>
<head>
<title>Kelemetry</title>
<base href="/kelemetry/" />
</head>
<body>
<h1>Kelemetry</h1>
<p>Check repo on <a href="https://github.com/kubewharf/kelemetry">GitHub</a>.</p>
<h2>Artifacts</h2>
<p>
This site hosts artifacts built from the latest development version of Kelemetry, including:
</p>
<ul>
<li><a href="kelemetry-linux-amd64/kelemetry">Executable binary (Linux, amd64)</a></li>
<li><a href="USAGE.txt">Executable options</a></li>
<li><a href="depgraph.png">Internal dependency graph</a></li>
</ul>
<h2>Previews</h2>
<p>
This site hosts a few demo traces from Kelemetry rendered on <a href="https://github.com/kubewharf/kelemetry/actions">GitHub CI</a>.
This preview contains assets from <a href="https://github.com/jaegertracing/jaeger-ui">Jaeger UI</a>,
which is distributed under <a href="https://github.com/jaegertracing/jaeger-ui/raw/main/LICENSE">Apache License 2.0</a>.
Part of the Jaeger UI assets may have been modified to facilitate serving on GitHub Pages.
</p>
<ul>
EOF
for trace_dir in output/trace-*; do
basename=$(basename $trace_dir)
cat <<EOF >>output/index.html
<li><a href="$basename/">$(cat $trace_dir/trace_display_name)</a></li>
EOF
done
cat <<EOF >>output/index.html
</ul>
</body>
</html>
EOF
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v1
with:
path: output
deploy-github-pages:
name: Deploy GitHub Pages
runs-on: [ubuntu-20.04]
needs: [build-site]
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'ci-test')
concurrency:
group: gh-pages
steps:
- uses: actions/deploy-pages@v2
id: deployment
publish-image:
name: Publish docker image
runs-on: [ubuntu-20.04]
needs: [build-docker]
concurrency:
group: ${{github.ref_type}}-${{github.ref}}
cancel-in-progress: true
if: github.event_name == 'push' && (github.ref_type == 'tag' || (github.ref_type == 'branch' && github.ref_name == 'main'))
steps:
- name: Download docker image
uses: actions/download-artifact@v4
with:
name: ci-docker-image
path: local
- name: Load docker image
run: docker load -i local/kelemetry-ci.tar
- name: Determine image tag for release
id: tag-name
run: |
if [[ ${{github.ref_type}} == tag ]]; then
echo "IMAGE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "IMAGE_TAG=dev" >> $GITHUB_OUTPUT
fi
- name: Re-tag docker image
run: docker tag kelemetry:ci ghcr.io/kubewharf/kelemetry:${{steps.tag-name.outputs.IMAGE_TAG}}
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- run: docker push ghcr.io/kubewharf/kelemetry:${{steps.tag-name.outputs.IMAGE_TAG}}