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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
pull_request:
branches: ["main"]
push:
branches: ["main"]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run tests
run: pytest -q
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release Artifact

on:
push:
branches: ["main"]

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Generate site artifact
run: python tools/generate_site.py

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: site-dist
path: dist/index.html
1 change: 1 addition & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""App package."""
5 changes: 5 additions & 0 deletions app/message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def render_message(name: str) -> str:
name = (name or "").strip()
if not name:
name = "anonymous"
return f"Hello, {name}!"
1 change: 1 addition & 0 deletions data/name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Yeji
20 changes: 20 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Day4 Artifact Demo</title>
<style>
body { font-family: Arial, Helvetica, sans-serif; padding: 24px; }
.box { max-width: 720px; border: 1px solid #ddd; border-radius: 8px; padding: 16px; }
</style>
</head>
<body>
<div class="box">
<h1>CI + Artifact CD Demo</h1>
<p><strong>Name:</strong> Yeji</p>
<p><strong>Message:</strong> Hello, Yeji!</p>
<p><strong>Generated at (UTC):</strong> 2026-01-15 16:32:49 UTC</p>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==8.3.2
8 changes: 0 additions & 8 deletions submissions/kyeowo1221.md

This file was deleted.

20 changes: 20 additions & 0 deletions tests/test_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from pathlib import Path
import sys

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))

from app.message import render_message


def test_render_message_normal():
assert render_message("Yeji") == "Hello, Yeji!"


def test_render_message_trims():
assert render_message(" Yeji ") == "Hello, Yeji!"


def test_render_message_empty():
assert render_message("") == "Hello, anonymous!"
46 changes: 46 additions & 0 deletions tools/generate_site.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from datetime import datetime, timezone
from pathlib import Path
import sys

ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))

from app.message import render_message
DATA = ROOT / "data" / "name.txt"
OUT = ROOT / "dist" / "index.html"


def main():
name = DATA.read_text(encoding="utf-8").strip()
rendered = render_message(name)
now = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")

html = f"""<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Day4 Artifact Demo</title>
<style>
body {{ font-family: Arial, Helvetica, sans-serif; padding: 24px; }}
.box {{ max-width: 720px; border: 1px solid #ddd; border-radius: 8px; padding: 16px; }}
</style>
</head>
<body>
<div class="box">
<h1>CI + Artifact CD Demo</h1>
<p><strong>Name:</strong> {name}</p>
<p><strong>Message:</strong> {rendered}</p>
<p><strong>Generated at (UTC):</strong> {now}</p>
</div>
</body>
</html>
"""
OUT.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text(html, encoding="utf-8")
print(f"Wrote {OUT}")


if __name__ == "__main__":
main()
Loading