1414
1515jobs :
1616 build-and-test :
17+ if : (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'workflow_dispatch'
1718 runs-on : ${{ matrix.runs-on }}
1819 timeout-minutes : 60
1920 strategy :
@@ -255,6 +256,7 @@ jobs:
255256 AWS_DEFAULT_REGION : " ${{ secrets.MINIO_REGION }}"
256257
257258 build-docker-and-test :
259+ if : (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'workflow_dispatch'
258260 runs-on : ubuntu-24-04-docker
259261 steps :
260262 - name : Getting the repo
@@ -309,3 +311,249 @@ jobs:
309311 docker stop cortex
310312 docker rm cortex
311313 echo "y\n" | docker system prune -af
314+
315+ build-and-test-target-pr :
316+ permissions :
317+ contents : read
318+ if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
319+ runs-on : ${{ matrix.runs-on }}
320+ timeout-minutes : 60
321+ strategy :
322+ fail-fast : false
323+ matrix :
324+ include :
325+ - os : " linux"
326+ name : " arm64"
327+ runs-on : " ubuntu-2004-arm64"
328+ cmake-flags : " -DCORTEX_CPP_VERSION=${{github.event.pull_request.head.sha}} -DCMAKE_BUILD_TEST=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
329+ build-deps-cmake-flags : " "
330+ ccache-dir : " "
331+ - os : " linux"
332+ name : " amd64"
333+ runs-on : " ubuntu-20-04-cuda-12-0"
334+ cmake-flags : " -DCORTEX_CPP_VERSION=${{github.event.pull_request.head.sha}} -DCMAKE_BUILD_TEST=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
335+ build-deps-cmake-flags : " "
336+ ccache-dir : " "
337+ - os : " mac"
338+ name : " amd64"
339+ runs-on : " macos-selfhosted-12"
340+ cmake-flags : " -DCORTEX_CPP_VERSION=${{github.event.pull_request.head.sha}} -DCMAKE_BUILD_TEST=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
341+ build-deps-cmake-flags : " "
342+ ccache-dir : " "
343+ - os : " mac"
344+ name : " arm64"
345+ runs-on : " macos-selfhosted-12-arm64"
346+ cmake-flags : " -DCORTEX_CPP_VERSION=${{github.event.pull_request.head.sha}} -DCMAKE_BUILD_TEST=ON -DMAC_ARM64=ON -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake"
347+ build-deps-cmake-flags : " "
348+ ccache-dir : " "
349+ - os : " windows"
350+ name : " amd64"
351+ runs-on : " windows-cuda-12-0"
352+ cmake-flags : " -DCORTEX_CPP_VERSION=${{github.event.pull_request.head.sha}} -DCMAKE_BUILD_TEST=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=C:/w/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja"
353+ build-deps-cmake-flags : " -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja"
354+ ccache-dir : ' C:\Users\ContainerAdministrator\AppData\Local\ccache'
355+ steps :
356+ - name : Clone
357+ id : checkout
358+ uses : actions/checkout@v3
359+ with :
360+ submodules : recursive
361+
362+ - name : use python
363+ continue-on-error : true
364+ uses : actions/setup-python@v5
365+ with :
366+ python-version : " 3.10"
367+
368+ - name : Install tools on Linux
369+ if : runner.os == 'Linux'
370+ run : |
371+ python3 -m pip install awscli
372+
373+ - name : Install choco on Windows
374+ if : runner.os == 'Windows'
375+ run : |
376+ choco install make pkgconfiglite ccache awscli 7zip ninja -y
377+
378+ - name : Configure vcpkg
379+ if : runner.os != 'Linux'
380+ run : |
381+ cd engine
382+ make configure-vcpkg
383+
384+ - name : Configure vcpkg linux amd64
385+ if : runner.os != 'Linux'
386+ run : |
387+ cd engine
388+ make configure-vcpkg
389+
390+ - name : Configure vcpkg linux arm64
391+ if : runner.os == 'Linux'
392+ run : |
393+ cd engine
394+ # Set env if arch is arm64
395+ if [ "${{ matrix.name }}" == "arm64" ]; then
396+ sudo apt install ninja-build pkg-config -y
397+ export VCPKG_FORCE_SYSTEM_BINARIES=1
398+ fi
399+ make configure-vcpkg
400+
401+ - name : Build
402+ if : runner.os != 'Linux'
403+ run : |
404+ cd engine
405+ make build CMAKE_EXTRA_FLAGS="${{ matrix.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ matrix.build-deps-cmake-flags }}"
406+
407+ - name : Build
408+ if : runner.os == 'Linux'
409+ run : |
410+ cd engine
411+ if [ "${{ matrix.name }}" == "arm64" ]; then
412+ export VCPKG_FORCE_SYSTEM_BINARIES=1
413+ fi
414+ make build CMAKE_EXTRA_FLAGS="${{ matrix.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ matrix.build-deps-cmake-flags }}"
415+
416+ - name : Run setup config
417+ run : |
418+ cd engine
419+ echo "gitHubToken: ${{ secrets.GITHUB_TOKEN }}" > ~/.cortexrc
420+ # ./build/cortex
421+ cat ~/.cortexrc
422+
423+ - name : Run unit tests
424+ run : |
425+ cd engine
426+ make run-unit-tests
427+ env :
428+ GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
429+
430+ - name : Run setup config
431+ run : |
432+ cd engine
433+ echo "apiServerPort: 3928" > ~/.cortexrc
434+ echo "gitHubToken: ${{ secrets.GITHUB_TOKEN }}" > ~/.cortexrc
435+ # ./build/cortex
436+ cat ~/.cortexrc
437+
438+ - name : Run e2e tests
439+ if : github.event_name != 'schedule' && runner.os != 'Windows' && github.event.pull_request.draft == false
440+ run : |
441+ cd engine
442+ cp build/cortex build/cortex-nightly
443+ cp build/cortex build/cortex-beta
444+ python -m pip install --upgrade pip
445+ python -m pip install -r e2e-test/requirements.txt
446+ python e2e-test/main.py
447+ rm build/cortex-nightly
448+ rm build/cortex-beta
449+ env :
450+ GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
451+
452+ - name : Run e2e tests
453+ if : github.event_name != 'schedule' && runner.os == 'Windows' && github.event.pull_request.draft == false
454+ run : |
455+ cd engine
456+ cp build/cortex.exe build/cortex-nightly.exe
457+ cp build/cortex.exe build/cortex-beta.exe
458+ python -m pip install --upgrade pip
459+ python -m pip install -r e2e-test/requirements.txt
460+ python e2e-test/main.py
461+ rm build/cortex-nightly.exe
462+ rm build/cortex-beta.exe
463+ env :
464+ GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
465+
466+ - name : Run e2e tests
467+ if : github.event_name == 'schedule' && runner.os != 'Windows' && github.event.pull_request.draft == false
468+ run : |
469+ cd engine
470+ cp build/cortex build/cortex-nightly
471+ cp build/cortex build/cortex-beta
472+ python -m pip install --upgrade pip
473+ python -m pip install -r e2e-test/requirements.txt
474+ python e2e-test/cortex-llamacpp-e2e-nightly.py
475+ rm build/cortex-nightly
476+ rm build/cortex-beta
477+ env :
478+ GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
479+
480+ - name : Run e2e tests
481+ if : github.event_name == 'schedule' && runner.os == 'Windows' && github.event.pull_request.draft == false
482+ run : |
483+ cd engine
484+ cp build/cortex.exe build/cortex-nightly.exe
485+ cp build/cortex.exe build/cortex-beta.exe
486+ python -m pip install --upgrade pip
487+ python -m pip install -r e2e-test/requirements.txt
488+ python e2e-test/cortex-llamacpp-e2e-nightly.py
489+ rm build/cortex-nightly.exe
490+ rm build/cortex-beta.exe
491+ env :
492+ GITHUB_TOKEN : ${{ secrets.PAT_SERVICE_ACCOUNT }}
493+
494+ - name : Pre-package
495+ run : |
496+ cd engine
497+ make pre-package DESTINATION_BINARY_NAME="cortex"
498+
499+ - name : Package
500+ run : |
501+ cd engine
502+ make package
503+
504+ - name : Upload Artifact
505+ uses : actions/upload-artifact@v4
506+ with :
507+ name : cortex-${{ matrix.os }}-${{ matrix.name }}
508+ path : ./engine/cortex
509+
510+ build-docker-and-test-target-pr :
511+ permissions :
512+ contents : read
513+ if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
514+ runs-on : ubuntu-24-04-docker
515+ steps :
516+ - name : Getting the repo
517+ uses : actions/checkout@v3
518+ with :
519+ submodules : ' recursive'
520+
521+ - name : Run Docker
522+ if : github.event_name != 'schedule'
523+ run : |
524+ docker build \
525+ -t menloltd/cortex:test -f docker/Dockerfile .
526+ docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
527+ sleep 20
528+
529+ - name : Run Docker
530+ if : github.event_name == 'schedule'
531+ run : |
532+ latest_prerelease=$(curl -s https://api.github.com/repos/cortexcpp/cortex.cpp/releases | jq -r '.[] | select(.prerelease == true) | .tag_name' | head -n 1)
533+ echo "cortex.llamacpp latest release: $latest_prerelease"
534+ docker build \
535+ --build-arg CORTEX_CPP_VERSION="${latest_prerelease}" \
536+ -t menloltd/cortex:test -f docker/Dockerfile .
537+ docker run -it -d -p 3928:39281 --name cortex menloltd/cortex:test
538+ sleep 20
539+
540+ - name : use python
541+ uses : actions/setup-python@v5
542+ with :
543+ python-version : " 3.10"
544+
545+ - name : Run e2e tests
546+ run : |
547+ cd engine
548+ python -m pip install --upgrade pip
549+ python -m pip install -r e2e-test/requirements.txt
550+ pytest e2e-test/test_api_docker.py
551+
552+ - name : Run Docker
553+ continue-on-error : true
554+ if : always()
555+ run : |
556+ docker logs cortex
557+ docker stop cortex
558+ docker rm cortex
559+ echo "y\n" | docker system prune -af
0 commit comments