Add test code to verify CI pipeline
Train & Deploy / train (push) Failing after 0s Details
Train & Deploy / build-and-deploy (push) Has been skipped Details
CI - Lint & Test / lint-and-test (push) Failing after 18s Details

- src/train.py: example training script
- tests/test_train.py: pytest test
- requirements.txt: pandas, scikit-learn
- Fix ci.yaml: use python:3.10-slim container

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Cloud User 2026-02-25 15:42:14 +09:00
parent b25b7d080e
commit d782c2741d
5 changed files with 37 additions and 6 deletions

View File

@ -8,16 +8,13 @@ on:
jobs:
lint-and-test:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: python:3.10-slim
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
pandas>=2.0.0
scikit-learn>=1.3.0

0
src/__init__.py Normal file
View File

23
src/train.py Normal file
View File

@ -0,0 +1,23 @@
"""Example training script for MLOps pipeline test."""
import json
import os
def train():
"""Simple training function for pipeline testing."""
model_info = {
"model": "test-model",
"version": "0.1.0",
"accuracy": 0.95,
}
os.makedirs("models", exist_ok=True)
with open("models/model_info.json", "w") as f:
json.dump(model_info, f, indent=2)
print(f"Training complete: {model_info}")
return model_info
if __name__ == "__main__":
train()

9
tests/test_train.py Normal file
View File

@ -0,0 +1,9 @@
"""Tests for training script."""
from src.train import train
def test_train_returns_model_info():
result = train()
assert result["model"] == "test-model"
assert "accuracy" in result
assert result["accuracy"] > 0