-
Notifications
You must be signed in to change notification settings - Fork 162
155 lines (139 loc) · 5.22 KB
/
Copy pathunit-tests-elastic.yml
File metadata and controls
155 lines (139 loc) · 5.22 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
name: Elastic Module Tests
on:
push:
branches: [ main, develop ]
paths:
- 'flagscale/runner/elastic/**'
- 'tests/unit_tests/runner/elastic/**'
- '.github/workflows/unit-tests-elastic.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'flagscale/runner/elastic/**'
- 'tests/unit_tests/runner/elastic/**'
- '.github/workflows/unit-tests-elastic.yml'
jobs:
lint-and-test:
runs-on: [self-hosted, Linux, X64, nvidia-0, gpus-8]
container:
image: flagscale/flagscale:dev-megatron
ports:
- 80
volumes:
- /home/flagscale_cicd/flask/static:/workspace/report
- /home/flagscale_cicd/flask/config:/workspace/config
- /home/flagscale_cicd/docker/docker_build/docker_data:/home/gitlab-runner/data
- /home/flagscale_cicd/docker/docker_build/docker_tokenizers:/home/gitlab-runner/tokenizers
options: --gpus all --shm-size=500g --hostname flagscale_cicd --user root --ulimit nofile=65535:65535
steps:
- name: Checkout Code
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 }}
ssh-strict: true
ssh-user: git
persist-credentials: true
clean: true
sparse-checkout-cone-mode: true
fetch-tags: false
show-progress: true
lfs: false
submodules: false
set-safe-directory: true
- name: Setup Environment
run: |
echo "USER: $USER"
echo "UID: $(id -u)"
echo "GID: $(id -g)"
echo "Home: $HOME"
whoami
git config --global --add safe.directory /__w/FlagScale/FlagScale || true
- name: Install Dependencies
run: |
source /root/miniconda3/etc/profile.d/conda.sh
conda activate flagscale-train
pip install pylint pytest pytest-cov
python tools/patch/unpatch.py --backend Megatron-LM || true
export PYTHONPATH=./third_party/Megatron-LM:$PYTHONPATH
export NVTE_FLASH_ATTN=0
export NVTE_FUSED_ATTN=0
ulimit -n 65535
- name: Pylint Check - Elastic Module
run: |
source /root/miniconda3/etc/profile.d/conda.sh
conda activate flagscale-train
export PYTHONPATH=./third_party/Megatron-LM:$PYTHONPATH
echo "Running pylint on elastic module..."
pylint flagscale/runner/elastic/ --output-format=text --reports=yes --exit-zero > pylint_report.txt
# Display pylint results
cat pylint_report.txt
# Extract pylint score
PYLINT_SCORE=$(grep "Your code has been rated at" pylint_report.txt | sed 's/.*rated at \([0-9.]*\).*/\1/' || echo "0")
echo "Pylint Score: $PYLINT_SCORE"
# Fail if score is below 8.0
if (( $(echo "$PYLINT_SCORE < 8.0" | bc -l) )); then
echo "Pylint score $PYLINT_SCORE is below required threshold of 8.0"
exit 1
fi
- name: Run Elastic Unit Tests
run: |
source /root/miniconda3/etc/profile.d/conda.sh
conda activate flagscale-train
export PYTHONPATH=./third_party/Megatron-LM:$PYTHONPATH
export NVTE_FLASH_ATTN=0
export NVTE_FUSED_ATTN=0
ulimit -n 65535
echo "Running elastic module unit tests..."
pytest tests/unit_tests/runner/elastic/ \
--cov=flagscale/runner/elastic \
--cov-report=xml:coverage_elastic.xml \
--cov-report=html:coverage_elastic_html \
--cov-report=term \
-v \
--tb=short \
-x
- name: Coverage Report
run: |
source /root/miniconda3/etc/profile.d/conda.sh
conda activate flagscale-train
echo "Coverage Summary for Elastic Module:"
if [ -f coverage_elastic.xml ]; then
echo "Coverage XML report generated successfully"
python -c "
import xml.etree.ElementTree as ET
try:
tree = ET.parse('coverage_elastic.xml')
root = tree.getroot()
coverage = root.attrib.get('line-rate', '0')
percentage = float(coverage) * 100
print(f'Line Coverage: {percentage:.1f}%')
if percentage < 80:
print(f'Warning: Coverage {percentage:.1f}% is below recommended 80%')
exit(1)
except Exception as e:
print(f'Error parsing coverage: {e}')
exit(1)
"
else
echo "Coverage XML report not found"
exit 1
fi
- name: Archive Test Results
uses: actions/upload-artifact@v3
if: always()
with:
name: elastic-test-results
path: |
pylint_report.txt
coverage_elastic.xml
coverage_elastic_html/
retention-days: 30
- name: Summary
if: always()
run: |
echo "=== Elastic Module CI/CD Summary ==="
echo "[INFO] Pylint check completed"
echo "[INFO] Unit tests executed"
echo "[INFO] Coverage report generated"
echo "=== Test artifacts uploaded to GitHub Actions ==="