Skip to content

Commit bf3a5f1

Browse files
fix: add scarb installation request before tests in snak-test, remove debug steps in ci
1 parent 6fcfae7 commit bf3a5f1

File tree

2 files changed

+45
-31
lines changed

2 files changed

+45
-31
lines changed

.github/workflows/backend.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
3737
3838
- name: Setup pnpm cache
39-
if: false
4039
uses: actions/cache@v4
4140
with:
4241
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
@@ -50,24 +49,9 @@ jobs:
5049
- name: Install turbo
5150
run: pnpm add turbo@latest -g
5251

53-
- name: Clean previous builds
54-
run: |
55-
rm -rf packages/*/dist
56-
rm -rf packages/*/node_modules/.cache
57-
5852
- name: Build
5953
run: turbo build
6054

61-
- name: Check files after build
62-
run: |
63-
find packages/backend/dist -type f | grep -i openai
64-
ls -la packages/backend/dist/config/provider || echo "Directory does not exist"
65-
66-
- name: Debug module resolution
67-
run: |
68-
cd packages/ingester
69-
NODE_PATH=../.. node -e "try { const path = require.resolve('@cairo-coder/backend/config/provider/openai'); console.log('Module found at:', path); } catch(e) { console.log('Module not found:', e.message); console.log('Available modules:', require('fs').readdirSync('../backend/dist/config').join(', ')); }"
70-
7155
- name: Create config file
7256
run: |
7357
mkdir -p packages/agents
@@ -182,6 +166,7 @@ jobs:
182166
CAIRO_GENERATION_API_URL="http://127.0.0.1:3001/chat/completions"
183167
184168
EOL
169+
185170
- name: Cache snak node modules
186171
uses: actions/cache@v4
187172
with:
@@ -222,18 +207,6 @@ jobs:
222207
echo "Server failed to start after $max_retries retries"
223208
exit 1
224209
fi
225-
226-
- name: Test basic API connectivity
227-
run: |
228-
echo "Testing basic API connectivity..."
229-
response=$(curl -s -H "Content-Type: application/json" -H "x-api-key: ${{ secrets.SNAK_SERVER_KEY }}" -X POST -d '{"request": "Hello World"}' http://localhost:${{ secrets.SNAK_SERVER_PORT }}/api/key/request)
230-
echo "Response: $response"
231-
if echo "$response" | grep -q "Hello"; then
232-
echo "✅ Basic API test passed!"
233-
else
234-
echo "❌ Basic API test failed!"
235-
exit 1
236-
fi
237210
238211
- name: Create cairo code generation test env file
239212
run: |

packages/agents/__tests__/code-quality/snak.test.ts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,49 @@ if (!process.env.API_URL) {
1111
const API_KEY = process.env.API_KEY;
1212
const API_URL = process.env.API_URL;
1313

14+
// Agent est défini au niveau global pour être utilisé dans beforeAll et dans les tests
15+
const agent = request(API_URL);
16+
17+
// Le beforeAll est placé au niveau global, en dehors du describe
18+
beforeAll(async () => {
19+
console.log('Setting up test environment - Installing Scarb...');
20+
21+
try {
22+
const installResponse = await agent
23+
.post('/api/key/request')
24+
.set('Content-Type', 'application/json')
25+
.set('x-api-key', API_KEY)
26+
.send({
27+
request: "Can you install scarb?",
28+
});
29+
30+
console.log('Scarb Installation Status:', installResponse.status);
31+
console.log('Scarb Installation Response:',
32+
installResponse.body.output ?
33+
JSON.stringify(installResponse.body.output[0], null, 2) :
34+
'No output'
35+
);
36+
37+
const isSuccess = installResponse.status === 201 &&
38+
installResponse.body.output &&
39+
installResponse.body.output[0].status === 'success';
40+
41+
if (!isSuccess) {
42+
console.error('⚠️ Warning: Scarb installation failed. : ', installResponse.body.output[0].text);
43+
} else {
44+
console.log('✅ Scarb installation successful');
45+
}
46+
47+
// Attendre que l'installation soit traitée
48+
await new Promise((resolve) => setTimeout(resolve, 5000));
49+
50+
} catch (error) {
51+
console.error('❌ Error during Scarb installation:', error);
52+
console.warn('⚠️ Tests may fail if Scarb is not properly installed');
53+
}
54+
}, 60000); // Timeout de 60 secondes pour l'installation
55+
1456
describe('Code Generation and Compilation Tests', () => {
15-
const agent = request(API_URL);
1657

1758
async function generateAndCompile(
1859
project_name: string,
@@ -132,10 +173,10 @@ describe('Code Generation and Compilation Tests', () => {
132173
}
133174

134175
describe('Cairo Functions and Basic Algorithms', () => {
135-
176+
136177
test('Hello World test', async () => {
137178
const project_name = 'hello_world';
138-
const prompt_content = 'a simple Hello World function in Cairo';
179+
const prompt_content = 'a cairo function that returns "Hello World"';
139180
const result = await generateAndCompile(project_name, prompt_content, 0);
140181

141182
if (!result.success) {

0 commit comments

Comments
 (0)