-
Notifications
You must be signed in to change notification settings - Fork 10
154 lines (131 loc) · 5.39 KB
/
cli-test.yml
File metadata and controls
154 lines (131 loc) · 5.39 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
name: CLI Integration Tests
on:
push:
branches: [main]
paths:
- 'src.ts/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/cli-test.yml'
pull_request:
branches: [main]
paths:
- 'src.ts/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/cli-test.yml'
workflow_dispatch:
jobs:
user-scenario-test:
name: User Test (Node ${{ matrix.node-version }} / ${{ matrix.pkg-manager }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
pkg-manager: [npm, yarn, pnpm]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm (for building)
uses: pnpm/action-setup@v2
with:
version: 9.15.4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Build and pack project
run: |
pnpm install --frozen-lockfile
pnpm build
pnpm pack
- name: Run CLI integration tests
run: pnpm test:cli
timeout-minutes: 10
- name: Setup test environment
run: |
mkdir -p /tmp/user-test
cd /tmp/user-test
cp $GITHUB_WORKSPACE/*.tgz ./package.tgz
- name: Setup package manager
run: |
if [ "${{ matrix.pkg-manager }}" = "yarn" ]; then
corepack enable
corepack prepare yarn@stable --activate
elif [ "${{ matrix.pkg-manager }}" = "pnpm" ]; then
npm install -g pnpm@9.15.4
fi
- name: Test package installation and CLI
working-directory: /tmp/user-test
run: |
# Initialize test project
npm init -y
# Install our package with peer dependencies
case "${{ matrix.pkg-manager }}" in
npm)
npm install ./package.tgz @types/crypto-js@4.2.2 crypto-js@4.2.0 ethers@6.13.1
;;
yarn)
yarn add ./package.tgz @types/crypto-js@4.2.2 crypto-js@4.2.0 ethers@6.13.1
;;
pnpm)
pnpm add ./package.tgz @types/crypto-js@4.2.2 crypto-js@4.2.0 ethers@6.13.1
;;
esac
# Test CLI commands using local binary
if [ -f "./node_modules/.bin/0g-compute-cli" ]; then
# npm/yarn classic with node_modules/.bin
echo "Testing basic CLI commands..."
./node_modules/.bin/0g-compute-cli --version
./node_modules/.bin/0g-compute-cli --help
./node_modules/.bin/0g-compute-cli inference --help
./node_modules/.bin/0g-compute-cli show-network || echo "Network command tested"
echo "Testing authentication-free commands..."
echo "→ Testing inference list-providers (no auth required)"
./node_modules/.bin/0g-compute-cli inference list-providers --rpc https://evmrpc-testnet.0g.ai
echo "→ Testing inference list-providers-detail (no auth required)"
./node_modules/.bin/0g-compute-cli inference list-providers-detail --rpc https://evmrpc-testnet.0g.ai
echo "→ Testing fine-tuning list-providers (no auth required)"
./node_modules/.bin/0g-compute-cli fine-tuning list-providers --rpc https://evmrpc-testnet.0g.ai
echo "→ Testing fine-tuning list-models (no auth required)"
./node_modules/.bin/0g-compute-cli fine-tuning list-models --rpc https://evmrpc-testnet.0g.ai
elif [ "${{ matrix.pkg-manager }}" = "yarn" ]; then
# yarn 4+ with PnP mode
echo "Testing basic CLI commands..."
yarn run 0g-compute-cli --version
yarn run 0g-compute-cli --help
yarn run 0g-compute-cli inference --help
yarn run 0g-compute-cli show-network || echo "Network command tested"
echo "Testing authentication-free commands..."
echo "→ Testing inference list-providers (no auth required)"
yarn run 0g-compute-cli inference list-providers --rpc https://evmrpc-testnet.0g.ai
echo "→ Testing inference list-providers-detail (no auth required)"
yarn run 0g-compute-cli inference list-providers-detail --rpc https://evmrpc-testnet.0g.ai
echo "→ Testing fine-tuning list-providers (no auth required)"
yarn run 0g-compute-cli fine-tuning list-providers --rpc https://evmrpc-testnet.0g.ai
echo "→ Testing fine-tuning list-models (no auth required)"
yarn run 0g-compute-cli fine-tuning list-models --rpc https://evmrpc-testnet.0g.ai
else
echo "CLI binary not found"
exit 1
fi
env:
ZG_RPC_ENDPOINT: https://evmrpc-testnet.0g.ai
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [user-scenario-test]
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.user-scenario-test.result }}" == "success" ]; then
echo "✅ All CLI user scenario tests passed!"
echo "- User installation scenarios: ✅"
else
echo "❌ User scenario tests failed:"
echo "- User scenarios: ${{ needs.user-scenario-test.result }}"
exit 1
fi