Skip to content
Open
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
40 changes: 23 additions & 17 deletions .github/workflows/manual_bsp_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ name: manual_trigger_scons_build_all
# toolchain主要用来选择默认安装的toolchain

on:
# Runs at 16:00 UTC (BeiJing 00:00) on the 1st of every month
# Runs at 16:00 UTC on the 1st (00:00 Beijing time on the 2nd).
schedule:
- cron: '0 16 1 * *'

Expand Down Expand Up @@ -52,7 +52,10 @@ permissions:
jobs:
build:
runs-on: ubuntu-22.04
name: ${{ github.event.inputs.bsp_options }}
name: ${{ inputs.bsp_options || 'all' }}
env:
RTT_BSP: ${{ inputs.bsp_options || 'all' }}
RTT_TOOL_CHAIN: ${{ inputs.bsp_tool_chain || 'sourcery-arm' }}
steps:
- uses: actions/checkout@main
- name: Set up Python
Expand All @@ -72,7 +75,7 @@ jobs:
echo "RTT_CC=gcc" >> $GITHUB_ENV

- name: Install Arm ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-arm' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'sourcery-arm' && success() }}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.3/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
Expand All @@ -81,7 +84,7 @@ jobs:
echo "RTT_EXEC_PATH=/opt/gcc-arm-none-eabi-10-2020-q4-major/bin" >> $GITHUB_ENV

- name: Install LLVM-Arm ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'llvm-arm' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'llvm-arm' && success() }}
shell: bash
run: |
wget -q https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-16.0.0/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz
Expand All @@ -92,7 +95,7 @@ jobs:
echo "RTT_EXEC_PATH=/opt/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin" >> $GITHUB_ENV

- name: Install AArch64 ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-aarch64' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'sourcery-aarch64' && success() }}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.6/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz
Expand All @@ -101,7 +104,7 @@ jobs:
echo "RTT_EXEC_PATH=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin" >> $GITHUB_ENV

- name: Install Mips ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-mips' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'sourcery-mips' && success() }}
shell: bash
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.1/mips-2016.05-7-mips-sde-elf-i686-pc-linux-gnu.tar.bz2
Expand All @@ -110,23 +113,23 @@ jobs:
echo "RTT_EXEC_PATH=/opt/mips-2016.05/bin" >> $GITHUB_ENV

- name: Install Riscv64-unknown-elf ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-riscv64-unknown-elf' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'sourcery-riscv64-unknown-elf' && success() }}
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.4/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
sudo tar zxf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz -C /opt
/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV

- name: Install Riscv-none-embed ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-riscv-none-embed' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'sourcery-riscv-none-embed' && success() }}
run: |
wget -q https://github.com/RT-Thread/toolchains-ci/releases/download/v1.5/xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz
sudo tar zxf xpack-riscv-none-embed-gcc-8.3.0-2.3-linux-x64.tar.gz -C /opt
/opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin/riscv-none-embed-gcc --version
echo "RTT_EXEC_PATH=/opt/xpack-riscv-none-embed-gcc-8.3.0-2.3/bin" >> $GITHUB_ENV

- name: Install riscv32-esp-elf ToolChains
if: ${{ github.event.inputs.bsp_tool_chain == 'sourcery-riscv32-esp32' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'sourcery-riscv32-esp32' && success() }}
run: |
wget -q https://github.com/espressif/crosstool-NG/releases/download/esp-15.2.0_20251204/riscv32-esp-elf-15.2.0_20251204-x86_64-linux-gnu.tar.xz
sudo tar xf riscv32-esp-elf-15.2.0_20251204-x86_64-linux-gnu.tar.xz -C /opt
Expand All @@ -135,21 +138,24 @@ jobs:
echo "RTT_EXEC_PATH=/opt/riscv32-esp-elf/bin" >> $GITHUB_ENV

- name: Install GCC Tools
if: ${{ github.event.inputs.bsp_tool_chain == 'gcc' && success() }}
if: ${{ env.RTT_TOOL_CHAIN == 'gcc' && success() }}
run: |
sudo apt-get -qq install libsdl2-dev

- name: Bsp Scons Compile
if: ${{ success() }}
shell: bash
env:
RTT_BSP: ${{ github.event.inputs.bsp_options }}
RTT_TOOL_CHAIN: ${{ github.event.inputs.bsp_tool_chain}}
run: |
source ~/.env/env.sh
python tools/ci/manual_bsp_build_all.py $RTT_BSP

- uses: actions/upload-artifact@v3
python tools/ci/manual_bsp_build_all.py "$RTT_BSP"
if [ -s failed_bsp_list.txt ]; then
echo "::error::Some BSP builds failed; see failed_bsp.log"
exit 1
fi

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: dist_file
path: ${{ github.workspace }}/failed_bsp.log
path: ${{ github.workspace }}/failed_bsp.log
if-no-files-found: ignore
27 changes: 20 additions & 7 deletions .github/workflows/scheduled-ci-trigger.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Weekly CI Scheduler
name: Daily CI Scheduler

on:
# Runs at 08:00 Beijing time every day
Expand All @@ -18,7 +18,12 @@ env:
jobs:
trigger-and-monitor:
name: Trigger and Monitor CIs
if: github.repository_owner == 'RT-Thread'
runs-on: ubuntu-latest
timeout-minutes: 270
permissions:
contents: read
actions: write
outputs:
failed_workflows: ${{ steps.collect-results.outputs.failed_workflows }}
total_workflows: ${{ steps.collect-results.outputs.total_workflows }}
Expand Down Expand Up @@ -49,6 +54,7 @@ jobs:

- name: Wait for workflows to appear
id: wait-for-workflows
if: ${{ !cancelled() && steps.start-time.outcome == 'success' }}
run: |
echo "Waiting for workflows to appear in API..."
python tools/ci/scheduled-ci-trigger/wait_for_workflows.py "${{ steps.start-time.outputs.start_time }}"
Expand All @@ -58,6 +64,7 @@ jobs:

- name: Monitor CI workflows
id: monitor-ci
if: ${{ !cancelled() && steps.start-time.outcome == 'success' }}
run: |
python tools/ci/scheduled-ci-trigger/monitor_workflows.py "${{ steps.start-time.outputs.start_time }}"
env:
Expand All @@ -66,11 +73,12 @@ jobs:

- name: Collect monitoring results
id: collect-results
if: ${{ !cancelled() && steps.start-time.outcome == 'success' }}
run: |
echo "Checking for monitoring results..."
if [ -f "monitoring_results.json" ]; then
echo "monitoring_results.json found"
FAILED_COUNT=$(python -c "import json; data=json.load(open('monitoring_results.json')); print(len([w for w in data if w.get('conclusion') == 'failure']))")
FAILED_COUNT=$(python -c "import json; data=json.load(open('monitoring_results.json')); print(len([w for w in data if w.get('conclusion') != 'success']))")
TOTAL_COUNT=$(python -c "import json; data=json.load(open('monitoring_results.json')); print(len(data))")
echo "failed_workflows=$FAILED_COUNT" >> $GITHUB_OUTPUT
echo "total_workflows=$TOTAL_COUNT" >> $GITHUB_OUTPUT
Expand All @@ -81,18 +89,19 @@ jobs:
echo "failed_workflows=0" >> $GITHUB_OUTPUT
echo "total_workflows=0" >> $GITHUB_OUTPUT
echo "has_results=false" >> $GITHUB_OUTPUT
exit 1
fi

- name: Generate detailed report
if: steps.collect-results.outputs.has_results == 'true' && steps.collect-results.outputs.failed_workflows != '0'
if: ${{ !cancelled() && steps.collect-results.outputs.has_results == 'true' && steps.collect-results.outputs.failed_workflows != '0' }}
id: generate-report
run: |
echo "Generating detailed report..."
python tools/ci/scheduled-ci-trigger/generate_report.py
echo "Report generation completed"

- name: Upload report artifact
if: steps.collect-results.outputs.has_results == 'true' && steps.collect-results.outputs.failed_workflows != '0'
if: ${{ !cancelled() && steps.collect-results.outputs.has_results == 'true' && steps.collect-results.outputs.failed_workflows != '0' }}
uses: actions/upload-artifact@v4
with:
name: ci-failure-report
Expand All @@ -104,8 +113,12 @@ jobs:
create-discussion:
name: Create Discussion Report
needs: trigger-and-monitor
if: needs.trigger-and-monitor.outputs.has_results == 'true' && needs.trigger-and-monitor.outputs.failed_workflows != '0'
if: ${{ !cancelled() && needs.trigger-and-monitor.outputs.has_results == 'true' && needs.trigger-and-monitor.outputs.failed_workflows != '0' }}
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
discussions: write

steps:
- name: Checkout repository
Expand All @@ -117,7 +130,7 @@ jobs:
name: ci-failure-report

- name: Create Discussion
uses: actions/github-script@v6
uses: actions/github-script@v8
env:
DISCUSSION_CATEGORY: ${{ env.DISCUSSION_CATEGORY }}
with:
Expand Down Expand Up @@ -197,4 +210,4 @@ jobs:
body: reportContent // 使用清理后的内容(无第一行)
});

console.log('Discussion created successfully:', result.createDiscussion.discussion.url);
console.log('Discussion created successfully:', result.createDiscussion.discussion.url);
23 changes: 13 additions & 10 deletions tools/ci/scheduled-ci-trigger/generate_report.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import json
import os
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from typing import List, Dict, Any

def load_monitoring_results() -> List[Dict[str, Any]]:
Expand All @@ -17,7 +17,7 @@ def load_monitoring_results() -> List[Dict[str, Any]]:
return []

def get_beijing_time() -> datetime:
return datetime.utcnow() + timedelta(hours=8)
return datetime.now(timezone(timedelta(hours=8)))

def format_time(dt: datetime) -> str:
return dt.strftime("%Y-%m-%d %H:%M")
Expand Down Expand Up @@ -45,7 +45,7 @@ def generate_report():
if not results:
return

failed_workflows = [r for r in results if r.get('conclusion') == 'failure']
failed_workflows = [r for r in results if r.get('conclusion') != 'success']
if not failed_workflows:
print("No failed workflows to report")
return
Expand All @@ -55,15 +55,15 @@ def generate_report():

# 时间范围
created_times = [
datetime.fromisoformat(r["created_at"].replace("Z", "+00:00")) + timedelta(hours=8)
for r in failed_workflows
datetime.fromisoformat(r["created_at"].replace("Z", "+00:00")).astimezone(now.tzinfo)
for r in failed_workflows if r.get("created_at")
]
updated_times = [
datetime.fromisoformat(r["updated_at"].replace("Z", "+00:00")) + timedelta(hours=8)
for r in failed_workflows
datetime.fromisoformat(r["updated_at"].replace("Z", "+00:00")).astimezone(now.tzinfo)
for r in failed_workflows if r.get("updated_at")
]
start_time = min(created_times)
end_time = max(updated_times)
start_time = min(created_times, default=now)
end_time = max(updated_times, default=now)

total = len(results)
failed_count = len(failed_workflows)
Expand Down Expand Up @@ -91,6 +91,9 @@ def generate_report():
details = wf.get("failure_details", [])

report += f"**📌 Run-{run_id}** | [{name}]({html_url})\n"
report += f"**运行结果 | Conclusion**: `{wf.get('conclusion', 'unknown')}`\n"
if wf.get("error"):
report += f"**错误信息 | Error**: {wf['error']}\n"

if not details:
report += "└─ 无失败作业详情 | No details of failed jobs\n\n"
Expand Down Expand Up @@ -132,4 +135,4 @@ def generate_report():
print(f"Error writing report: {e}")

if __name__ == "__main__":
generate_report()
generate_report()
Loading
Loading