Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

### 3) 配置最小 CI(GitHub Actions,~5–10 分钟)
name: CI
on:
push:
branches: [ main, "feature/**" ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install -r requirements.txt || true
- run: |
if [ -f requirements.txt ]; then
pytest -q
else
python -m src.app
fi
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python-envs.defaultEnvManager": "ms-python.python:conda",
"python-envs.defaultPackageManager": "ms-python.python:conda",
"python-envs.pythonProjects": []
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# DevOps
跑通最小 DevOps 流程(Hello World)PR+CI+Release+重新克隆运行成功
# Hello World (DevOps Flow)

![CI](https://github.com/chenshming/DevOps/actions/workflows/ci.yml/badge.svg)

## Run
```bash
python -m src.app
6 changes: 6 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# src/app.py
def main():
print("Hello, world")

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions tests/requirement.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==8.2.0
9 changes: 9 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from io import StringIO
from contextlib import redirect_stdout
from src.app import main

def test_main_prints_hello_world():
buf = StringIO()
with redirect_stdout(buf):
main()
assert buf.getvalue().strip() == "Hello, world"