Skip to content

Commit cd2e8d3

Browse files
committed
Test, build, package stages with additional placeholders
Signed-off-by: anuunchin <88698977+anuunchin@users.noreply.github.com>
1 parent 211088c commit cd2e8d3

20 files changed

Lines changed: 1765 additions & 14 deletions

.github/workflows/ci.yml

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88

99
# Lint stage
10-
10+
1111
lint-frontend:
1212
name: Lint frontend
1313
runs-on: ubuntu-latest
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Lint
3030
run: make lint-frontend
31-
31+
3232
lint-backend:
3333
name: Lint backend
3434
runs-on: ubuntu-latest
@@ -47,3 +47,123 @@ jobs:
4747

4848
- name: Lint
4949
run: make lint-backend
50+
51+
# Build stage
52+
53+
build-frontend:
54+
name: Build frontend
55+
runs-on: ubuntu-latest
56+
needs: [lint-frontend]
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
61+
- name: Setup Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
cache: 'npm'
66+
cache-dependency-path: 'src/frontend/package-lock.json'
67+
68+
- name: Install dependencies
69+
working-directory: src/frontend
70+
run: npm ci
71+
72+
- name: Build
73+
working-directory: src/frontend
74+
run: npm run build
75+
76+
build-backend:
77+
name: Build backend
78+
runs-on: ubuntu-latest
79+
needs: [lint-backend]
80+
steps:
81+
- name: Checkout
82+
uses: actions/checkout@v4
83+
84+
- name: Install uv
85+
uses: astral-sh/setup-uv@v3
86+
87+
- name: Set up Python
88+
run: uv python install 3.11
89+
90+
- name: Install dependencies
91+
run: make install-backend
92+
93+
- name: Build (smoke test)
94+
working-directory: src/backend
95+
run: uv run python main.py
96+
97+
# Test stage
98+
99+
test-frontend:
100+
name: Test frontend
101+
runs-on: ubuntu-latest
102+
needs: [build-frontend]
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v4
106+
107+
- name: Setup Node.js
108+
uses: actions/setup-node@v4
109+
with:
110+
node-version: '20'
111+
cache: 'npm'
112+
cache-dependency-path: 'src/frontend/package-lock.json'
113+
114+
- name: Install dependencies
115+
working-directory: src/frontend
116+
run: npm ci
117+
118+
- name: Test
119+
run: make test-frontend
120+
121+
test-backend:
122+
name: Test backend
123+
runs-on: ubuntu-latest
124+
needs: [build-backend]
125+
steps:
126+
- name: Checkout
127+
uses: actions/checkout@v4
128+
129+
- name: Install uv
130+
uses: astral-sh/setup-uv@v3
131+
132+
- name: Set up Python
133+
run: uv python install 3.11
134+
135+
- name: Install dependencies
136+
run: make install-backend
137+
138+
- name: Test
139+
run: make test-backend
140+
141+
# Package stage
142+
143+
package-frontend:
144+
name: Package frontend
145+
runs-on: ubuntu-latest
146+
needs: [test-frontend]
147+
steps:
148+
- name: Checkout
149+
uses: actions/checkout@v4
150+
151+
- name: Set up Docker Buildx
152+
uses: docker/setup-buildx-action@v3
153+
154+
- name: Build Docker image
155+
run: make docker-build-frontend
156+
157+
package-backend:
158+
name: Package backend
159+
runs-on: ubuntu-latest
160+
needs: [test-backend]
161+
steps:
162+
- name: Checkout
163+
uses: actions/checkout@v4
164+
165+
- name: Set up Docker Buildx
166+
uses: docker/setup-buildx-action@v3
167+
168+
- name: Build Docker image
169+
run: make docker-build-backend

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ bin/
3636
.DS_Store
3737

3838
.venv/
39-
.ruff_cache/
39+
.ruff_cache/
40+
.mypy_cache/
41+
.pytest_cache/

Makefile

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help lint lint-frontend lint-backend lint-go
1+
.PHONY: help lint lint-frontend lint-backend type-check-backend test test-frontend test-backend format format-frontend format-backend docker-build docker-build-frontend docker-build-backend docker-run-frontend docker-run-backend docker-clean
22

33
help:
44
@echo "make"
@@ -9,13 +9,37 @@ help:
99
@echo " install-backend"
1010
@echo " install backend dependencies (uv)"
1111
@echo " lint"
12-
@echo " runs all linters (frontend, backend, and Go)"
12+
@echo " runs all linters and type checking (frontend, backend)"
1313
@echo " lint-frontend"
1414
@echo " lints frontend code with npm run lint"
1515
@echo " lint-backend"
1616
@echo " lints backend Python code with ruff"
17+
@echo " type-check-backend"
18+
@echo " type checks backend Python code with mypy"
19+
@echo " format"
20+
@echo " formats all code (frontend and backend)"
21+
@echo " format-frontend"
22+
@echo " formats frontend code with prettier"
1723
@echo " format-backend"
1824
@echo " formats backend Python code with ruff"
25+
@echo " test"
26+
@echo " runs all tests (frontend and backend)"
27+
@echo " test-frontend"
28+
@echo " runs frontend tests with vitest"
29+
@echo " test-backend"
30+
@echo " runs backend tests with pytest"
31+
@echo " docker-build"
32+
@echo " builds all Docker images (frontend and backend)"
33+
@echo " docker-build-frontend"
34+
@echo " builds frontend Docker image"
35+
@echo " docker-build-backend"
36+
@echo " builds backend Docker image"
37+
@echo " docker-run-frontend"
38+
@echo " runs frontend container on port 8080"
39+
@echo " docker-run-backend"
40+
@echo " runs backend container on port 8000"
41+
@echo " docker-clean"
42+
@echo " removes built Docker images"
1943

2044
dev: install
2145

@@ -29,14 +53,52 @@ install-backend:
2953
cd src/backend && uv pip install -r requirements.txt
3054
cd src/backend && uv pip install -r requirements-dev.txt
3155

32-
lint: lint-frontend lint-backend lint-go
56+
lint: lint-frontend lint-backend type-check-backend
3357

3458
lint-frontend:
3559
cd src/frontend && npm run lint
3660

3761
lint-backend:
3862
cd src/backend && uv run ruff check .
3963

64+
format: format-frontend format-backend
65+
66+
format-frontend:
67+
cd src/frontend && npx prettier --write .
68+
4069
format-backend:
4170
cd src/backend && uv run ruff format .
4271

72+
type-check-backend:
73+
cd src/backend && uv run mypy .
74+
75+
test: test-frontend test-backend
76+
77+
test-frontend:
78+
cd src/frontend && npm test
79+
80+
test-backend:
81+
cd src/backend && uv run pytest
82+
83+
docker-build: docker-build-frontend docker-build-backend
84+
85+
docker-build-frontend:
86+
docker build -t robot-frontend:latest src/frontend
87+
88+
docker-build-backend:
89+
docker build -t robot-backend:latest src/backend
90+
91+
docker-run-frontend:
92+
@echo "Starting frontend container..."
93+
@docker run -d --rm -p 8080:80 --name robot-frontend-dev robot-frontend:latest
94+
@sleep 1
95+
@echo "Opening browser at http://localhost:8080"
96+
@open http://localhost:8080 || echo "Please open http://localhost:8080 in your browser"
97+
@echo "To stop: docker stop robot-frontend-dev"
98+
99+
docker-run-backend:
100+
docker run --rm -p 8000:8000 robot-backend:latest
101+
102+
docker-clean:
103+
docker rmi robot-frontend:latest robot-backend:latest || true
104+

src/backend/.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__pycache__
2+
.pytest_cache
3+
.ruff_cache
4+
5+
.venv
6+
7+
Dockerfile
8+
.dockerignore
9+
10+
tests
11+

src/backend/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3.11-slim
2+
WORKDIR /app
3+
COPY requirements.txt .
4+
RUN pip install --no-cache-dir -r requirements.txt
5+
COPY . .
6+
EXPOSE 8000
7+
CMD ["python", "main.py"]
8+

src/backend/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""
2-
Minimal smoke test file for CI
2+
Minimal placeholder file for CI
33
"""
44

55

6-
def hello():
7-
"""Placeholder function."""
6+
def hello() -> str:
87
return "Hello from backend"
98

109

src/backend/mypy.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[mypy]
2+
python_version = 3.11
3+
exclude = (tests/|\.venv/)
4+
5+
disallow_untyped_defs = True
6+
disallow_incomplete_defs = True
7+
check_untyped_defs = True

src/backend/requirements-dev.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
-r requirements.txt
2-
ruff==0.7.0
2+
ruff==0.7.0
3+
pytest==8.3.3
4+
mypy==1.13.0

src/backend/tests/__init__.py

Whitespace-only changes.

src/backend/tests/test_main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from main import hello
2+
3+
4+
def test_hello():
5+
assert hello() == "Hello from backend"

0 commit comments

Comments
 (0)