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>
This commit is contained in:
Thomas Brandého 2024-11-06 09:31:13 -08:00 committed by GitHub
parent 8d5187432f
commit 54b081c104
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 19 deletions

View File

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

View File

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

View File

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

View File

@ -598,6 +598,8 @@ def initialize_web_directory():
initialize_package_json() initialize_package_json()
initialize_bun_config()
path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC) path_ops.mkdir(get_web_dir() / constants.Dirs.PUBLIC)
update_next_config() update_next_config()
@ -622,17 +624,21 @@ def _compile_package_json():
def initialize_package_json(): def initialize_package_json():
"""Render and write in .web the package.json file.""" """Render and write in .web the package.json file."""
output_path = get_web_dir() / constants.PackageJson.PATH output_path = get_web_dir() / constants.PackageJson.PATH
code = _compile_package_json() output_path.write_text(_compile_package_json())
output_path.write_text(code)
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 = get_web_dir() / constants.Bun.CONFIG_PATH
bun_config_path.write_text(
f""" if (custom_bunfig := Path(constants.Bun.CONFIG_PATH)).exists():
[install] bunfig_content = custom_bunfig.read_text()
registry = "{best_registry}" 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): def init_reflex_json(project_hash: int | None):