Skip to content

Commit ef70bed

Browse files
authored
Refactoring python code location, adding tests (#66)
1 parent 90f30d2 commit ef70bed

Some content is hidden

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

99 files changed

+1041
-588
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
'plugin:react-hooks/recommended',
99
'prettier',
1010
],
11-
ignorePatterns: ['node_modules'],
11+
ignorePatterns: ['node_modules', 'dist'],
1212
parser: '@typescript-eslint/parser',
1313
plugins: ['react', '@typescript-eslint', 'react-refresh', 'simple-import-sort'],
1414
rules: {

.github/workflows/ci.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
with:
2525
node-version: 18
2626

27-
- run: pip install -r python/requirements/all.txt
27+
- run: pip install -r src/python-fastui/requirements/all.txt
2828

2929
- run: npm install
3030

@@ -34,7 +34,42 @@ jobs:
3434
env:
3535
SKIP: no-commit-to-branch
3636

37-
packages-build:
37+
test:
38+
name: test ${{ matrix.python-version }} on ${{ matrix.os }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
os: [ubuntu, macos]
43+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
44+
45+
runs-on: ${{ matrix.os }}-latest
46+
47+
env:
48+
PYTHON: ${{ matrix.python-version }}
49+
OS: ${{ matrix.os }}
50+
51+
steps:
52+
- uses: actions/checkout@v3
53+
54+
- name: set up python
55+
uses: actions/setup-python@v4
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
59+
- run: pip install -r src/python-fastui/requirements/test.txt
60+
- run: pip install -r src/python-fastui/requirements/pyproject.txt
61+
- run: pip install src/python-fastui
62+
63+
- run: make test
64+
65+
- run: coverage xml
66+
67+
- uses: codecov/codecov-action@v3
68+
with:
69+
file: ./coverage.xml
70+
env_vars: PYTHON,OS
71+
72+
npm-build:
3873
runs-on: ubuntu-latest
3974

4075
steps:
@@ -46,11 +81,11 @@ jobs:
4681

4782
- run: npm install
4883
- run: npm run build
49-
- run: tree packages
84+
- run: tree src
5085

5186
check: # This job does nothing and is only used for the branch protection
5287
if: always()
53-
needs: [lint, packages-build]
88+
needs: [lint, npm-build]
5489
runs-on: ubuntu-latest
5590

5691
steps:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ yarn-debug.log*
66
yarn-error.log*
77
pnpm-debug.log*
88
lerna-debug.log*
9+
/**/*.egg-info
910

1011
node_modules
1112
dist
@@ -31,3 +32,4 @@ __pycache__/
3132
/frontend-dist/
3233
/scratch/
3334
/packages-dist/
35+
/.coverage

Makefile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,46 @@
11
.DEFAULT_GOAL:=all
2-
paths = python
2+
path = src/python-fastui
33

44
.PHONY: install
55
install:
66
pip install -U pip pre-commit pip-tools
7-
pip install -r python/requirements/all.txt
7+
pip install -r $(path)/requirements/all.txt
8+
pip install -e $(path)
89
pre-commit install
910

1011
.PHONY: update-lockfiles
1112
update-lockfiles:
1213
@echo "Updating requirements files using pip-compile"
13-
pip-compile -q --strip-extras -o python/requirements/lint.txt python/requirements/lint.in
14-
pip-compile -q --strip-extras -o python/requirements/pyproject.txt pyproject.toml --extra=fastapi
15-
pip install --dry-run -r python/requirements/all.txt
14+
pip-compile -q --strip-extras -o $(path)/requirements/lint.txt $(path)/requirements/lint.in
15+
pip-compile -q --strip-extras -o $(path)/requirements/test.txt $(path)/requirements/test.in
16+
pip-compile -q --strip-extras -o $(path)/requirements/pyproject.txt $(path)/pyproject.toml --extra=fastapi
17+
pip install --dry-run -r $(path)/requirements/all.txt
1618

1719
.PHONY: format
1820
format:
19-
ruff check --fix-only $(paths)
20-
ruff format $(paths)
21+
ruff check --fix-only $(path)
22+
ruff format $(path)
2123

2224
.PHONY: lint
2325
lint:
24-
ruff check $(paths)
25-
ruff format --check $(paths)
26+
ruff check $(path)
27+
ruff format --check $(path)
2628

2729
.PHONY: typecheck
2830
typecheck:
29-
pyright python/fastui
31+
pyright
3032

3133
.PHONY: test
3234
test:
33-
coverage run -m pytest tests
35+
coverage run -m pytest
3436

3537
.PHONY: testcov
3638
testcov: test
3739
coverage html
3840

3941
.PHONY: dev
4042
dev:
41-
uvicorn python.demo:app --reload
43+
uvicorn demo:app --reload
4244

4345
.PHONY: all
4446
all: testcov lint
File renamed without changes.
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,19 @@ def form_content(kind: FormKind):
8585
return [
8686
c.Heading(text='Login Form', level=2),
8787
c.Paragraph(text='Simple login form with email and password.'),
88-
c.ModelForm[LoginForm](
89-
submit_url='/api/forms/login',
90-
success_event=PageEvent(name='form_success'),
91-
),
88+
c.ModelForm[LoginForm](submit_url='/api/forms/login'),
9289
]
9390
case 'select':
9491
return [
9592
c.Heading(text='Select Form', level=2),
9693
c.Paragraph(text='Form showing different ways of doing select.'),
97-
c.ModelForm[SelectForm](
98-
submit_url='/api/forms/select',
99-
success_event=PageEvent(name='form_success'),
100-
),
94+
c.ModelForm[SelectForm](submit_url='/api/forms/select'),
10195
]
10296
case 'big':
10397
return [
10498
c.Heading(text='Large Form', level=2),
10599
c.Paragraph(text='Form with a lot of fields.'),
106-
c.ModelForm[BigModel](
107-
submit_url='/api/forms/big',
108-
success_event=PageEvent(name='form_success'),
109-
),
100+
c.ModelForm[BigModel](submit_url='/api/forms/big'),
110101
]
111102
case _:
112103
raise ValueError(f'Invalid kind {kind!r}')
File renamed without changes.

0 commit comments

Comments
 (0)