Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 25173dd

Browse files
committed
Initiate CICD nightly
1 parent 722ec0c commit 25173dd

File tree

2 files changed

+200
-0
lines changed

2 files changed

+200
-0
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI Cortex CPP Nightly Build
2+
3+
on:
4+
schedule:
5+
- cron: '0 20 * * *' # At 8 PM UTC everyday
6+
workflow_dispatch:
7+
inputs:
8+
public_provider:
9+
type: choice
10+
description: 'Public Provider'
11+
options:
12+
- none
13+
- aws-s3
14+
default: none
15+
16+
env:
17+
LLM_MODEL_URL: https://delta.jan.ai/tinyllama-1.1b-chat-v0.3.Q2_K.gguf
18+
EMBEDDING_MODEL_URL: https://catalog.jan.ai/dist/models/embeds/nomic-embed-text-v1.5.f16.gguf
19+
20+
jobs:
21+
set-public-provider:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
public_provider: ${{ steps.set-public-provider.outputs.public_provider }}
25+
ref: ${{ steps.set-public-provider.outputs.ref }}
26+
steps:
27+
- name: Set public provider
28+
id: set-public-provider
29+
run: |
30+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
31+
echo "::set-output name=public_provider::${{ github.event.inputs.public_provider }}"
32+
echo "::set-output name=ref::${{ github.ref }}"
33+
else
34+
if [ "${{ github.event_name }}" == "schedule" ]; then
35+
echo "::set-output name=public_provider::aws-s3"
36+
echo "::set-output name=ref::refs/heads/dev"
37+
elif [ "${{ github.event_name }}" == "push" ]; then
38+
echo "::set-output name=public_provider::aws-s3"
39+
echo "::set-output name=ref::${{ github.ref }}"
40+
else
41+
echo "::set-output name=public_provider::none"
42+
echo "::set-output name=ref::${{ github.ref }}"
43+
fi
44+
fi
45+
46+
# Job create Update app version based on latest release tag with build number and save to output
47+
get-update-version:
48+
uses: ./.github/workflows/template-get-update-version.yml
49+
50+
build-and-test:
51+
runs-on: ${{ matrix.runs-on }}
52+
needs: [get-update-version, set-public-provider]
53+
timeout-minutes: 60
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
include:
58+
- os: "linux"
59+
name: "amd64"
60+
runs-on: "ubuntu-20-04-cuda-12-0"
61+
cmake-flags: "-DCORTEX_CPP_VERSION=${{ needs.get-update-version.outputs.new_version }} -DCMAKE_TOOLCHAIN_FILE=/home/runner/actions-runner/_work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
62+
build-deps-cmake-flags: ""
63+
ccache-dir: ''
64+
- os: "mac"
65+
name: "amd64"
66+
runs-on: "macos-13"
67+
cmake-flags: "-DCORTEX_CPP_VERSION=${{ needs.get-update-version.outputs.new_version }} -DCMAKE_TOOLCHAIN_FILE=/Users/runner/work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
68+
build-deps-cmake-flags: ""
69+
ccache-dir: ''
70+
- os: "mac"
71+
name: "arm64"
72+
runs-on: "macos-latest"
73+
cmake-flags: "-DCORTEX_CPP_VERSION=${{ needs.get-update-version.outputs.new_version }} -DMAC_ARM64=ON -DCMAKE_TOOLCHAIN_FILE=/Users/runner/work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
74+
build-deps-cmake-flags: ""
75+
ccache-dir: ''
76+
- os: "windows"
77+
name: "amd64"
78+
runs-on: "windows-cuda-12-0"
79+
cmake-flags: "-DCORTEX_CPP_VERSION=${{ needs.get-update-version.outputs.new_version }} -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"
80+
build-deps-cmake-flags: "-DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja"
81+
ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache'
82+
steps:
83+
- name: Clone
84+
id: checkout
85+
uses: actions/checkout@v3
86+
with:
87+
submodules: recursive
88+
89+
- name: Install choco on Windows
90+
if: runner.os == 'Windows'
91+
run: |
92+
choco install make pkgconfiglite ccache awscli 7zip ninja -y
93+
94+
- name: Download ccache from s3
95+
if: runner.os == 'Windows'
96+
continue-on-error: true
97+
run: |
98+
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
99+
refreshenv
100+
aws s3 cp s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-${{ matrix.os }}-${{ matrix.name }} ${{ matrix.ccache-dir }} --recursive --endpoint ${{ secrets.MINIO_ENDPOINT }}
101+
env:
102+
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
103+
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
104+
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
105+
106+
- name: Configure vcpkg
107+
run: |
108+
cd engine
109+
make configure-vcpkg
110+
111+
- name: Build
112+
run: |
113+
cd engine
114+
make build CMAKE_EXTRA_FLAGS="${{ matrix.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ matrix.build-deps-cmake-flags }}"
115+
116+
- name: Pre-package
117+
run: |
118+
cd engine
119+
make pre-package
120+
121+
- name: Package
122+
run: |
123+
cd engine
124+
make package
125+
126+
- name: Upload Artifact
127+
uses: actions/upload-artifact@v2
128+
with:
129+
name: cortex-cpp-${{ matrix.os }}-${{ matrix.name }}
130+
path: ./engine/cortex-cpp
131+
132+
- name: Upload ccache to s3
133+
continue-on-error: true
134+
if: always() && runner.os == 'Windows'
135+
run: |
136+
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
137+
refreshenv
138+
aws s3 cp ${{ matrix.ccache-dir }} s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-${{ matrix.os }}-${{ matrix.name }} --recursive --endpoint ${{ secrets.MINIO_ENDPOINT }}
139+
env:
140+
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
141+
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
142+
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: get-update-version
2+
on:
3+
workflow_call:
4+
outputs:
5+
new_version:
6+
description: 'The new version of the app'
7+
value: ${{ jobs.get-update-version.outputs.new_version }}
8+
9+
jobs:
10+
get-update-version:
11+
runs-on: ubuntu-latest
12+
environment: production
13+
outputs:
14+
new_version: ${{ steps.version_update.outputs.new_version }}
15+
steps:
16+
- name: Install jq
17+
uses: dcarbone/[email protected]
18+
19+
- name: Get tag
20+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
21+
id: tag
22+
uses: dawidd6/action-get-tag@v1
23+
24+
- name: Update app version based on latest release tag with build number
25+
id: version_update
26+
run: |
27+
# Function to get the latest release tag
28+
get_latest_tag() {
29+
local retries=0
30+
local max_retries=3
31+
local tag
32+
while [ $retries -lt $max_retries ]; do
33+
tag=$(curl -s https://api.github.com/repos/janhq/cortex.cpp/releases/latest | jq -r .tag_name)
34+
if [ -n "$tag" ] && [ "$tag" != "null" ]; then
35+
echo $tag
36+
return
37+
else
38+
let retries++
39+
echo "Retrying... ($retries/$max_retries)"
40+
sleep 2
41+
fi
42+
done
43+
echo "Failed to fetch latest tag after $max_retries attempts."
44+
exit 1
45+
}
46+
47+
if ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}; then
48+
echo "Tag detected, set output follow tag"
49+
echo "::set-output name=new_version::${{ steps.tag.outputs.tag }}"
50+
else
51+
# Get the latest release tag from GitHub API
52+
LATEST_TAG=$(get_latest_tag)
53+
54+
# Remove the 'v' and append the build number to the version
55+
new_version="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
56+
echo "New version: $new_version"
57+
echo "::set-output name=new_version::$new_version"
58+
fi

0 commit comments

Comments
 (0)