示例工程 39-ci-cd-release-pipeline
39-ci-cd-release-pipeline/02-github-actions-yaml/README.md
# 02 · github-actions-yaml
**演示**:不装 PyYAML,用 90 行实现 YAML 子集解析(映射/列表/标量/注释),把 `workflow.yml` 解析成 dict 后做结构校验:`name`、`on`、`runs-on`、`steps` 的 `uses`/`run`。CI 配置本身也能被单元测试。
**运行**:
```sh
uv run python examples/39-ci-cd-release-pipeline/02-github-actions-yaml/github_actions_yaml.py
```
**预期输出**(3.12.9):
```text
jobs: ['test']
python_versions: ['3.12', '3.13', '3.14']
steps: 4
problems: []
json_roundtrip: ci
```
**依赖**:仅标准库。
**注意**:只支持本仓库用到的 YAML 子集(块状映射/列表、单行标量),不支持 flow 列表 `[a, b]`、多行字符串 `|`、锚点;生产请用 PyYAML/ruamel。解析器拒绝 tab 缩进与不一致缩进,避免「本地看着对、CI 解析失败」。