@@ -327,12 +327,14 @@ jobs:
327327 fi
328328
329329 echo "Building STREAM with CC=$CC and CFLAGS=$CFLAGS"
330+ echo "Target: ${{ matrix.target }}"
330331
331332 # 编译 STREAM C 版本
332333 echo "=== Building STREAM C version ==="
333334
334335 # 对于某些特殊架构,可能需要特殊处理
335336 BUILD_SUCCESS=false
337+ BUILD_ERROR=""
336338
337339 # macOS 特殊编译选项
338340 if [[ "${{ runner.os }}" == "macOS" && "${{ matrix.use_openmp }}" == "true" ]]; then
@@ -352,14 +354,22 @@ jobs:
352354 {
353355 echo "Even basic compilation failed, trying minimal flags..."
354356 $CC -O2 -static stream.c -o stream_c${{ matrix.ext }} && BUILD_SUCCESS=true || \
355- $CC stream.c -o stream_c${{ matrix.ext }} && BUILD_SUCCESS=true
357+ $CC stream.c -o stream_c${{ matrix.ext }} && BUILD_SUCCESS=true || \
358+ {
359+ BUILD_ERROR="All compilation attempts failed for ${{ matrix.target }}"
360+ echo "ERROR: $BUILD_ERROR"
361+ }
356362 }
357363 }
358364 fi
359365
360366 if [[ "$BUILD_SUCCESS" != "true" ]]; then
361- echo "ERROR: Failed to build C version for ${{ matrix.target }}"
362- exit 1
367+ # 记录失败但不退出,让其他架构继续构建
368+ echo "FAILED: ${{ matrix.target }} - $BUILD_ERROR"
369+ echo "${{ matrix.target }}: FAILED - $BUILD_ERROR" > ../build-failure.log
370+ # 创建一个空的标记文件,表示此架构构建失败
371+ echo "Build failed: $BUILD_ERROR" > "../bin/FAILED-${{ matrix.target }}.txt"
372+ exit 0 # 不要因为单个架构失败而终止整个构建
363373 fi
364374
365375 # 尝试编译 Fortran 版本 (如果有 Fortran 编译器)
@@ -445,13 +455,15 @@ jobs:
445455 fi
446456 fi
447457
448- continue-on-error : true
458+ continue-on-error : false # 改为 false,让失败的构建显示为失败但不阻止其他构建
449459
450460 - name : Upload binary artifact
451461 uses : actions/upload-artifact@v4
452462 with :
453463 name : stream-${{ matrix.target }}
454- path : bin/stream-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && 'v' }}${{ matrix.goarm }}*
464+ path : |
465+ bin/stream-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && 'v' }}${{ matrix.goarm }}*
466+ bin/FAILED-${{ matrix.target }}.txt
455467 retention-days : 30
456468 continue-on-error : true
457469
@@ -464,6 +476,7 @@ jobs:
464476 uses : actions/checkout@v4
465477 with :
466478 token : ${{ secrets.GITHUB_TOKEN }}
479+ fetch-depth : 0 # 获取完整历史以便于提交
467480
468481 - name : Checkout STREAM source
469482 uses : actions/checkout@v4
@@ -484,6 +497,9 @@ jobs:
484497 # 从所有构建工件中复制文件到 bin 目录
485498 find artifacts/ -type f -name "stream-*" -exec cp {} bin/ \;
486499
500+ # 复制失败标记文件(如果有的话)
501+ find artifacts/ -type f -name "FAILED-*.txt" -exec cp {} bin/ \; 2>/dev/null || true
502+
487503 # 给所有二进制文件添加执行权限
488504 chmod +x bin/stream-* 2>/dev/null || true
489505
@@ -638,24 +654,76 @@ jobs:
638654 echo "" >> bin/ARCHITECTURES.md
639655
640656 for arch in amd64 386 arm64 arm riscv64 ppc64le ppc64 s390x mips mipsle mips64 mips64le; do
641- count=$(ls bin/stream-linux-${arch}* 2>/dev/null | wc -l)
657+ count=$(ls bin/stream-linux-${arch}* 2>/dev/null | grep -v "FAILED" | wc -l)
658+ failed_file="bin/FAILED-linux-${arch}.txt"
642659 if [ $count -gt 0 ]; then
643660 echo "✅ linux-${arch}: $count binaries" >> bin/ARCHITECTURES.md
644- ls bin/stream-linux-${arch}* 2>/dev/null | sed 's/^bin\// - /' >> bin/ARCHITECTURES.md
661+ ls bin/stream-linux-${arch}* 2>/dev/null | grep -v "FAILED" | sed 's/^bin\// - /' >> bin/ARCHITECTURES.md
662+ elif [ -f "$failed_file" ]; then
663+ echo "❌ linux-${arch}: build failed - $(cat "$failed_file")" >> bin/ARCHITECTURES.md
645664 else
646- echo "❌ linux-${arch}: build failed " >> bin/ARCHITECTURES.md
665+ echo "⚠️ linux-${arch}: no artifacts found ( build may have been skipped) " >> bin/ARCHITECTURES.md
647666 fi
648667 echo "" >> bin/ARCHITECTURES.md
649668 done
650669
651670 # 统计其他平台
652- darwin_count=$(ls bin/stream-darwin-* 2>/dev/null | wc -l)
653- windows_count=$(ls bin/stream-windows-* 2>/dev/null | wc -l)
671+ darwin_count=$(ls bin/stream-darwin-* 2>/dev/null | grep -v "FAILED" | wc -l)
672+ windows_count=$(ls bin/stream-windows-* 2>/dev/null | grep -v "FAILED" | wc -l)
654673
655674 echo "Other platforms:" >> bin/ARCHITECTURES.md
656675 echo "✅ macOS: $darwin_count binaries" >> bin/ARCHITECTURES.md
657676 echo "✅ Windows: $windows_count binaries" >> bin/ARCHITECTURES.md
658677 echo "" >> bin/ARCHITECTURES.md
659678
660- total_binaries=$(ls bin/stream-* 2>/dev/null | grep -v -E '\.(md|txt)' | wc -l)
679+ total_binaries=$(ls bin/stream-* 2>/dev/null | grep -v -E '\.(md|txt)' | grep -v "FAILED" | wc -l)
680+ failed_builds=$(ls bin/FAILED-*.txt 2>/dev/null | wc -l)
661681 echo "**Total: $total_binaries STREAM binaries built**" >> bin/ARCHITECTURES.md
682+ if [ $failed_builds -gt 0 ]; then
683+ echo "**Failed: $failed_builds build failures**" >> bin/ARCHITECTURES.md
684+ fi
685+
686+ - name : Configure Git for automated commits
687+ run : |
688+ git config --local user.email "action@github.com"
689+ git config --local user.name "GitHub Action"
690+
691+ - name : Commit and push binaries to repository
692+ run : |
693+ # 计算统计数据
694+ total_binaries=$(ls bin/stream-* 2>/dev/null | grep -v -E '\.(md|txt)' | grep -v "FAILED" | wc -l)
695+ linux_count=$(ls bin/stream-linux-* 2>/dev/null | grep -v "FAILED" | wc -l)
696+ darwin_count=$(ls bin/stream-darwin-* 2>/dev/null | grep -v "FAILED" | wc -l)
697+ windows_count=$(ls bin/stream-windows-* 2>/dev/null | grep -v "FAILED" | wc -l)
698+
699+ # 检查是否有变化
700+ if [[ $(git status --porcelain bin/) ]]; then
701+ echo "Changes detected in bin/ directory, committing..."
702+
703+ # 添加所有 bin/ 目录下的文件
704+ git add bin/
705+
706+ # 创建提交信息
707+ COMMIT_MSG="🚀 Auto-build: Update STREAM binaries from workflow run ${{ github.run_number }}
708+
709+ Built ${total_binaries} binaries across multiple architectures :
710+ - Linux : ${linux_count} binaries
711+ - macOS : ${darwin_count} binaries
712+ - Windows : ${windows_count} binaries
713+
714+ Workflow : ${{ github.workflow }}
715+ Run ID : ${{ github.run_id }}
716+ Commit : ${{ github.sha }}
717+ Actor : ${{ github.actor }}"
718+
719+ # 提交更改
720+ git commit -m "$COMMIT_MSG"
721+
722+ # 推送到 main 分支
723+ echo "Pushing binaries to main branch..."
724+ git push origin HEAD:main
725+
726+ echo "✅ Successfully committed and pushed ${total_binaries} binaries to repository"
727+ else
728+ echo "No changes detected in bin/ directory, skipping commit"
729+ fi
0 commit comments