-
-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (147 loc) · 5.37 KB
/
test.yml
File metadata and controls
162 lines (147 loc) · 5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Test
on:
push:
branches:
# Run on pushes to any branch, including namespaced branches like feat/foo.
- "**"
paths-ignore:
- "Changelog.md"
- "docker/**"
- "docker-compose.yml"
- "decks/**"
- ".dockerignore"
- "README.md"
- "deployment/**"
- "examples/**"
- "openspec/**"
- "cli/**"
- "website/**"
- "sandboxes/**"
- "wiki/**"
jobs:
###############################################################
## Test Frontend
###############################################################
test-frontend:
runs-on: ubuntu-latest
environment: Test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Cache Node dependencies
id: cache-node
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
working-directory: ./frontend
if: steps.cache-node.outputs.cache-hit != 'true'
run: npm ci
- name: Save Node dependencies cache
if: steps.cache-node.outputs.cache-hit != 'true'
id: save-cache-node
uses: actions/cache@v4
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Run tests
working-directory: ./frontend
run: npm test
- name: Build frontend
working-directory: ./frontend
run: npm run build
###############################################################
## Test Backend use Cache
###############################################################
test-backend:
runs-on: ubuntu-latest
environment: Test
env:
APP_ENV: test
APP_LOG_LEVEL: debug
APP_SECRET_KEY: ${{ secrets.APP_SECRET_KEY }}
POSTGRES_CONNECTION_STRING: postgresql://admin:test1234@localhost:5432/lg_template_test
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
REDIS_URL: redis://localhost:6379/0
services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: admin
POSTGRES_PASSWORD: test1234
POSTGRES_DB: lg_template_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache Python dependencies
id: cache-python
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
working-directory: ./backend
run: |
env | sort
mkdir -p src/public/docs
mkdir -p src/public/assets
pip install --upgrade pip
pip install uv
uv sync --frozen --no-cache --dev --extra api
- name: Save Python dependencies cache
if: steps.cache-python.outputs.cache-hit != 'true'
id: save-cache-python
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
- name: Wait for PostgreSQL
run: |
timeout 30 bash -c 'until pg_isready -h localhost -p 5432 -U admin; do sleep 1; done'
- name: Run database migrations
working-directory: ./backend
env:
PYTHONPATH: ./src:.
run: |
uv run alembic upgrade head
- name: Run tests
working-directory: ./backend
env:
PYTHONPATH: ./src:.
run: |
# Create the database directory
mkdir -p ./docker/postgres/data
# Run your tests
uv run pytest -rs