Skip to content

Commit e7d80ce

Browse files
authored
add Makefile with test targets, test-templates CI workflow, remove manual-workflow (#58)
1 parent 03ddb66 commit e7d80ce

4 files changed

Lines changed: 98 additions & 69 deletions

File tree

.github/workflows/invoke-all.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Invoke All Functions
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
types:
67
- opened

.github/workflows/manual-workflow.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Test Templates
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
paths-ignore:
10+
- '.github/**'
11+
push:
12+
branches:
13+
- main
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: 'stable'
26+
27+
- name: Setup Java
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: 'temurin'
31+
java-version: '21'
32+
33+
- name: Setup Rust
34+
uses: actions-rust-lang/setup-rust-toolchain@v1
35+
36+
- name: Run template tests
37+
run: make test

Makefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.PHONY: test test-go test-node test-python test-quarkus test-rust test-springboot test-typescript test-ci invoke-ci
2+
3+
LOG := test-results.log
4+
START_TIME := $(shell date +%s%3N)
5+
6+
# Skipped templates:
7+
# go/blog — Hugo theme is a broken submodule, func create doesn't fetch submodules
8+
# python/llamacpp, mcp, mcp-ollama, mcp-ollama-rag, ollama-client — need external services or have broken tests
9+
GO_SKIP := blog
10+
PYTHON_SKIP := llamacpp mcp mcp-ollama mcp-ollama-rag ollama-client
11+
12+
# Run tests for each template in a language directory.
13+
# For each template: check skip list, run test command, print colored result with timing.
14+
# Detailed output goes to LOG file; PASS/FAIL/SKIP printed to stdout.
15+
# Args: $(1)=language dir $(2)=space-separated skip list $(3)=test command
16+
define run_tests
17+
@for dir in $(1)/*/; do \
18+
t=$$(basename $$dir); \
19+
skip=false; for s in $(2); do [ "$$t" = "$$s" ] && skip=true && break; done; \
20+
if [ "$$skip" = "true" ]; then \
21+
printf "\033[33mSKIP\033[0m %s\n" "$$dir"; echo "SKIP $$dir" >> $(LOG); continue; \
22+
fi; \
23+
start=$$(date +%s%3N); \
24+
if (cd $$dir && $(3)) >> $(LOG) 2>&1; then \
25+
ms=$$(( $$(date +%s%3N) - $$start )); \
26+
printf "\033[32mPASS\033[0m %s (%d.%03ds)\n" "$$dir" "$$((ms/1000))" "$$((ms%1000))"; \
27+
echo "PASS $$dir ($${ms}ms)" >> $(LOG); \
28+
else \
29+
ms=$$(( $$(date +%s%3N) - $$start )); \
30+
printf "\033[31mFAIL\033[0m %s (%d.%03ds)\n" "$$dir" "$$((ms/1000))" "$$((ms%1000))"; \
31+
echo "FAIL $$dir ($${ms}ms)" >> $(LOG); \
32+
fi; \
33+
done
34+
endef
35+
36+
test: clean-log test-go test-node test-python test-quarkus test-rust test-springboot test-typescript summary
37+
38+
clean-log:
39+
@rm -f $(LOG)
40+
@echo "Running tests..."
41+
42+
test-go: ; $(call run_tests,go,$(GO_SKIP),go test -count=1 ./...)
43+
test-node: ; $(call run_tests,node,,npm install --silent && npm test && rm -rf node_modules)
44+
test-python: ; $(call run_tests,python,$(PYTHON_SKIP),python -m venv .venv && .venv/bin/pip install -q '.[dev]' && .venv/bin/python -m pytest tests/ && rm -rf .venv)
45+
test-quarkus: ; $(call run_tests,quarkus,,mvn test -q)
46+
test-rust: ; $(call run_tests,rust,,cargo test)
47+
test-springboot: ; $(call run_tests,springboot,,mvn test -q)
48+
test-typescript: ; $(call run_tests,typescript,,npm install --silent && npm test && rm -rf node_modules build)
49+
50+
summary:
51+
@echo ""
52+
@echo "=== Test Summary ==="
53+
@passed=$$(grep -c "^PASS" $(LOG) || true); \
54+
failed=$$(grep -c "^FAIL" $(LOG) || true); \
55+
skipped=$$(grep -c "^SKIP" $(LOG) || true); \
56+
ms=$$(( $$(date +%s%3N) - $(START_TIME) )); \
57+
printf "\033[32m$$passed passed\033[0m, \033[31m$$failed failed\033[0m, \033[33m$$skipped skipped\033[0m in %d.%03ds\n" "$$((ms/1000))" "$$((ms%1000))"; \
58+
echo "Full log: $(LOG)"; \
59+
if [ "$$failed" -gt 0 ]; then echo ""; echo "=== Failed ==="; grep "^FAIL" $(LOG); exit 1; fi
60+

0 commit comments

Comments
 (0)