# 用一个 GitHub Actions 步骤校验 CSV

项目中准备一份 UTF-8 CSV 和一份 Table Schema。将下列工作流保存为 `.github/workflows/check-csv.yml`，把 `csv` 和 `schema` 改为检出目录内的相对路径。文件有自己的 CSV 方言时可另传 `dialect: path/to/dialect.json`。

```yaml
name: Check exported CSV
on: [push, pull_request]
permissions:
  contents: read
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
      - uses: Kleinrat/MoonFriction@v0.30.0
        with:
          csv: data/cycles.csv
          schema: rules/cycles.schema.json
```

Action 使用 GitHub runner 的 Node.js 24 和随版本提交的 MoonBit 编译产物。消费方检出代码后即可运行。成功显示数据行数；遇到错误时该步骤失败，GitHub 注解指出文件和 CSV 物理行。未提供路径、文件读取失败或规则无法编译时也会结束并说明原因。[Action 定义](../action.yml) · [示例规则](../examples/row-rules/cycles.schema.json)

## 同一份检查的三次运行

验证使用项目作者的 MoonRainflow fork 和专用分支。七行样本来自上游公开的计算结果。只在接收方副本中改变第 4 行的终点，恢复时也只改这个值。原仓 PR 的采纳状态可单独查看。[接收方工作流与提交](https://github.com/Kleinrat/MoonRainflow/tree/verification/row-rules-action) · [运行列表](https://github.com/Kleinrat/MoonRainflow/actions/workflows/cycle-csv-contract.yml?query=branch%3Averification%2Frow-rules-action) · [上游 PR](https://github.com/Mr-Shi123/MoonRainflow/pull/1)

三次公开运行使用相同的规则和同一份 Action（提交 `26e23cb`）。

| 接收方 CSV 第 4 行的起点、终点 | GitHub 检查 |
|---|---|
| 原始 `4,5` | [通过，7 条记录](https://github.com/Kleinrat/MoonRainflow/actions/runs/46702273638) |
| 改为 `4,4` | [失败，第 4 行两个值均为 4](https://github.com/Kleinrat/MoonRainflow/actions/runs/46702321079/job/142838925811) |
| 恢复 `4,5` | [再次通过，7 条记录](https://github.com/Kleinrat/MoonRainflow/actions/runs/46702365553) |

[在网页上进行相同操作](https://kleinrat.github.io/MoonFriction/#row-rules) · [本机 SQLite 复验](ROW-RULES.md)
