# cicd-examples **Repository Path**: looking4id/cicd-examples ## Basic Information - **Project Name**: cicd-examples - **Description**: 多语言小工程,验证流水线构建、打包、单元测试效果 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-13 - **Last Updated**: 2026-09-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # code-examples 多语言「 hello world + 单元测试 」示例工程,用于演示 **CI/CD 在不同技术栈下如何构建并运行单元测试**。 每个子目录都是一个**独立、可单独构建**的最小工程,且都带一个会断言 `hello world` 的单元测试 —— 可直接挂到流水线里当作「构建 + 测试」阶段的样例。 | 目录 | 语言 / 框架 | 构建工具 | 运行单元测试 | 说明 | |------|------------|----------|--------------|------| | `java-springboot-hello/` | Java 21 + Spring Boot 3.3 | Maven | `mvn test` | Web 工程,`GET /hello` 返回 `hello world`;测试为纯单元(不启动容器) | | `node-vue3-hello/` | Node + Vue 3 | npm (Vite + Vitest) | `npm install && npm test` | 含组件测试(`@vue/test-utils`)+ 纯函数测试 | | `go-hello/` | Go 1.21 | `go` | `go test ./...` | 单 module;`go run .` 打印 `hello world` | | `python-hello/` | Python 3.10 | 标准库 `unittest` | `python -m unittest test_hello -v` | 无需 `pytest`,开箱即跑(本机未装 pytest) | ## 在流水线里怎么用 以「构建 + 测试」两个阶段为例(语言片段可直接拼进 WeAgile / YAML 流水线): ```yaml # Java - mvn -B test # Node - npm ci && npm test # 若提交了 package-lock.json;否则用 npm install # Go - go test ./... # Python - python -m unittest discover -s . -p "test_*.py" -v ``` 每个子目录里额外附带了 `.github/workflows/ci.yml`,是一份**可直接运行的 GitHub Actions 样例**, 展示了对应语言在 CI 里「装环境 → 跑测试」的标准写法,可照搬到其他 CI 系统。 ## 验证(本机已跑通) | 工程 | 运行输出 | 测试 | |------|----------|------| | go-hello | `hello world` | `ok example.com/go-hello` | | python-hello | `hello world` | `Ran 1 test ... OK` | | java-springboot-hello | `GET /hello` → `hello world` | `mvn test` 通过 | | node-vue3-hello | 页面渲染 `hello world` | `vitest run` 通过 |