forked from flagos-ai/FlagScale
-
Notifications
You must be signed in to change notification settings - Fork 0
270 lines (243 loc) · 8.83 KB
/
Copy pathfunctional_tests_cli.yml
File metadata and controls
270 lines (243 loc) · 8.83 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# Copyright 2026 FlagOS Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Common Functional Tests - CLI
on:
workflow_call:
inputs:
platform:
required: true
type: string
description: Platform name (e.g., cuda, default)
image:
required: true
type: string
runs_on:
required: true
type: string
container_volumes:
required: true
type: string
container_options:
required: true
type: string
pkg_mgr:
required: false
type: string
description: Package manager (pip, uv, conda). Default uv.
default: "uv"
env_name:
required: false
type: string
description: Conda environment name (for conda only)
default: ""
env_path:
required: false
type: string
description: Environment path (venv path for uv, conda installation path for conda)
default: "/opt/venv"
jobs:
functional_test_cli:
defaults:
run:
shell: bash
env:
PROJECT_ROOT: ${{ github.workspace }}/FlagScale
runs-on: ${{ fromJson(inputs.runs_on) }}
container:
image: ${{ inputs.image }}
ports:
- 80
volumes: ${{ fromJson(inputs.container_volumes) }}
options: ${{ inputs.container_options }}
steps:
- name: Checkout code (attempt 1)
id: checkout_attempt_1
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
path: FlagScale
ssh-strict: true
ssh-user: git
persist-credentials: false
clean: true
sparse-checkout-cone-mode: true
fetch-tags: false
show-progress: true
lfs: false
submodules: false
set-safe-directory: true
- name: Checkout code (attempt 2)
if: steps.checkout_attempt_1.outcome == 'failure'
id: checkout_attempt_2
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
path: FlagScale
ssh-strict: true
ssh-user: git
persist-credentials: false
clean: true
sparse-checkout-cone-mode: true
fetch-tags: false
show-progress: true
lfs: false
submodules: false
set-safe-directory: true
- name: Checkout code (attempt 3)
if: steps.checkout_attempt_2.outcome == 'failure'
id: checkout_attempt_3
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.ref || github.ref }}
path: FlagScale
ssh-strict: true
ssh-user: git
persist-credentials: false
clean: true
sparse-checkout-cone-mode: true
fetch-tags: false
show-progress: true
lfs: false
submodules: false
set-safe-directory: true
- name: Set safe directory
run: |
git config --global --add safe.directory $PROJECT_ROOT
- name: Check environment info
run: cd $PROJECT_ROOT && bash ./tests/test_utils/runners/check_env.sh
- name: Install FlagScale CLI
run: |
set -euo pipefail
cd $PROJECT_ROOT
PKG_MGR='${{ inputs.pkg_mgr }}'
ENV_NAME='${{ inputs.env_name }}'
ENV_PATH='${{ inputs.env_path }}'
echo "Installing FlagScale CLI"
echo "Package Manager: $PKG_MGR"
echo "Environment Name: $ENV_NAME"
echo "Environment Path: $ENV_PATH"
# Source environment utilities
source ./tools/install/utils/pyenv_utils.sh
# Activate environment based on package manager
case "$PKG_MGR" in
conda)
if [ -n "$ENV_NAME" ] && [ -n "$ENV_PATH" ]; then
activate_conda "$ENV_NAME" "$ENV_PATH" || { echo "❌ Conda activation failed"; exit 1; }
fi
;;
uv)
if [ -n "$ENV_PATH" ] && [ -d "$ENV_PATH" ]; then
activate_uv_env "$ENV_PATH" || { echo "❌ UV activation failed"; exit 1; }
fi
;;
pip)
echo "Using system Python with pip"
;;
esac
echo "Python location: $(which python)"
echo "Python version: $(python --version)"
# Install FlagScale CLI
pip install . --no-build-isolation --root-user-action=ignore || { echo "❌ FlagScale CLI install failed"; exit 1; }
# Verify installation
command -v flagscale || { echo "❌ FlagScale CLI not found in PATH"; exit 1; }
echo "✅ FlagScale CLI installed successfully"
timeout-minutes: 10
- name: Validate CLI functionality
id: cli_validation
run: |
set -euo pipefail
cd $PROJECT_ROOT
PKG_MGR='${{ inputs.pkg_mgr }}'
ENV_NAME='${{ inputs.env_name }}'
ENV_PATH='${{ inputs.env_path }}'
# Source environment utilities
source ./tools/install/utils/pyenv_utils.sh
# Activate environment based on package manager
# Activate environment based on package manager
case "$PKG_MGR" in
conda)
if [ -n "$ENV_NAME" ] && [ -n "$ENV_PATH" ]; then
activate_conda "$ENV_NAME" "$ENV_PATH" || { echo "❌ Conda activation failed"; exit 1; }
fi
;;
uv)
if [ -n "$ENV_PATH" ] && [ -d "$ENV_PATH" ]; then
activate_uv_env "$ENV_PATH" || { echo "❌ UV activation failed"; exit 1; }
fi
;;
pip)
echo "Using system Python with pip"
;;
esac
echo "Validating CLI"
echo "Python location: $(which python)"
echo "Python version: $(python --version)"
failed=false
# 1. Validate flagscale --version
echo "=========================================="
echo "Test: flagscale --version"
echo "=========================================="
if flagscale --version; then
echo "✅ flagscale --version passed"
else
echo "❌ flagscale --version failed"
failed=true
fi
# 2. Validate flagscale --help
echo "=========================================="
echo "Test: flagscale --help"
echo "=========================================="
if flagscale --help; then
echo "✅ flagscale --help passed"
else
echo "❌ flagscale --help failed"
failed=true
fi
# 3. Validate each subcommand --help
SUBCOMMANDS="train serve inference rl compress install test pull run"
for cmd in $SUBCOMMANDS; do
echo "=========================================="
echo "Test: flagscale $cmd --help"
echo "=========================================="
if flagscale $cmd --help; then
echo "✅ flagscale $cmd --help passed"
else
echo "❌ flagscale $cmd --help failed"
failed=true
fi
done
# 4. Run CLI unit tests
echo "=========================================="
echo "Test: CLI unit tests (pytest)"
echo "=========================================="
pip install pytest pytest-mock --root-user-action=ignore || { echo "❌ pytest install failed"; exit 1; }
if pytest tests/unit_tests/test_cli.py -v; then
echo "✅ CLI unit tests passed"
else
echo "❌ CLI unit tests failed"
failed=true
fi
# Final result
echo "=========================================="
if [ "$failed" = "true" ]; then
echo "❌ CLI validation failed"
exit 1
fi
echo "✅ All CLI validations passed!"
timeout-minutes: 10