Преглед на файлове

allow custom bunfig.toml file (#4280)

* allow custom bunfig.toml file

* always copy custom bunfig

* split tests into half

* forgot a space

* use different syntax

* also split node latest check

* turn off failfast for app harness

---------

Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
Thomas Brandého преди 6 месеца
родител
ревизия
54b081c104
променени са 4 файла, в които са добавени 35 реда и са изтрити 19 реда
  1. 5 2
      .github/workflows/check_node_latest.yml
  2. 10 8
      .github/workflows/integration_app_harness.yml
  3. 5 0
      reflex/constants/installer.py
  4. 15 9
      reflex/utils/prerequisites.py

+ 5 - 2
.github/workflows/check_node_latest.yml

@@ -18,7 +18,10 @@ jobs:
         strategy:
             matrix:
                 python-version: ['3.12']
+                split_index: [1, 2]
                 node-version: ['node']
+            fail-fast: false
+
         steps:
             - uses: actions/checkout@v4
             - uses: ./.github/actions/setup_build_env
@@ -30,11 +33,11 @@ jobs:
               with:
                 node-version: ${{ matrix.node-version }}
             - run: |
-                poetry run uv pip install pyvirtualdisplay pillow
+                poetry run uv pip install pyvirtualdisplay pillow pytest-split
                 poetry run playwright install --with-deps
             - run: |
                 poetry run pytest tests/test_node_version.py
-                poetry run pytest tests/integration
+                poetry run pytest tests/integration --splits 2 --group ${{matrix.split_index}}
   
 
 

+ 10 - 8
.github/workflows/integration_app_harness.yml

@@ -6,13 +6,13 @@ concurrency:
 
 on:
   push:
-    branches: ['main']
+    branches: ["main"]
     paths-ignore:
-      - '**/*.md'
+      - "**/*.md"
   pull_request:
-    branches: ['main']
+    branches: ["main"]
     paths-ignore:
-      - '**/*.md'
+      - "**/*.md"
 
 permissions:
   contents: read
@@ -22,8 +22,10 @@ jobs:
     timeout-minutes: 30
     strategy:
       matrix:
-        state_manager: ['redis', 'memory']
-        python-version: ['3.11.5', '3.12.0']
+        state_manager: ["redis", "memory"]
+        split_index: [1, 2]
+        python-version: ["3.11.5", "3.12.0"]
+      fail-fast: false
     runs-on: ubuntu-22.04
     services:
       # Label used to access the service container
@@ -45,14 +47,14 @@ jobs:
           python-version: ${{ matrix.python-version }}
           run-poetry-install: true
           create-venv-at-path: .venv
-      - run: poetry run uv pip install pyvirtualdisplay pillow
+      - run: poetry run uv pip install pyvirtualdisplay pillow pytest-split
       - name: Run app harness tests
         env:
           SCREENSHOT_DIR: /tmp/screenshots
           REDIS_URL: ${{ matrix.state_manager == 'redis' && 'redis://localhost:6379' || '' }}
         run: |
           poetry run playwright install --with-deps
-          poetry run pytest tests/integration
+          poetry run pytest tests/integration --splits 2 --group ${{matrix.split_index}}
       - uses: actions/upload-artifact@v4
         name: Upload failed test screenshots
         if: always()

+ 5 - 0
reflex/constants/installer.py

@@ -75,6 +75,11 @@ class Bun(SimpleNamespace):
         """
         return cls.ROOT_PATH / "bin" / ("bun" if not IS_WINDOWS else "bun.exe")
 
+    DEFAULT_CONFIG = """
+[install]
+registry = {registry}
+"""
+
 
 # FNM config.
 class Fnm(SimpleNamespace):

+ 15 - 9
reflex/utils/prerequisites.py

@@ -598,6 +598,8 @@ def initialize_web_directory():
 
     initialize_package_json()
 
+    initialize_bun_config()
+
     path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC)
 
     update_next_config()
@@ -622,17 +624,21 @@ def _compile_package_json():
 def initialize_package_json():
     """Render and write in .web the package.json file."""
     output_path = get_web_dir() / constants.PackageJson.PATH
-    code = _compile_package_json()
-    output_path.write_text(code)
+    output_path.write_text(_compile_package_json())
+
 
-    best_registry = _get_npm_registry()
+def initialize_bun_config():
+    """Initialize the bun config file."""
     bun_config_path = get_web_dir() / constants.Bun.CONFIG_PATH
-    bun_config_path.write_text(
-        f"""
-[install]
-registry = "{best_registry}"
-"""
-    )
+
+    if (custom_bunfig := Path(constants.Bun.CONFIG_PATH)).exists():
+        bunfig_content = custom_bunfig.read_text()
+        console.info(f"Copying custom bunfig.toml inside {get_web_dir()} folder")
+    else:
+        best_registry = _get_npm_registry()
+        bunfig_content = constants.Bun.DEFAULT_CONFIG.format(registry=best_registry)
+
+    bun_config_path.write_text(bunfig_content)
 
 
 def init_reflex_json(project_hash: int | None):