Skip to content

feat: multi-arch builds, env refactoring, new features, and expanded tests #480

feat: multi-arch builds, env refactoring, new features, and expanded tests

feat: multi-arch builds, env refactoring, new features, and expanded tests #480

Workflow file for this run

name: MagiAttention Build and Test
on:
push:
branches: [main]
pull_request_target:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
detect_changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
contents: read
outputs:
MagiAttention: ${{ steps.filter.outputs.MagiAttention }}
steps:
- name: Print Event Context
run: |
echo "Event Name: ${{ github.event_name }}"
echo "Action: ${{ github.action }}"
echo "Actor: ${{ github.actor }}"
echo "Ref: ${{ github.ref }}"
if [[ "${{ github.event_name }}" == "pull_request" || "${{ github.event_name }}" == "pull_request_target" ]]; then
echo "PR Title: ${{ github.event.pull_request.title }}"
echo "PR Number: ${{ github.event.number }}"
echo "PR Head SHA: ${{ github.event.pull_request.head.sha }}"
fi
# ==========================================================
# Check if PR title starts with some specific prefixes
# and fail the job if it does.
# ==========================================================
- name: Fail if PR title is [WIP] or [DO NOT MERGE]
# Ensure this check only runs for 'pull_request' events
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
run: |
# Get the PR title
PR_TITLE="${{ github.event.pull_request.title }}"
# Check if the title starts with "[WIP]" OR "[DO NOT MERGE]" (case-sensitive)
if [[ "$PR_TITLE" == "[WIP]"* ]] || [[ "$PR_TITLE" == "[DO NOT MERGE]"* ]]; then
# Use ::error:: to provide clear feedback
echo "::error::Pull Request title starts with [WIP] or [DO NOT MERGE]. Please remove the tag to run the workflow."
exit 1 # Fail the job immediately
else
echo "PR title is clean: $PR_TITLE"
fi
# ==========================================================
# End of check
# ==========================================================
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.event.pull_request.head.sha || github.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.event.pull_request.base.ref || github.base_ref }}
filters: |
MagiAttention:
- 'magi_attention/**'
- name: print filter results
run: |
echo "is MagiAttention modified: ${{ steps.filter.outputs.MagiAttention }}"
test_MagiAttention_ngc2510_cuda13:
needs: [detect_changes]
if: |
always() &&
(
needs.detect_changes.outputs.MagiAttention == 'true'
)
environment: ${{ (github.event_name == 'pull_request_target') && 'ci-internal' || '' }}
runs-on: [self-hosted]
container:
image: registry.cn-sh-01.sensecore.cn/sandai-ccr/magi-base:25.10.5
options: --gpus all --ipc host
credentials:
username: ${{ secrets.DOCKER_USER_NAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
env:
http_proxy: ${{ secrets.HTTP_PROXY }}
https_proxy: ${{ secrets.HTTP_PROXY }}
no_proxy: pypi.tuna.tsinghua.edu.cn
GITHUB_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
volumes:
- /mnt/afs/littsk/ci_workspace_magi_attention/:/workspace
steps:
- name: echo proxy
run: |
echo "http_proxy: $http_proxy"
echo "https_proxy: $https_proxy"
echo "no_proxy: $no_proxy"
echo "secret.HTTP_PROXY: ${{ secrets.HTTP_PROXY }}"
echo "secret.HTTPS_PROXY: ${{ secrets.HTTP_PROXY }}"
- name: curl google
run: |
curl www.google.com
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.event.pull_request.head.sha || github.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
fetch-depth: 0
- name: manually merge latest main
if: github.event_name == 'pull_request_target'
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
git config user.name "github-actions"
git config user.email "github-actions@github.com"
echo "Fetching latest main from base repository..."
git fetch https://github.com/${{ github.repository }}.git ${{ github.event.pull_request.base.ref }}
echo "Merging latest ${{ github.event.pull_request.base.ref }} into PR branch..."
git merge FETCH_HEAD
- name: install requirements
run: |
bash -x .github/scripts/install_requirements.sh
- name: clear MagiAttention cache
run: |
rm -rf /github/home/.cache/magi_attention/
- name: install MagiAttention
run: |
pip install -e . --no-build-isolation -vvv
- name: verify MagiAttention import
run: |
cd /github/home
python -c "import magi_attention; print('Pip Installation and Import Success')"
# ONLY clean the dist folder to ensure we install the correct newly-built wheel.
# We KEEP the 'build/' directory to reuse the compilation cache from the previous 'pip install -e' step.
- name: build MagiAttention wheel
run: |
rm -rf dist/
python -m build --wheel --no-isolation -v
- name: install MagiAttention wheel
run: |
pip uninstall -y magi_attention
pip install dist/*.whl
- name: verify MagiAttention wheel
run: |
cd /github/home
python -c "import magi_attention; print('Wheel Installation and Import Success')"
- name: Test and Generate coverage report
run: |
MAGI_ATTENTION_TEST_BACKEND="*SDPA,*FFA" coverage run --source magi_attention -m pytest --skip-slow --import-mode=append -qsv ./tests
coverage combine
coverage xml -i
env:
COVERAGE_RUN: True
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: SandAI-org/MagiAttention
files: coverage.xml