Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 59 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ env:

permissions:
contents: read
pages: write
id-token: write

jobs:
# ═════════════════════════════════════════════════════════════════════════
# 课题功能测试:所有14个模块的单元测试 + 集成测试
# ═════════════════════════════════════════════════════════════════════════
test:
runs-on: self-hosted
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
timeout-minutes: 20
steps:
- name: Checkout pull request on isolated runner
if: github.event_name == 'pull_request'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false

- name: Set up Python for pull request
if: github.event_name == 'pull_request'
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"

- name: Sync from local mirror (skip unstable GitHub checkout)
if: github.event_name != 'pull_request'
run: |
echo "=== CI Sync ==="
retry() {
Expand All @@ -46,12 +57,6 @@ jobs:
cd "$WORKSPACE"
echo "Fetching origin main..."
retry "git fetch origin main" git fetch origin main || exit 1
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
PR_NUMBER="${GITHUB_REF#refs/pull/}"
PR_NUMBER="${PR_NUMBER%/merge}"
echo "Fetching PR #${PR_NUMBER} merge ref..."
retry "git fetch PR #${PR_NUMBER}" git fetch origin "refs/pull/${PR_NUMBER}/merge" || exit 1
fi
echo "Checking out $GITHUB_SHA..."
if git -c advice.detachedHead=false checkout -f "$GITHUB_SHA"; then
echo "::notice::Checkout successful: $(git log -1 --format='%h %ai %s')"
Expand All @@ -64,6 +69,7 @@ jobs:
run: |
python3.12 -m pip install --upgrade pip
python3.12 -m pip install -e ".[all]"
python3.12 -m pip install "pytest>=7,<10"

- name: Run all topic tests
run: |
Expand All @@ -72,6 +78,14 @@ jobs:
--junit-xml=benchmark_reports/test_results.xml \
--ignore=tests/test_simulator.py

- name: Run constant-merge regressions
run: |
python3.12 -m pytest \
tests/test_const_merge.py \
tests/test_backend.py::TestConstMergeIntegration \
tests/test_simulator.py::TestStubProfiledMachine \
-v --tb=short

- name: Run PR #37 register-allocation regressions
run: python3.12 -m pytest tests/test_pr37_regression.py -v --tb=short

Expand All @@ -84,7 +98,7 @@ jobs:

- name: Upload test reports
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: test-reports
path: |
Expand All @@ -96,10 +110,23 @@ jobs:
# 模型性能测试:ONNX模型管线 + DSL用例 + CNN RISC-V编译
# ═════════════════════════════════════════════════════════════════════════
benchmark:
runs-on: self-hosted
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
timeout-minutes: 30
steps:
- name: Checkout pull request on isolated runner
if: github.event_name == 'pull_request'
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false

- name: Set up Python for pull request
if: github.event_name == 'pull_request'
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"

- name: Sync from local mirror (skip unstable GitHub checkout)
if: github.event_name != 'pull_request'
run: |
echo "=== CI Sync ==="
retry() {
Expand All @@ -123,12 +150,6 @@ jobs:
cd "$WORKSPACE"
echo "Fetching origin main..."
retry "git fetch origin main" git fetch origin main || exit 1
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
PR_NUMBER="${GITHUB_REF#refs/pull/}"
PR_NUMBER="${PR_NUMBER%/merge}"
echo "Fetching PR #${PR_NUMBER} merge ref..."
retry "git fetch PR #${PR_NUMBER}" git fetch origin "refs/pull/${PR_NUMBER}/merge" || exit 1
fi
echo "Checking out $GITHUB_SHA..."
if git -c advice.detachedHead=false checkout -f "$GITHUB_SHA"; then
echo "::notice::Checkout successful: $(git log -1 --format='%h %ai %s')"
Expand All @@ -141,12 +162,20 @@ jobs:
run: |
python3.12 -m pip install --upgrade pip
python3.12 -m pip install -e ".[all]"
python3.12 -m pip install markdown
python3.12 -m pip install markdown "pytest>=7,<10"

# ── 3.1 ONNX 模型管线基准测试 ──────────────────────────────────────
- name: ONNX model pipeline benchmarks
run: python3.12 -m pytest benchmarks/test_benchmark.py -v --tb=short

# ── 3.1.1 课题14:固定 case + 真实 TinyFive A/B 报告 ─────────────
- name: Topic 14 constant-merge case report
run: |
python3.12 benchmarks/run_const_merge_case.py \
benchmarks/cases/const_merge_feature.asm \
--json benchmark_reports/const_merge_report.json \
--markdown benchmark_reports/const_merge_report.md

# ── 3.2 DSL 用例编译 + 模拟基准 ────────────────────────────────────
- name: DSL case compilation benchmarks
run: |
Expand All @@ -166,7 +195,7 @@ jobs:
python3.12 scripts/gen_minimal_cnn.py 2>&1
fi
python3.12 scratchv/standalone/onnx_to_riscv_standalone.py \
"$MODEL" -o /tmp/cnn_riscv.bin --estimate --report
"$MODEL" -o /tmp/cnn_riscv.bin --estimate --report --const-merge

# ── 3.4 LLVM vs ScratchV + TinyFive + Dashboard ──────────────────
- name: LLVM vs ScratchV comparison
Expand All @@ -176,7 +205,8 @@ jobs:
if [ ! -f benchmark_reports/cnn_scratchv.s ] && [ -f models/graph/cnn.onnx ]; then
python3.12 scratchv/standalone/onnx_to_riscv_standalone.py \
models/graph/cnn.onnx -o /tmp/cnn_riscv.bin \
--asm benchmark_reports/cnn_scratchv.s --estimate 2>&1 | tail -3
--asm benchmark_reports/cnn_scratchv.s --estimate \
--const-merge 2>&1 | tail -3
fi
python3.12 scratchv/standalone/llvm_cache_compare.py \
--json-output benchmark_reports/llvm_vs_scratchv.json \
Expand Down Expand Up @@ -211,7 +241,8 @@ jobs:

# ── 上报 ──────────────────────────────────────────────────────────
- name: Upload benchmark reports
uses: actions/upload-artifact@v4
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: benchmark-reports
path: benchmark_reports/
Expand Down Expand Up @@ -256,12 +287,17 @@ jobs:
# ── 上传 Pages 产物 ──────────────────────────────────────────────
- name: Upload Pages artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with:
path: benchmark_reports/

- name: Write job summary
if: always()
run: |
if [ -f benchmark_reports/const_merge_report.md ]; then
cat benchmark_reports/const_merge_report.md >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f benchmark_reports/github_summary.md ]; then
cat benchmark_reports/github_summary.md >> $GITHUB_STEP_SUMMARY
fi
Expand All @@ -287,4 +323,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
Loading
Loading