Skip to content

Commit 5eabdf7

Browse files
mekarpelesMek
authored andcommitted
Tested build workflow locally with success
1 parent da12419 commit 5eabdf7

File tree

1 file changed

+59
-4
lines changed

1 file changed

+59
-4
lines changed

.github/agents/open-library-instructions.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22

33
This document provides step-by-step instructions for GitHub Copilot agents working on Open Library tasks. Follow these instructions to set up, build, test, and verify changes.
44

5+
> **Note**: If `docker compose` (with space) fails with "unknown command", use `docker-compose` (with hyphen) instead. This is required when using colima or Docker without the buildx plugin.
6+
57
## Repository Structure
68

79
Open Library is a Python/JavaScript web application built with:
10+
811
- **Backend**: Python 3.12, web.py framework, Infogami wiki system
912
- **Frontend**: JavaScript/Vue.js, LESS/CSS, Lit web components
1013
- **Infrastructure**: Docker Compose for local development
1114
- **Database**: PostgreSQL, Solr for search
1215

1316
### Key Directories
17+
1418
- `openlibrary/core/` - Core Open Library functionality
1519
- `openlibrary/plugins/` - Models, controllers, and view helpers
1620
- `openlibrary/views/` - Views for rendering web pages
@@ -24,34 +28,40 @@ Open Library is a Python/JavaScript web application built with:
2428
## Initial Setup
2529

2630
### 1. Check Docker Installation
31+
2732
```bash
2833
docker --version
29-
docker compose version
34+
docker-compose version # or "docker compose version" if using Docker Desktop with buildx plugin
3035
docker run hello-world
3136
```
3237

3338
### 2. Build the Docker Environment
39+
3440
```bash
3541
# From the repository root
36-
docker compose build
42+
docker-compose build # or "docker compose build" if using Docker Desktop with buildx plugin
3743
```
44+
3845
This takes 15-30 minutes on first run. If it times out, re-run the command.
3946

4047
### 3. Start the Application
48+
4149
```bash
4250
# Start all services
43-
docker compose up -d
51+
docker-compose up -d # or "docker compose up -d" if using Docker Desktop with buildx plugin
4452

4553
# View logs to confirm startup
46-
docker compose logs -f --tail=50 web
54+
docker-compose logs -f --tail=50 web # or "docker compose logs -f --tail=50 web"
4755
```
4856

4957
The application is ready when you see repeating log entries like:
58+
5059
```
5160
infobase_1 | 172.19.0.5:45716 - - [16/Feb/2023 16:54:10] "HTTP/1.1 GET /openlibrary.org/log/2023-02-16:0" - 200 OK
5261
```
5362

5463
### 4. Verify the Application is Running
64+
5565
- Visit http://localhost:8080 in your browser
5666
- You should see the Open Library homepage with "development version" banner
5767
- Services are available at:
@@ -76,51 +86,60 @@ docker compose run --rm home make lit-components # Lit web components
7686
```
7787

7888
### Install Node Dependencies (if package.json changes)
89+
7990
```bash
8091
docker compose run --rm home npm install --no-audit
8192
```
8293

8394
### Install Python Dependencies (if requirements.txt changes)
95+
8496
```bash
8597
# Rebuild the home container
8698
docker compose build home
8799
```
88100

89101
### Update Git Submodules (e.g., infogami)
102+
90103
```bash
91104
docker compose run --rm home sh -c "git submodule init && git submodule sync && git submodule update"
92105
```
93106

94107
## Running Tests
95108

96109
### Run All Tests
110+
97111
```bash
98112
docker compose run --rm home make test
99113
```
100114

101115
This runs:
116+
102117
1. Python tests (pytest)
103118
2. JavaScript tests (jest)
104119
3. i18n validation tests
105120

106121
### Run Python Tests Only
122+
107123
```bash
108124
docker compose run --rm home make test-py
109125
# Or with pytest directly:
110126
docker compose run --rm home pytest . --ignore=infogami --ignore=vendor --ignore=node_modules
111127
```
112128

113129
### Run JavaScript Tests Only
130+
114131
```bash
115132
docker compose run --rm home npm run test:js
116133
```
117134

118135
### Run i18n Tests
136+
119137
```bash
120138
docker compose run --rm home make test-i18n
121139
```
122140

123141
### Run Specific Test File
142+
124143
```bash
125144
docker compose run --rm home pytest tests/unit/test_something.py
126145
docker compose run --rm home pytest tests/unit/test_something.py::test_specific_function
@@ -129,6 +148,7 @@ docker compose run --rm home pytest tests/unit/test_something.py::test_specific_
129148
## Linting and Code Quality
130149

131150
### Pre-commit Hooks (Recommended)
151+
132152
The repository uses pre-commit hooks for automated linting. These run automatically in CI but should be run locally:
133153

134154
```bash
@@ -144,6 +164,7 @@ docker compose run --rm home pre-commit run --all-files
144164
```
145165

146166
### Python Linting
167+
147168
```bash
148169
# Run ruff linter (primary Python linter)
149170
docker compose run --rm home make lint
@@ -161,6 +182,7 @@ docker compose run --rm home python -m mypy openlibrary/
161182
```
162183

163184
### JavaScript Linting
185+
164186
```bash
165187
# Lint JavaScript and Vue files
166188
docker compose run --rm home npm run lint:js
@@ -170,6 +192,7 @@ docker compose run --rm home npm run lint-fix:js
170192
```
171193

172194
### CSS Linting
195+
173196
```bash
174197
# Lint CSS/LESS files
175198
docker compose run --rm home npm run lint:css
@@ -179,6 +202,7 @@ docker compose run --rm home npm run lint-fix:css
179202
```
180203

181204
### All Linting Together
205+
182206
```bash
183207
# Run all linters (check only, no fixes)
184208
docker compose run --rm home npm run lint # JS + CSS
@@ -193,29 +217,35 @@ docker compose run --rm home python -m black . # Python formatting
193217
## Internationalization (i18n)
194218

195219
### Extract Messages (Create/Update .pot file)
220+
196221
```bash
197222
docker compose run --rm home python ./scripts/i18n-messages extract
198223
```
199224

200225
### Compile Messages
226+
201227
```bash
202228
docker compose run --rm home make i18n
203229
# Or:
204230
docker compose run --rm home python ./scripts/i18n-messages compile
205231
```
206232

207233
### Validate i18n for Specific Locales
234+
208235
```bash
209236
docker compose run --rm home python ./scripts/i18n-messages validate de es fr hr it ja zh
210237
```
211238

212239
## Development Workflow
213240

214241
### 1. Make Code Changes
242+
215243
Edit files in your local repository. Changes are automatically synced to the Docker container via volume mounts.
216244

217245
### 2. Restart Services (if needed)
246+
218247
Most Python changes require a restart:
248+
219249
```bash
220250
docker compose restart web
221251
# Or for all services:
@@ -225,6 +255,7 @@ docker compose restart
225255
Frontend asset changes require rebuilding (see "Building Assets" section).
226256

227257
### 3. View Logs
258+
228259
```bash
229260
# View logs for a specific service
230261
docker compose logs -f web
@@ -236,6 +267,7 @@ docker compose logs -f
236267
```
237268

238269
### 4. Access Container Shell
270+
239271
```bash
240272
# Open bash in the web container
241273
docker compose exec web bash
@@ -245,6 +277,7 @@ docker compose run --rm home bash
245277
```
246278

247279
### 5. Run Commands in Container
280+
248281
```bash
249282
# Format: docker compose run --rm home <command>
250283
docker compose run --rm home python scripts/some_script.py
@@ -254,12 +287,15 @@ docker compose run --rm home psql -h db -U openlibrary openlibrary
254287
## Common Development Tasks
255288

256289
### Clear Browser Cache
290+
257291
If changes aren't appearing:
292+
258293
1. Hard refresh: Ctrl+Shift+R (Linux/Windows) or Cmd+Shift+R (Mac)
259294
2. Clear browser cache completely
260295
3. Check that assets were rebuilt (check timestamps in `static/build/`)
261296

262297
### Database Operations
298+
263299
```bash
264300
# Connect to PostgreSQL
265301
docker compose exec db psql -U openlibrary openlibrary
@@ -269,6 +305,7 @@ docker compose run --rm home python scripts/run_migrations.py
269305
```
270306

271307
### Solr Reindexing (if needed)
308+
272309
```bash
273310
# Note: This is a long-running operation
274311
docker compose run --rm home make reindex-solr
@@ -277,18 +314,22 @@ docker compose run --rm home make reindex-solr
277314
## Cleanup and Reset
278315

279316
### Stop Services
317+
280318
```bash
281319
docker compose down
282320
```
283321

284322
### Remove Volumes (Reset Database)
323+
285324
```bash
286325
docker compose down
287326
docker compose rm -v
288327
```
289328

290329
### Full Environment Reset
330+
291331
If you encounter persistent issues:
332+
292333
```bash
293334
# Stop everything
294335
docker compose down
@@ -312,11 +353,13 @@ docker compose up -d
312353
When working on an Open Library issue, follow this workflow:
313354

314355
### 1. Understand the Task
356+
315357
- Read the issue description carefully
316358
- Review related files and code
317359
- Check existing tests
318360

319361
### 2. Set Up Environment
362+
320363
```bash
321364
# Ensure services are running
322365
docker compose up -d
@@ -326,22 +369,26 @@ curl http://localhost:8080
326369
```
327370

328371
### 3. Make Changes
372+
329373
- Edit the necessary files
330374
- Follow existing code style and patterns
331375
- Add or update tests as needed
332376

333377
### 4. Build Assets (if frontend changes)
378+
334379
```bash
335380
# Build affected assets
336381
docker compose run --rm home npm run build-assets
337382
```
338383

339384
### 5. Compile i18n (if template changes)
385+
340386
```bash
341387
docker compose run --rm home make i18n
342388
```
343389

344390
### 6. Run Linters
391+
345392
```bash
346393
# Python
347394
docker compose run --rm home make lint
@@ -358,6 +405,7 @@ docker compose run --rm home npm run lint-fix
358405
```
359406

360407
### 7. Run Tests
408+
361409
```bash
362410
# Run relevant tests
363411
docker compose run --rm home pytest tests/unit/test_your_feature.py
@@ -367,12 +415,14 @@ docker compose run --rm home make test
367415
```
368416

369417
### 8. Manual Verification
418+
370419
- Restart services if needed: `docker compose restart web`
371420
- Test in browser at http://localhost:8080
372421
- Verify the changes work as expected
373422
- Check for console errors in browser dev tools
374423

375424
### 9. Final Checks
425+
376426
- Run pre-commit hooks: `docker compose run --rm home pre-commit run --all-files`
377427
- Ensure all tests pass
378428
- Verify linting passes
@@ -381,14 +431,17 @@ docker compose run --rm home make test
381431
## Troubleshooting
382432

383433
### "No module named 'infogami'"
434+
384435
```bash
385436
docker compose run --rm home sh -c "git submodule init && git submodule sync && git submodule update"
386437
```
387438

388439
### "Cannot allocate memory" Errors
440+
389441
Increase Docker's RAM allocation to at least 4GB and swap to 2GB in Docker Desktop settings.
390442

391443
### Port Already in Use
444+
392445
```bash
393446
# Check what's using the port
394447
lsof -i :8080 # or netstat -an | grep 8080
@@ -397,6 +450,7 @@ lsof -i :8080 # or netstat -an | grep 8080
397450
```
398451

399452
### Container Keeps Restarting
453+
400454
```bash
401455
# Check logs for errors
402456
docker compose logs web
@@ -408,6 +462,7 @@ docker compose logs web
408462
```
409463

410464
### Changes Not Appearing
465+
411466
1. Rebuild assets: `docker compose run --rm home npm run build-assets`
412467
2. Restart service: `docker compose restart web`
413468
3. Hard refresh browser: Ctrl+Shift+R

0 commit comments

Comments
 (0)