-
Notifications
You must be signed in to change notification settings - Fork 2
182 lines (156 loc) · 7.08 KB
/
macos_test.yaml
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
name: Build, Sign, and Run Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run_test:
runs-on: self-hosted
strategy:
matrix:
os: [
macos-latest,
]
build_type: [ debug ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.LOCAL_AI_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.LOCAL_AI_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.LOCAL_AI_AWS_REGION }}
- name: Download artifact from S3 (Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
aws s3 cp s3://appflowy-local-ai-test/${{ matrix.os }}/AppFlowyLLM_${{ matrix.build_type }}.zip AppFlowyLLM_${{ matrix.os }}_${{ matrix.build_type }}.zip
unzip AppFlowyLLM_${{ matrix.os }}_${{ matrix.build_type }}.zip -d AppFlowyLLM
cd AppFlowyLLM
pwd
ls
shell: bash
- name: Download artifact from S3 (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
aws s3 cp s3://appflowy-local-ai-test/${{ matrix.os }}/AppFlowyLLM_${{ matrix.build_type }}.zip AppFlowyLLM_${{ matrix.os }}_${{ matrix.build_type }}.zip
Expand-Archive -Path AppFlowyLLM_${{ matrix.os }}_${{ matrix.build_type }}.zip -DestinationPath AppFlowyLLM
cd AppFlowyLLM
dir
shell: powershell
- name: Download models (Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
curl -sSL -o tinyllama.gguf "https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_0.gguf?download=true"
curl -sSL -o all-MiniLM-L12-v2.F16.gguf "https://huggingface.co/leliuga/all-MiniLM-L12-v2-GGUF/resolve/main/all-MiniLM-L12-v2.F16.gguf?download=true"
ls
- name: Download models (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
Invoke-WebRequest -Uri "https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_0.gguf?download=true" -OutFile tinyllama.gguf
Invoke-WebRequest -Uri "https://huggingface.co/leliuga/all-MiniLM-L12-v2-GGUF/resolve/main/all-MiniLM-L12-v2.F16.gguf?download=true" -OutFile all-MiniLM-L12-v2.F16.gguf
dir
- name: Prepare env (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
ls
ABS_PATH=$(pwd)
chat_bin_path=$ABS_PATH/AppFlowyLLM/appflowy_ai_plugin
embedding_bin_path=$ABS_PATH/AppFlowyLLM/appflowy_embedding_plugin
cp dev.env .env
sed -i '' 's|RUST_LOG=.*|RUST_LOG=trace|' .env
# binary
sed -i '' "s|CHAT_BIN_PATH=.*|CHAT_BIN_PATH=$chat_bin_path|" .env
sed -i '' "s|EMBEDDING_BIN_PATH=.*|EMBEDDING_BIN_PATH=$embedding_bin_path|" .env
# model
sed -i '' "s|LOCAL_AI_MODEL_DIR=.*|LOCAL_AI_MODEL_DIR=$ABS_PATH|" .env
sed -i '' 's|LOCAL_AI_CHAT_MODEL_NAME=.*|LOCAL_AI_CHAT_MODEL_NAME=tinyllama.gguf|' .env
sed -i '' 's|LOCAL_AI_EMBEDDING_MODEL_NAME=.*|LOCAL_AI_EMBEDDING_MODEL_NAME=all-MiniLM-L12-v2.F16.gguf|' .env
cat .env
shell: bash
- name: Prepare env (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
ABS_PATH=$(pwd)
chat_bin_path=$ABS_PATH/AppFlowyLLM/appflowy_ai_plugin
embedding_bin_path=$ABS_PATH/AppFlowyLLM/appflowy_embedding_plugin
cp dev.env .env
sed -i 's|RUST_LOG=.*|RUST_LOG=trace|' .env
# binary
sed -i "s|CHAT_BIN_PATH=.*|CHAT_BIN_PATH=$chat_bin_path|" .env
sed -i "s|EMBEDDING_BIN_PATH=.*|EMBEDDING_BIN_PATH=$embedding_bin_path|" .env
# model
sed -i "s|LOCAL_AI_MODEL_DIR=.*|LOCAL_AI_MODEL_DIR=$ABS_PATH|" .env
sed -i 's|LOCAL_AI_CHAT_MODEL_NAME=.*|LOCAL_AI_CHAT_MODEL_NAME=tinyllama.gguf|' .env
sed -i 's|LOCAL_AI_EMBEDDING_MODEL_NAME=.*|LOCAL_AI_EMBEDDING_MODEL_NAME=all-MiniLM-L12-v2.F16.gguf|' .env
cat .env
shell: bash
- name: Prepare env (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
$ErrorActionPreference = 'Stop'
try {
$ABS_PATH = $PWD.Path
$chat_bin_path = Join-Path $ABS_PATH 'AppFlowyLLM' 'appflowy_ai_plugin.exe'
$embedding_bin_path = Join-Path $ABS_PATH 'AppFlowyLLM' 'appflowy_embedding_plugin.exe'
Copy-Item -Path 'dev.env' -Destination '.env' -Force
$envContent = Get-Content '.env'
$envContent = $envContent -replace 'RUST_LOG=.*', 'RUST_LOG=trace'
$envContent = $envContent -replace 'CHAT_BIN_PATH=.*', "CHAT_BIN_PATH=$chat_bin_path"
$envContent = $envContent -replace 'EMBEDDING_BIN_PATH=.*', "EMBEDDING_BIN_PATH=$embedding_bin_path"
$envContent = $envContent -replace 'LOCAL_AI_MODEL_DIR=.*', "LOCAL_AI_MODEL_DIR=$ABS_PATH"
$envContent = $envContent -replace 'LOCAL_AI_CHAT_MODEL_NAME=.*', 'LOCAL_AI_CHAT_MODEL_NAME=tinyllama.gguf'
$envContent = $envContent -replace 'LOCAL_AI_EMBEDDING_MODEL_NAME=.*', 'LOCAL_AI_EMBEDDING_MODEL_NAME=all-MiniLM-L12-v2.F16.gguf'
$envContent | Set-Content '.env'
Get-Content '.env'
Write-Host "Environment setup completed successfully."
}
catch {
Write-Host "An error occurred during environment setup: $_"
exit 1
}
shell: pwsh
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.2
override: true
profile: minimal
- name: Run tests
if: ${{ matrix.os != 'windows-latest' }}
run: cargo test ci_
shell: bash
- name: Load .env file
if: ${{ matrix.os == 'windows-latest' }}
run: |
Get-Content .env | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
$name = $matches[1]
$value = $matches[2]
Write-Output "$name=$value" >> $env:GITHUB_ENV
}
}
shell: powershell
- name: Run tests (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: cargo test ci_
shell: powershell
- name: Cleanup downloaded artifacts (Unix)
if: ${{ matrix.os != 'windows-latest' }}
run: |
rm -rf AppFlowyLLM_${{ matrix.os }}_${{ matrix.build_type }}.zip
rm -rf AppFlowyLLM
rm -rf tinyllama.gguf
rm -rf all-MiniLM-L12-v
- name: Cleanup downloaded artifacts (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
Remove-Item -Recurse -Force AppFlowyLLM_${{ matrix.os }}_${{ matrix.build_type }}.zip
Remove-Item -Recurse -Force AppFlowyLLM
Remove-Item -Recurse -Force tinyllama.gguf
Remove-Item -Recurse -Force all-MiniLM-L12-v2.F16.gguf
dir
shell: powershell