Skip to content

Commit d56a2a1

Browse files
authored
Merge pull request #2 from Yauanyyy/ZZ_workflowtest
Add GitHub Actions workflow for simulation and plotting
2 parents 7cb0c00 + 7d4a1b6 commit d56a2a1

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Simulation and Plotting
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch: # 允许手动点击触发
7+
8+
jobs:
9+
run-sim:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# 1. 拉取代码
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
# 2. 编译两个 C 语言文件
18+
- name: Compile C code
19+
run: |
20+
gcc Viterbi_Hard_K3_75.c -o viterbi_hard -lm
21+
gcc Viterbi_Soft_K3_75.c -o viterbi_soft -lm
22+
# 注意:-lm 用于链接 math 库 (math.h)
23+
24+
# 3. 运行 C 程序 (重点:自动输入参数)
25+
# 你的程序通过 scanf 等待输入: start, finish, seq_num
26+
# 这里我们用 echo 把 "0 10 10000" 喂给程序 (0dB到10dB, 10000帧)
27+
- name: Run Hard Decision Simulation
28+
run: echo "0 12 100000" | ./viterbi_hard
29+
30+
- name: Run Soft Decision Simulation
31+
run: echo "0 12 100000" | ./viterbi_soft
32+
33+
# 4. 整理文件 (关键步骤)
34+
# Python 脚本去 zoutput 文件夹找 csv,所以我们手动创建并移动过去
35+
- name: Organize CSV files
36+
run: |
37+
mkdir -p zoutput
38+
mv hard_viterbi.csv zoutput/
39+
mv soft_viterbi.csv zoutput/
40+
41+
# 5. 配置 Python 环境
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: '3.9'
46+
47+
# 6. 安装 Python 绘图依赖
48+
- name: Install dependencies
49+
run: |
50+
pip install matplotlib pandas scipy
51+
52+
# 7. 运行 Python 绘图
53+
- name: Generate Plots
54+
run: python plot_new.py
55+
56+
# 8. 打包下载结果
57+
# 这里我们把生成的图片 (pictures/) 和 CSV 数据 (zoutput/) 都打包
58+
- name: Upload Results
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: simulation-results
62+
path: |
63+
pictures/*.png
64+
zoutput/*.csv
65+
retention-days: 5

0 commit comments

Comments
 (0)