Skip to content

Commit f2416a5

Browse files
committed
添加GitHub Actions CI工作流,用于运行单元测试和验证示例代码
1 parent 5f32f72 commit f2416a5

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Go CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: 测试和示例验证
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: 检出代码
16+
uses: actions/checkout@v3
17+
18+
- name: 设置 Go 环境
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version: '1.20'
22+
cache: true
23+
24+
- name: 安装依赖
25+
run: go mod download
26+
27+
- name: 运行单元测试
28+
run: go test -v ./pkg/...
29+
30+
- name: 验证基本解析示例
31+
run: |
32+
go build -o parse-action ./example/01_basic_parsing/parse_action.go
33+
./parse-action pkg/parser/testdata/action.yml
34+
35+
- name: 验证工作流解析示例
36+
run: |
37+
go build -o parse-workflow ./example/02_workflow_parsing/parse_workflow.go
38+
./parse-workflow pkg/parser/testdata/workflow.yml
39+
40+
- name: 验证验证工具示例
41+
run: |
42+
go build -o validate-action ./example/03_validation/validate_action.go
43+
./validate-action pkg/parser/testdata/action.yml
44+
45+
- name: 验证可重用工作流分析示例
46+
run: |
47+
go build -o analyze-reusable ./example/04_reusable_workflow/analyze_reusable_workflow.go
48+
./analyze-reusable pkg/parser/testdata/reusable-workflow.yml
49+
50+
- name: 验证实用工具函数示例
51+
run: |
52+
go build -o utils-example ./example/05_utility_functions/utils_example.go
53+
./utils-example parse_dir pkg/parser/testdata/
54+
./utils-example check_reusable pkg/parser/testdata/reusable-workflow.yml
55+
./utils-example extract_inputs pkg/parser/testdata/reusable-workflow.yml
56+
./utils-example extract_outputs pkg/parser/testdata/reusable-workflow.yml
57+
./utils-example convert_map '{"key1":"value1","key2":"value2"}'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
一个用于解析、验证和处理GitHub Action YAML文件的Go库。
44

5-
[![Go Reference](https://pkg.go.dev/badge/github.com/scagogogo/github-action-parser.svg)](https://pkg.go.dev/github.com/scagogogo/github-action-parser)
5+
[![Go Reference](https://pkg.go.dev/badge/github.com/scagogogo/github-action-parser.svg)](https://pkg.go.dev/github.com/scagogogo/github-action-parser) [![Go CI](https://github.com/scagogogo/github-action-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/scagogogo/github-action-parser/actions/workflows/ci.yml)
66

77
## 功能特点
88

0 commit comments

Comments
 (0)