Skip to content

Merge remote-tracking branch 'origin/main' into elastic #9

Merge remote-tracking branch 'origin/main' into elastic

Merge remote-tracking branch 'origin/main' into elastic #9

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

Check failure on line 118 in .github/workflows/unit-tests-elastic.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/unit-tests-elastic.yml

Invalid workflow file

You have an error in your yaml syntax on line 118
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 ==="