CI #226
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: CI | |
on: | |
schedule: | |
- cron: '0 20 * * *' # At 8 PM UTC, which is 3 AM UTC+7 | |
push: | |
branches: | |
- main | |
tags: ["v[0-9]+.[0-9]+.[0-9]+"] | |
paths: ['.github/scripts/**','.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cc', '**/*.cxx', '!docs/**', '!.gitignore'] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: ['.github/scripts/**','.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cc', '**/*.cxx', '!docs/**', '!.gitignore'] | |
workflow_dispatch: | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
MODEL_URL: https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF/resolve/main/tinyllama-1.1b-chat-v0.3.Q2_K.gguf | |
jobs: | |
create-draft-release: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
version: ${{ steps.get_version.outputs.version }} | |
permissions: | |
contents: write | |
steps: | |
- name: Extract tag name without v prefix | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV && echo "::set-output name=version::${GITHUB_REF#refs/tags/v}" | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
- name: Create Draft Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: "${{ env.VERSION }}" | |
draft: true | |
prerelease: false | |
ubuntu-amd64-build: | |
runs-on: ubuntu-latest | |
needs: create-draft-release | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') | |
permissions: | |
contents: write | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
# - name: Dependencies | |
# id: depends | |
# run: | | |
# sudo apt-get update | |
# sudo apt-get install build-essential gcc-8 | |
- name: Build | |
id: make_build | |
run: | | |
./install_deps.sh | |
mkdir build && cd build | |
cmake -DDEBUG=ON .. | |
CC=gcc-8 make -j $(nproc) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-linux-amd64 | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-linux-amd64.tar.gz | |
asset_content_type: application/gzip | |
ubuntu-amd64-cuda-build: | |
runs-on: linux-gpu | |
needs: create-draft-release | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') | |
permissions: | |
contents: write | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
# - name: Dependencies | |
# id: depends | |
# run: | | |
# sudo apt-get update | |
# sudo apt-get install build-essential gcc-8 uuid-dev | |
- name: Build | |
id: make_build | |
run: | | |
./install_deps.sh | |
mkdir build && cd build | |
cmake -DDEBUG=ON -DLLAMA_CUBLAS=ON .. | |
CC=gcc-8 make -j $(nproc) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-linux-amd64-cuda | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-linux-amd64-cuda.tar.gz | |
asset_content_type: application/gzip | |
macOS-M-build: | |
runs-on: mac-silicon | |
needs: create-draft-release | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') | |
permissions: | |
contents: write | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Dependencies | |
id: depends | |
continue-on-error: true | |
run: | | |
brew update | |
brew install cmake | |
- name: Build | |
id: cmake_build | |
run: | | |
./install_deps.sh | |
mkdir build && cd build | |
cmake .. | |
CC=gcc-8 make -j $(sysctl -n hw.ncp) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp llama.cpp/ggml-metal.metal nitro/ | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-mac-arm64 | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-mac-arm64.tar.gz | |
asset_content_type: application/gzip | |
macOS-Intel-build: | |
runs-on: macos-latest | |
needs: create-draft-release | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') | |
permissions: | |
contents: write | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Dependencies | |
id: depends | |
continue-on-error: true | |
run: | | |
brew update | |
- name: Build | |
id: cmake_build | |
run: | | |
./install_deps.sh | |
mkdir build && cd build | |
cmake -DLLAMA_METAL=OFF .. | |
CC=gcc-8 make -j $(sysctl -n hw.ncp) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-mac-amd64 | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-mac-amd64.tar.gz | |
asset_content_type: application/gzip | |
windows-amd64-build: | |
runs-on: windows-latest | |
needs: create-draft-release | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') | |
permissions: | |
contents: write | |
env: | |
OPENBLAS_VERSION: 0.3.23 | |
OPENCL_VERSION: 2023.04.17 | |
CLBLAST_VERSION: 1.6.0 | |
strategy: | |
matrix: | |
include: | |
- build: 'normal' | |
defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"' | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup VSWhere.exe | |
uses: warrenbuckley/Setup-VSWhere@v1 | |
with: | |
version: latest | |
silent: true | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- name: actions-setup-cmake | |
uses: jwlawson/[email protected] | |
- name: Build | |
id: cmake_build | |
shell: cmd | |
run: | | |
cmake -S ./nitro_deps -B ./build_deps/nitro_deps | |
cmake --build ./build_deps/nitro_deps --config Release | |
mkdir -p build | |
cd build | |
cmake .. | |
cmake --build . --config Release -j "%NUMBER_OF_PROCESSORS%" | |
- name: Pack artifacts | |
id: pack_artifacts | |
shell: cmd | |
run: | | |
robocopy build_deps\_install\bin .\build\Release zlib.dll | |
robocopy build\bin\Release .\build\Release llama.dll | |
dotnet tool install --global AzureSignTool | |
azuresigntool.exe sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr https://timestamp.globalsign.com/tsa/r6advanced1 -v ".\build\Release\nitro.exe" | |
7z a -ttar temp.tar .\build\Release\* | |
7z a -tgzip nitro.tar.gz temp.tar | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-win-amd64 | |
path: ./build/Release | |
- name: Run e2e testing | |
shell: cmd | |
run: | | |
cd .\build\Release | |
..\..\.github\scripts\e2e-test-windows.bat .\nitro.exe ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-win-amd64.tar.gz | |
asset_content_type: application/gzip | |
windows-amd64-cuda-build: | |
runs-on: windows-nvidia | |
needs: create-draft-release | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
cuda: ['12.2.0'] | |
build: ['cublas'] | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup VSWhere.exe | |
uses: warrenbuckley/Setup-VSWhere@v1 | |
with: | |
version: latest | |
silent: true | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Build | |
id: cmake_build | |
shell: cmd | |
run: | | |
cmake -S ./nitro_deps -B ./build_deps/nitro_deps | |
cmake --build ./build_deps/nitro_deps --config Release | |
mkdir -p build | |
cd build | |
cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON | |
cmake --build . --config Release -j "%NUMBER_OF_PROCESSORS%" | |
- name: Pack artifacts | |
id: pack_artifacts | |
shell: cmd | |
run: | | |
set PATH=%PATH%;C:\Program Files\7-Zip\ | |
robocopy build_deps\_install\bin .\build\Release zlib.dll | |
robocopy build\bin\Release .\build\Release llama.dll | |
dotnet tool install --global AzureSignTool | |
%USERPROFILE%\.dotnet\tools\azuresigntool.exe sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr https://timestamp.globalsign.com/tsa/r6advanced1 -v ".\build\Release\nitro.exe" | |
7z a -ttar temp.tar .\build\Release\* | |
7z a -tgzip nitro.tar.gz temp.tar | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-win-amd64-cuda | |
path: ./build/Release | |
- name: run e2e testing | |
shell: cmd | |
run: | | |
cd .\build\Release | |
..\..\.github\scripts\e2e-test-windows.bat .\nitro.exe ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-win-amd64-cuda.tar.gz | |
asset_content_type: application/gzip | |
update_release_draft: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
needs: [ubuntu-amd64-build, ubuntu-amd64-cuda-build, macOS-M-build, macOS-Intel-build, windows-amd64-build, windows-amd64-cuda-build] | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: release-drafter/release-drafter@v5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
noti-discord-nightly: | |
if: always() && github.event_name == 'schedule' && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.ubuntu-amd64-build.result == 'success' && needs.ubuntu-amd64-cuda-build.result == 'success' && needs.macOS-M-build.result == 'success' && needs.macOS-Intel-build.result == 'success' && needs.windows-amd64-build.result == 'success' && needs.windows-amd64-cuda-build.result == 'success' | |
needs: [create-draft-release, ubuntu-amd64-build, ubuntu-amd64-cuda-build, macOS-M-build, macOS-Intel-build, windows-amd64-build, windows-amd64-cuda-build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify Discord | |
uses: Ilshidur/action-discord@master | |
with: | |
args: "Nightly build artifact: https://github.com/janhq/nitro/actions/runs/{{ GITHUB_RUN_ID }}" | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
noti-discord-manual: | |
if: always() && github.event_name == 'workflow_dispatch' && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.ubuntu-amd64-build.result == 'success' && needs.ubuntu-amd64-cuda-build.result == 'success' && needs.macOS-M-build.result == 'success' && needs.macOS-Intel-build.result == 'success' && needs.windows-amd64-build.result == 'success' && needs.windows-amd64-cuda-build.result == 'success' | |
needs: [create-draft-release, ubuntu-amd64-build, ubuntu-amd64-cuda-build, macOS-M-build, macOS-Intel-build, windows-amd64-build, windows-amd64-cuda-build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify Discord | |
uses: Ilshidur/action-discord@master | |
with: | |
args: "Manual build artifact: https://github.com/janhq/nitro/actions/runs/{{ GITHUB_RUN_ID }}" | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} |