generated from konveyor-ecosystem/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 38
400 lines (347 loc) · 15.1 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
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
# TODO: removing { "os": "windows-11-preview-arm", "shell": "cmd" }, from the matrix
# we have to wait for the a real image to be published that actually has what we
# need to use it. This wil be fine for now.
env:
BUILD_MATRIX: |
[
{ "os": "ubuntu-20.04", "shell": "bash" },
{ "os": "macos-latest", "shell": "bash" },
{ "os": "macos-13", "shell": "bash" },
{ "os": "ubuntu-22.04-arm", "shell": "bash" },
{ "os": "windows-latest", "shell": "cmd" }
]
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:
#fail-fast: false
matrix:
runs_on: ${{ fromJson(needs.share_matrix_info.outputs.matrix_info) }}
models:
- provider: ChatOpenAI
model_id: kai-test-generation
runs-on: ${{ matrix.runs_on.os }}
steps:
# Keeping these steps, because if we must, we may need to use them to get arm builds for windows.
- name: Download Git for Windows (aarch64)
uses: robinraju/release-downloader@v1
if: ${{ matrix.runs_on.os == 'windows-11-preview-arm'}}
with:
repository: "git-for-windows/git"
tag: "v2.48.0-rc1.windows.1"
filename: "Git-2.48.0-rc1-arm64.exe"
- name: Install Git for Windows (aarch64)
if: ${{ matrix.runs_on.os == 'windows-11-preview-arm'}}
run: |
Start-Process -FilePath "Git-2.48.0-rc1-arm64.exe" -ArgumentList "/VERYSILENT" -NoNewWindow -Wait
Add-Content -Path $env:GITHUB_PATH -Value "C:\Program Files\Git\cmd" -Encoding utf8
Add-Content -Path $env:GITHUB_PATH -Value "C:\Program Files\Git\bin" -Encoding utf8
- name: install windows compilers
if: ${{ matrix.runs_on.os == 'windows-11-preview-arm'}}
run: |
Set-ExecutionPolicy Bypass -Scope Process
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
echo "C:\ProgramData\chocolatey\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
choco feature enable -n allowGlobalConfirmation
choco install visualstudio2022-workload-vctools --package-parameters "--includeOptional"
choco install -y llvm
Get-ChildItem -Path "C:\Program Files\LLVM\bin" -ErrorAction Ignore
Get-ChildItem -Path "C:\Program Files (x86)\LLVM\bin" -ErrorAction Ignore
& "C:\Program Files\LLVM\bin\clang.exe" --version
Add-Content -Path $env:GITHUB_PATH -Value "C:\Program Files\LLVM\bin" -Encoding utf8
Set-Alias -Name clang -Value "C:\Program Files\LLVM\bin\clang.exe"
clang --version
- 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"
- name: Set up Maven
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.9
- name: Add things to path
if: ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
Add-Content -Path $env:GITHUB_PATH -Value "C:\Program Files\Git\cmd" -Encoding utf8
Add-Content -Path $env:GITHUB_PATH -Value "C:\Program Files\Git\bin" -Encoding utf8
Add-Content -Path $env:GITHUB_PATH -Value "C:\hostedtoolcache\windows\maven\3.9.9\x64\bin" -Encoding utf8
Add-Content -Path $env:GITHUB_ENV -Value "Path=$env:Path;C:\hostedtoolcache\windows\maven\3.9.9\x64\bin" -Encoding utf8
- 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 (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
Copy-Item -Verbose -Path .\java-deps\* -Destination .\example\analysis -Recurse
- name: Run e2e test
if: false # ${{ startsWith(matrix.runs_on.os, 'windows') }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Konveyor CI"
cp ./dist/kai-rpc-server.exe ./example/analysis/
cp ./kai_analyzer_rpc/kai-analyzer-rpc ./example/analysis/
Remove-Item -Path .\example\initialize.toml
New-Item -Path ".\example\initialize.toml" -ItemType File -Value @"
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 = "info"
file_log_level = "debug"
log_dir_path = '${{github.workspace}}\logs\'
[model_provider]
provider = "${{ matrix.models.provider }}"
[model_provider.args]
model = "${{ matrix.models.model_id }}"
"@
if ("${{ matrix.models.max_new_tokens }}") {
Add-Content -Path ".\example\initialize.toml" -Value "parameters.max_new_tokens = ${{ matrix.models.max_new_tokens }}"
}
Get-Content -Path .\example\initialize.toml
Get-Command python
Set-Location -Path .\example
git clone https://github.com/konveyor-ecosystem/coolstore.git
pip list
python run_demo.py
cd coolstore
$changed_files_count = (git diff --name-only | Measure-Object).Count
if ($changed_files_count -eq 26) {
echo "Tests passed"
exit 0
}
else {
echo "Tests failed, only $changed_files_count where changed"
git diff --name-only
cat ../../logs/kai_server.log
cat ../../logs/kai_server.log
exit 1
}
env:
GENAI_KEY: "BWAHAHA"
OPENAI_API_KEY: "BWAHAHA"
- name: Run e2e test
if: ${{ ! startsWith(matrix.runs_on.os, 'windows') }}
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/
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 = "info"
file_log_level = "debug"
log_dir_path = "${{github.workspace}}/logs/"
[model_provider]
provider = "${{ matrix.models.provider }}"
[model_provider.args]
model = "${{ 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 ../../logs/kai_server.log
cat ../../logs/kai_server.log
exit 1
fi
env:
PATH: ${{ env.PATH }}
GENAI_KEY: "BWAHAHA"
OPENAI_API_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