👻 Config changes #451
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_path = "./analysis/bundle.jar" | |
analyzer_lsp_lsp_path = "./analysis/jdtls/bin/jdtls" | |
analyzer_lsp_rpc_path = "./analysis/kai-analyzer-rpc" | |
analyzer_lsp_rules_path = "./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 |