Skip to content

Commit

Permalink
Add PDM as dependency manager
Browse files Browse the repository at this point in the history
Remove old dependency style .txt

Add PDM to demo project and linted project with ruff

Add PDM to fastui and linted project with ruff

Updated gitignore with pdm stuff

Fix CI/CD
  • Loading branch information
ManiMozaffar committed Apr 29, 2024
1 parent a19d7bf commit faa5697
Show file tree
Hide file tree
Showing 47 changed files with 1,836 additions and 316 deletions.
35 changes: 23 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ jobs:
with:
node-version: 18

- run: pip install -r src/python-fastui/requirements/all.txt
- run: pip install src/python-fastui
- run: pip install pdm==2.12.4

- run: make install

- run: make lint

- run: npm install

Expand Down Expand Up @@ -69,23 +72,31 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- run: pip install -r src/python-fastui/requirements/test.txt
- run: pip install -r src/python-fastui/requirements/pyproject.txt
- run: pip install -e src/python-fastui
- run: pip install pdm==2.12.4

- run: make install

- run: make testcov

- run: make testcov-report

- run: coverage run -m pytest src
# display coverage and fail if it's below 80%, which shouldn't happen
- run: coverage report --fail-under=80
- run: make typecheck

# ci on demo for 3.11 and 3.12, these ops are intentionally omitted, reason is that it's using 3.11 and 3.12 syntax
- if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
run: make lint-demo

- if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
run: make typecheck-demo

# test demo on 3.11 and 3.12, these tests are intentionally omitted from coverage
- if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
run: pytest demo/tests.py
run: make test-demo

- run: coverage xml
- run: make testcov-xml

- uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
file: ./src/python-fastui/coverage.xml
env_vars: PYTHON,OS

npm-build:
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ __pycache__/
/frontend-dist/
/scratch/
/packages-dist/
/.coverage
.coverage
/users.db

# pdm
.pdm.toml
.pdm-python
.pdm-build/
__pypackages__/
49 changes: 32 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,63 @@ path = src/python-fastui

.PHONY: install
install:
pip install -U pip pre-commit pip-tools
pip install -r $(path)/requirements/all.txt
pip install -e $(path)
pre-commit install
cd src/python-fastui && pdm install
cd demo && pdm install

.PHONY: update-lockfiles
update-lockfiles:
@echo "Updating requirements files using pip-compile"
pip-compile -q --strip-extras -o $(path)/requirements/lint.txt $(path)/requirements/lint.in
pip-compile -q --strip-extras -o $(path)/requirements/pyproject.txt -c $(path)/requirements/lint.txt $(path)/pyproject.toml --extra=fastapi
pip-compile -q --strip-extras -o $(path)/requirements/test.txt -c $(path)/requirements/lint.txt -c $(path)/requirements/pyproject.txt $(path)/requirements/test.in
pip install --dry-run -r $(path)/requirements/all.txt
cd src/python-fastui && pdm sync
cd demo && pdm sync

.PHONY: format
format:
ruff check --fix-only $(path) demo
ruff format $(path) demo
cd src/python-fastui && pdm run ruff check --fix-only .
cd demo && pdm run ruff check --fix-only .

.PHONY: lint
lint:
ruff check $(path) demo
ruff format --check $(path) demo
cd src/python-fastui && pdm run ruff check .

.PHONY: lint-demo
lint-demo:
cd demo && pdm run ruff check .


.PHONY: typecheck
typecheck:
pyright
cd src/python-fastui && pdm run pyright fastui

.PHONY: typecheck-demo
typecheck-demo:
cd demo && pdm run pyright src


.PHONY: test
test:
coverage run -m pytest
cd src/python-fastui && pdm run coverage run -m pytest tests

.PHONY: test-demo
test-demo:
cd demo && pdm run pytest tests

.PHONY: testcov
testcov: test
coverage html
cd src/python-fastui && pdm run coverage html

.PHONY: testcov-report
testcov-report:
cd src/python-fastui && pdm run coverage report --fail-under=80

testcov-xml:
cd src/python-fastui && pdm run coverage xml

.PHONY: typescript-models
typescript-models:
fastui generate fastui:FastUI src/npm-fastui/src/models.d.ts

.PHONY: dev
dev:
uvicorn demo:app --reload --reload-dir .
uvicorn demo.src:app --reload --reload-dir .

.PHONY: all
all: testcov lint
Loading

0 comments on commit faa5697

Please sign in to comment.