-
-
Notifications
You must be signed in to change notification settings - Fork 986
150 lines (127 loc) · 4.57 KB
/
Copy pathtest-main-features.yml
File metadata and controls
150 lines (127 loc) · 4.57 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
name: Test Main Features
on:
push:
paths:
- 'tests/test_main_features.py'
- 'swarms/**'
- 'requirements.txt'
- 'pyproject.toml'
branches: [ "master" ]
pull_request:
paths:
- 'tests/test_main_features.py'
- 'swarms/**'
- 'requirements.txt'
- 'pyproject.toml'
branches: [ "master" ]
workflow_dispatch: # Allow manual triggering
jobs:
test-main-features:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Cache pip dependencies
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Install dependencies
run: |
poetry install --with test --no-dev
- name: Set up environment variables
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> $GITHUB_ENV
echo "ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}" >> $GITHUB_ENV
echo "GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }}" >> $GITHUB_ENV
echo "COHERE_API_KEY=${{ secrets.COHERE_API_KEY }}" >> $GITHUB_ENV
echo "HUGGINGFACE_API_KEY=${{ secrets.HUGGINGFACE_API_KEY }}" >> $GITHUB_ENV
echo "REPLICATE_API_KEY=${{ secrets.REPLICATE_API_KEY }}" >> $GITHUB_ENV
echo "TOGETHER_API_KEY=${{ secrets.TOGETHER_API_KEY }}" >> $GITHUB_ENV
- name: Run Main Features Tests
run: |
cd /Users/swarms_wd/Desktop/research/swarms
poetry run python tests/test_main_features.py
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results
path: test_runs/
retention-days: 7
- name: Comment on PR with test results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const path = require('path');
try {
// Look for test result files
const testRunsDir = 'test_runs';
if (fs.existsSync(testRunsDir)) {
const files = fs.readdirSync(testRunsDir);
const latestReport = files
.filter(f => f.endsWith('.md'))
.sort()
.pop();
if (latestReport) {
const reportPath = path.join(testRunsDir, latestReport);
const reportContent = fs.readFileSync(reportPath, 'utf8');
// Extract summary from markdown
const summaryMatch = reportContent.match(/## Summary\n\n(.*?)\n\n## Detailed Results/s);
const summary = summaryMatch ? summaryMatch[1] : 'Test results available in artifacts';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Main Features Test Results\n\n${summary}\n\n📊 Full test report available in artifacts.`
});
}
}
} catch (error) {
console.log('Could not read test results:', error.message);
}
test-coverage:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: test-main-features
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
poetry install --with test
- name: Run coverage analysis
run: |
poetry run pytest tests/test_main_features.py --cov=swarms --cov-report=xml --cov-report=html
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: main-features
name: main-features-coverage
fail_ci_if_error: false