Skip to content

Commit 0cc1bb7

Browse files
phernandezphernandez
andauthored
Project refactor (#4)
* refactor project into foundation and modules - get app running again * fix tests * add more tests * Refactor workflows and update project structure - Remove redundant Node.js dependency installation from workflow - Use distinct install targets in Makefile for Python and Node.js - Update paths and references in pyproject.toml and .gitignore - Adjust commands in Makefile to accommodate new directory structure * fix init_data path in Makefile * fix pyproject.toml * fix test targets in github actions * fix test targets in github actions again --------- Co-authored-by: phernandez <phernandez@basicmachines.co>
1 parent 8bacae6 commit 0cc1bb7

124 files changed

Lines changed: 535 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coveragerc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
dynamic_context = test_function
33
branch = true
44
source =
5-
app/src
5+
foundation
66

77
omit =
8-
app/tests/foundation/conftest.py
9-
app/src/foundation/web/*
8+
foundation/conftest.py
9+
modules/foundation/web/*
1010

1111
concurrency=greenlet

.github/workflows/basic-foundation-test.yml

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,42 +35,6 @@ jobs:
3535
with:
3636
python-version: "3.12.1"
3737

38-
# - name: Cache Poetry
39-
# id: poetry-cache
40-
# uses: actions/cache@v3
41-
# with:
42-
# path: ~/.poetry
43-
# key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
44-
# restore-keys: |
45-
# ${{ runner.os }}-poetry-
46-
#
47-
# - name: Cache virtualenv
48-
# id: venv-cache
49-
# uses: actions/cache@v3
50-
# with:
51-
# path: .venv
52-
# key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
53-
# restore-keys: |
54-
# ${{ runner.os }}-venv-
55-
#
56-
# - name: Cache Playwright binaries
57-
# id: playwright-cache
58-
# uses: actions/cache@v3
59-
# with:
60-
# path: ~/.cache/ms-playwright
61-
# key: ${{ runner.os }}-playwright-${{ hashFiles('**/poetry.lock') }}
62-
# restore-keys: |
63-
# ${{ runner.os }}-playwright-
64-
#
65-
# - name: Cache Node.js modules
66-
# id: node-modules-cache
67-
# uses: actions/cache@v3
68-
# with:
69-
# path: node_modules
70-
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
71-
# restore-keys: |
72-
# ${{ runner.os }}-node-
73-
7438
- name: Bootstrap poetry
7539
run: |
7640
if [ ! -x "$(command -v poetry)" ]; then
@@ -88,12 +52,6 @@ jobs:
8852
run: |
8953
make install
9054
91-
- name: Install Node.js dependencies
92-
run: |
93-
if [ ! -d "node_modules" ]; then
94-
npm install
95-
fi
96-
9755
- name: Run dbmate migrations
9856
run: |
9957
make migrate-up
@@ -106,9 +64,13 @@ jobs:
10664
run: |
10765
make type-check
10866
109-
- name: Run api tests
67+
- name: Run foundation tests
11068
run: |
111-
make test-api
69+
make test-foundation
70+
71+
- name: Run foundation tests
72+
run: |
73+
make test-modules-api
11274
11375
- name: Install Playwright and dependencies
11476
run: |
@@ -126,7 +88,7 @@ jobs:
12688
12789
- name: Run Playwright tests
12890
run: |
129-
make test-playwright
91+
make test-modules-web
13092
13193
- name: Upload Playwright Traces
13294
uses: actions/upload-artifact@v4
@@ -147,7 +109,6 @@ jobs:
147109
- name: Display coverage report in job summary
148110
run: cat coverage.md >> $GITHUB_STEP_SUMMARY
149111

150-
151112
- name: Upload Coverage Report
152113
uses: actions/upload-artifact@v4
153114
with:

.gitignore

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ cython_debug/
157157

158158

159159
.DS_Store
160-
/.idea/
161-
/node_modules/
162-
!/templates/email/build/
163-
<<<<<<< HEAD
164-
/coverage.txt
165-
=======
166-
160+
.idea/
161+
modules/foundation/web/node_modules/
162+
!/foundation/templates/email/build/
167163
coverage.txt
168-
>>>>>>> bea77b7

Makefile

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@ include .env
22

33
.PHONY: install test clean lint lint-fix format migrate-new migrate-up migrate-down migrate-dump migrate-reset
44

5-
install:
5+
install: install-python install-node
6+
7+
install-python:
68
poetry install
7-
npm install
9+
10+
install-node:
11+
cd modules/foundation/web && npm install
812

913
reset-cov:
1014
rm -f .coverage
1115

12-
test: reset-cov test-api test-playwright
16+
test: reset-cov test-foundation test-modules-api test-modules-web
17+
18+
COVERAGE_ARGS ?= --cov-append --cov-report=term-missing --cov-config=.coveragerc
1319

14-
COV_REPORT ?= term-missing
20+
test-foundation:
21+
poetry run pytest foundation --cov=./foundation $(COVERAGE_ARGS)
1522

16-
test-api:
17-
poetry run pytest --cov=./app --cov-append --cov-config=.coveragerc -m "not playwright"
23+
test-modules-api:
24+
poetry run pytest modules/foundation/api --cov=./modules/foundation/api $(COVERAGE_ARGS)
1825

19-
test-playwright: # assumes app is running on at API_URL in config
20-
poetry run pytest --cov=./app --cov-append --cov-config=.coveragerc -m "playwright" --tracing=retain-on-failure
26+
test-modules-web: # runs playwright tests: assumes app is running on at API_URL in config
27+
poetry run pytest modules/foundation/web --cov=./modules/foundation/web $(COVERAGE_ARGS) -m "playwright" --tracing=retain-on-failure
2128
#poetry run pytest -m "playwright" --headed --slowmo 500
2229

2330
test-coverage:
@@ -40,18 +47,18 @@ format-python:
4047
poetry run ruff format .
4148

4249
format-prettier:
43-
npx prettier templates --write
50+
cd modules/foundation/web && npx prettier templates --write
4451

4552
format: format-python format-prettier
4653

4754
type-check:
4855
poetry run pyright
4956

5057
tailwind:
51-
npm run build
58+
cd modules/foundation/web && npm run build
5259

5360
tailwind-prod:
54-
npm run build-prod
61+
cd modules/foundation/web && npm run build-prod
5562

5663
# Database migrations
5764

@@ -91,7 +98,7 @@ migrate-reset:
9198
# You might need to adjust this depending on your Docker setup and database location.
9299

93100
init-data:
94-
poetry run python app/src/tools/init_data.py
101+
poetry run python foundation/tools/init_data.py
95102

96103
run:
97-
poetry run fastapi run app/src/foundation/app.py --port 10000
104+
poetry run fastapi run foundation/app.py --port 10000

TODO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
- web-htmx
99
- [ ] uv
1010
- [ ] permission checks
11-
- [ ] user service with current user
1211
- [x] has to be at least one admin
1312
- [x] only admins can create/edit users
14-
- [ ] db: rename is_superuser to is_admin
1513
- [ ] dashboard stats should link to filtered list
14+
- [ ] user service with current user
1615
- [ ] make active/admin colums enums
16+
- [ ] db: rename is_superuser to is_admin
1717
- [ ] page_size is appended to url
1818
- [x] use fixtures in web tests
1919
- [x] delete user after test

app/pytest.ini

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/src/foundation/main.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/tests/foundation/test_main.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

app/tests/foundation/web/auth/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)