forked from konveyor/kai
-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (258 loc) · 10.3 KB
/
build-and-push-binaries.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: Build and Publish Binaries
on:
workflow_call:
outputs:
matrix_info:
description: List of os / arch information in the build matrix
value: ${{ jobs.share_matrix_info.outputs.matrix_info }}
workflow_dispatch:
inputs:
publish_artifacts_to_release:
type: boolean
default: true
description: Upload binaries to an existing github release. When not set, binaries will be uploaded as temporary github artifacts.
use_latest_release:
type: boolean
default: true
description: Upload binaries to the most recent release
pattern:
type: string
default: "v*"
description: Pick from tags matching this pattern
pre_release:
type: boolean
description: Look for pre-release?
default: false
pull_request:
push:
# the build matrix exists as an env var so that we can
# share that info reliably with the "calling" workflow
env:
BUILD_MATRIX: |
[
{ "os": "ubuntu-latest", "shell": "bash" },
{ "os": "macos-latest", "shell": "bash" },
{ "os": "macos-13", "shell": "bash" },
{ "os": "windows-latest", "shell": "cmd" },
{ "os": "windows-11-preview-arm", "shell": "cmd" },
{ "os": "ubuntu-24.04-arm", "shell": "bash" }
]
jobs:
# these are specific java artifacts (cross-platform) that we
# download on linux and re-use on other platforms
download_artifacts:
name: Download cross-platform java dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
repository: konveyor/kai
- name: Download deps
run: |
git config --global user.email "[email protected]"
git config --global user.name "Konveyor CI"
make get-analyzer-deps
make get-rulesets
cd example/analysis && zip -r java-deps.zip maven.default.index jdtls bundle.jar rulesets
- name: Upload deps as temp artifacts
uses: actions/upload-artifact@v4
with:
name: java-deps.zip
path: ./example/analysis/java-deps.zip
# this job exists because we want to store the build matrix as output
# it will be used in the subsequent job as well as in a "calling" workflow
share_matrix_info:
name: Output platform info
runs-on: ubuntu-latest
outputs:
matrix_info: ${{ steps.matrix_info.outputs.matrix_info }}
steps:
- id: matrix_info
run: |
{
echo 'matrix_info<<EOF'
echo '${{ env.BUILD_MATRIX }}'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
e2e_test:
needs:
- share_matrix_info
- download_artifacts
name: Run e2e test
strategy:
matrix:
runs_on: ${{ fromJson(needs.share_matrix_info.outputs.matrix_info) }}
models:
- provider: ChatIBMGenAI
model_id: meta-llama/llama-3-1-70b-instruct
max_new_tokens: 2048
runs-on: ${{ matrix.runs_on.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
repository: konveyor/kai
- uses: actions/setup-java@v3
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
with:
distribution: "oracle"
java-version: "17"
- uses: actions/setup-java@v3
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
with:
distribution: "microsoft"
java-version: "17"
- id: release_info
if: ${{ github.event.inputs.publish_artifacts_to_release || false }}
uses: joutvhu/get-release@v1
with:
latest: ${{ github.event.inputs.use_latest_release }}
pattern: ${{ github.event.inputs.pattern }}
prerelease: ${{ github.event.inputs.pre_release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Set up venv (windows)
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
python -m venv venv
. venv\Scripts\activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Set up venv (linux & mac)
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
run: |
python -m venv venv
. venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: Build RPC server
run: |
pip install pyinstaller
pip install -e .
pyinstaller build/build.spec
env:
PATH: ${{ env.PATH }}
- name: Build Kai Analyzer (non-windows)
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
run: |
cd kai_analyzer_rpc && go build -ldflags="-extldflags=-static" -o kai-analyzer-rpc main.go && cd ..
- name: Build Kai Analyzer (windows)
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
cd kai_analyzer_rpc; go build -ldflags="-extldflags=-static" -o kai-analyzer-rpc main.go; cd ..
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: java-deps.zip
- name: Setup analysis deps (linux & mac)
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
run: |
unzip java-deps.zip -d java-deps
cp -r java-deps/* ./example/analysis
- name: Setup analysis deps (windows)
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
Expand-Archive -Path java-deps.zip -DestinationPath java-deps
- name: Run e2e test
if: ${{ startsWith(matrix.runs_on.os, 'ubuntu') }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Konveyor CI"
cp ./dist/kai-rpc-server ./example/analysis/
cp ./kai_analyzer_rpc/kai-analyzer-rpc ./example/analysis/
rm -f ./example/initialize.toml
cat << EOF > ./example/initialize.toml
root_path = "./coolstore"
analyzer_lsp_java_bundle_paths = [ "./analysis/bundle.jar" ]
analyzer_lsp_lsp_path = "./analysis/jdtls/bin/jdtls"
analyzer_lsp_rpc_path = "./analysis/kai-analyzer-rpc"
analyzer_lsp_rules_paths = [ "./analysis/rulesets/default/generated" ]
analyzer_lsp_dep_labels_path = "./analysis/maven.default.index"
demo_mode = true
enable_reflection = false
[log_config]
log_level = "debug"
file_log_level = "debug"
log_dir_path = "/home/runner/work/kai/kai/kai/../../logs/"
[model_provider]
provider = "${{ matrix.models.provider }}"
[model_provider.args]
model_id = "${{ matrix.models.model_id }}"
EOF
if [[ -n "${{ matrix.models.max_new_tokens }}" ]]; then
cat << EOF >> ./example/initialize.toml
parameters.max_new_tokens = ${{ matrix.models.max_new_tokens }}
EOF
fi
cat ./example/initialize.toml
which python
cd example
./fetch.sh
./run_demo.py
cd coolstore
changed_files_count=$(git diff --name-only | wc -l)
if (( changed_files_count == 26 )); then
echo "Tests passed"
exit 0
else
echo "Tests failed, only $changed_files_count where changed"
git diff --name-only
cat /home/runner/work/kai/kai/kai/../../logs/kai_server.log
cat /home/runner/work/kai/kai/example/logs/kai_server.log
exit 1
fi
env:
PATH: ${{ env.PATH }}
GENAI_KEY: "BWAHAHA"
- name: lowercase runner.os (linux & mac)
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
run: |
echo "OS=`echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
- name: lowercase runner.os (windows)
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
$os_string = "${{ runner.os }}"
$lowercase_os_string = $os_string.ToLower()
echo "OS=$lowercase_os_string" >> $env:GITHUB_ENV
- name: Identify OS Arch (linux & mac)
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
run: |
echo "OS_ARCH=$(uname -m)" >>${GITHUB_ENV}
- name: Identify OS Arch (windows)
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
echo "OS_ARCH=$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)" >> $env:GITHUB_ENV
- name: Archive binaries (linux & mac)
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
run: |
zip -j kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip dist/kai-rpc-server kai_analyzer_rpc/kai-analyzer-rpc ./example/analysis/maven.default.index ./example/analysis/bundle.jar
zip -r kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip ./example/analysis/jdtls ./example/analysis/rulesets
- name: Archive binaries (windows)
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
mv kai_analyzer_rpc\kai-analyzer-rpc kai_analyzer_rpc\kai-analyzer-rpc.exe
$filesToInclude = "dist\kai-rpc-server.exe", "kai_analyzer_rpc\kai-analyzer-rpc.exe", "java-deps\maven.default.index", "java-deps\rulesets", "java-deps\bundle.jar", "java-deps\jdtls"
Compress-Archive -Path $filesToInclude -Destination kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip
- name: Upload binary
if: ${{ github.event.inputs.publish_artifacts_to_release || false }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_info.outputs.upload_url }}
asset_path: kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip
asset_name: kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip
asset_content_type: application/zip
- name: Upload binaries as artifact
if: ${{ !github.event.inputs.publish_artifacts_to_release || true }}
uses: actions/upload-artifact@v4
with:
name: kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip
path: kai-rpc-server.${{ env.OS }}-${{ env.OS_ARCH }}.zip