Forráskód Böngészése

Add cache for GitHub actions (#13)

Nikhil Rao 2 éve
szülő
commit
30f1bb17e1

+ 15 - 0
.github/workflows/python-checks.yml

@@ -25,15 +25,30 @@ jobs:
       with:
       with:
         python-version: ${{ matrix.python-version }}
         python-version: ${{ matrix.python-version }}
 
 
+    - name: cache poetry install
+      uses: actions/cache@v2
+      with:
+        path: ~/.local
+        key: poetry-1.1.14-0
+
     - uses: snok/install-poetry@v1
     - uses: snok/install-poetry@v1
       with:
       with:
         version: 1.1.14
         version: 1.1.14
         virtualenvs-create: true
         virtualenvs-create: true
         virtualenvs-in-project: true
         virtualenvs-in-project: true
 
 
+    - name: cache deps
+      id: cache-deps
+      uses: actions/cache@v2
+      with:
+        path: .venv
+        key: python-${{ matrix.python-version }}-pydeps-${{ hashFiles('**/poetry.lock') }}
+
     - run: poetry install --no-interaction --no-root
     - run: poetry install --no-interaction --no-root
+      if: steps.cache-deps.outputs.cache-hit != 'true'
     - run: poetry install --no-interaction
     - run: poetry install --no-interaction
     - run: poetry run pytest tests
     - run: poetry run pytest tests
     - run: poetry run pyright pynecone tests
     - run: poetry run pyright pynecone tests
     - run: poetry run pydocstyle pynecone tests
     - run: poetry run pydocstyle pynecone tests
     - run: poetry run darglint pynecone tests
     - run: poetry run darglint pynecone tests
+    - run: poetry run black --check pynecone tests

+ 0 - 2
pynecone/.templates/web/package.json

@@ -19,8 +19,6 @@
     "plotly.js": "2.6.4",
     "plotly.js": "2.6.4",
     "prettier": "^2.7.1",
     "prettier": "^2.7.1",
     "react": "^17.0.2",
     "react": "^17.0.2",
-    "react-confetti": "^6.1.0",
-    "react-copy-to-clipboard": "^5.1.0",
     "react-dom": "^17.0.2",
     "react-dom": "^17.0.2",
     "react-markdown": "^8.0.3",
     "react-markdown": "^8.0.3",
     "react-plotly.js": "^2.6.0",
     "react-plotly.js": "^2.6.0",

+ 3 - 0
pynecone/compiler/templates.py

@@ -11,6 +11,9 @@ PCCONFIG = f"""import pynecone as pc
 
 
 config = pc.Config(
 config = pc.Config(
     app_name="{{app_name}}",
     app_name="{{app_name}}",
+    bun_path="{constants.BUN_PATH}",
+    db_url="{constants.DB_URL}",
+    env=pc.Env.DEV,
 )
 )
 """
 """
 
 

+ 0 - 6
pynecone/components/media/avatar.py

@@ -11,9 +11,6 @@ class Avatar(ChakraComponent):
 
 
     tag = "Avatar"
     tag = "Avatar"
 
 
-    # Function to get the initials to display.
-    get_initials: Var[str]
-
     # The default avatar used as fallback when name, and src is not specified.
     # The default avatar used as fallback when name, and src is not specified.
     icon: Var[str]
     icon: Var[str]
 
 
@@ -23,9 +20,6 @@ class Avatar(ChakraComponent):
     # If true, opt out of the avatar's fallback logic and renders the img at all times.
     # If true, opt out of the avatar's fallback logic and renders the img at all times.
     ignore_fallback: Var[bool]
     ignore_fallback: Var[bool]
 
 
-    # Defines loading strategy ("eager" | "lazy").
-    loading: Var[str]
-
     # The name of the person in the avatar.
     # The name of the person in the avatar.
     name: Var[str]
     name: Var[str]
 
 

+ 3 - 3
pynecone/config.py

@@ -16,10 +16,10 @@ class Config(Base):
     username: Optional[str] = None
     username: Optional[str] = None
 
 
     # The backend API url.
     # The backend API url.
-    api_url: str = "http://localhost:8000"
+    api_url: str = constants.API_URL
 
 
     # The database url.
     # The database url.
-    db_url: str = f"sqlite:///{constants.DB_NAME}"
+    db_url: str = constants.DB_URL
 
 
     # The redis url.
     # The redis url.
     redis_url: Optional[str] = None
     redis_url: Optional[str] = None
@@ -31,4 +31,4 @@ class Config(Base):
     env: constants.Env = constants.Env.DEV
     env: constants.Env = constants.Env.DEV
 
 
     # The path to the bun executable.
     # The path to the bun executable.
-    bun_path: str = "$HOME/.bun/bin/bun"
+    bun_path: str = constants.BUN_PATH

+ 6 - 0
pynecone/constants.py

@@ -48,6 +48,10 @@ NODE_MODULES = "node_modules"
 PACKAGE_LOCK = "package-lock.json"
 PACKAGE_LOCK = "package-lock.json"
 
 
 # Commands to run the app.
 # Commands to run the app.
+# The backend api url.
+API_URL = "http://localhost:8000"
+# The default path where bun is installed.
+BUN_PATH = "$HOME/.bun/bin/bun"
 # Command to install bun.
 # Command to install bun.
 INSTALL_BUN = "curl https://bun.sh/install | bash"
 INSTALL_BUN = "curl https://bun.sh/install | bash"
 # Command to run the backend in dev mode.
 # Command to run the backend in dev mode.
@@ -94,6 +98,8 @@ FRONTEND_ZIP = "frontend.zip"
 BACKEND_ZIP = "backend.zip"
 BACKEND_ZIP = "backend.zip"
 # The name of the sqlite database.
 # The name of the sqlite database.
 DB_NAME = "pynecone.db"
 DB_NAME = "pynecone.db"
+# The sqlite url.
+DB_URL = f"sqlite:///{DB_NAME}"
 # The default title to show for Pynecone apps.
 # The default title to show for Pynecone apps.
 DEFAULT_TITLE = "Pynecone App"
 DEFAULT_TITLE = "Pynecone App"
 # The name of the pynecone config module.
 # The name of the pynecone config module.

+ 2 - 0
pyproject.toml

@@ -21,6 +21,7 @@ sqlmodel = "^0.0.6"
 typer = "^0.4.1"
 typer = "^0.4.1"
 uvicorn = "^0.17.6"
 uvicorn = "^0.17.6"
 rich = "^12.6.0"
 rich = "^12.6.0"
+redis = "^4.3.5"
 
 
 [tool.poetry.dev-dependencies]
 [tool.poetry.dev-dependencies]
 pytest = "^7.1.2"
 pytest = "^7.1.2"
@@ -31,6 +32,7 @@ toml = "^0.10.2"
 isort = "^5.10.1"
 isort = "^5.10.1"
 pylint = "^2.14.5"
 pylint = "^2.14.5"
 pytest-asyncio = "^0.20.1"
 pytest-asyncio = "^0.20.1"
+black = "^22.10.0"
 
 
 [tool.poetry.scripts]
 [tool.poetry.scripts]
 pc = "pynecone.pc:main"
 pc = "pynecone.pc:main"