Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,47 @@ jobs:
steps:
- uses: actions/checkout@v2


- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1


- name: apt-install
run: |
sudo apt-get update -y && sudo apt-get install -y \
libwoff1 libvpx9 libevent-2.1-7t64 libopus0 libgstreamer-plugins-base1.0-0 \
libgstreamer-gl1.0-0 \
libgstreamer-plugins-bad1.0-0 \
libflite1 \
libavif16 \
libharfbuzz-icu0 \
libsecret-1-0 \
libhyphen0 \
libmanette-0.2-0 \
libgles2 \
gstreamer1.0-libav

- name: Install mamba
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v2
with:
environment-file: dev-env.yml
environment-name: dev-env
micromamba-version: "1.4.1"

init-shell: >-
bash

- name: Install Playwright
shell: bash -el {0}
run: |
playwright install

- name: Install pyjs-code-runner
shell: bash -el {0}
run: |
micromamba activate dev-env
python -m pip install . --no-deps

- name: Run Tests
shell: bash -el {0}
run: |
micromamba activate dev-env
pytest -s
pytest -s -vvvvv


test_with_pip:
Expand All @@ -50,20 +68,34 @@ jobs:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1

- name: apt-install
run: |
sudo apt-get update -y && sudo apt-get install -y \
libwoff1 libvpx9 libevent-2.1-7t64 libopus0 libgstreamer-plugins-base1.0-0 \
libgstreamer-gl1.0-0 \
libgstreamer-plugins-bad1.0-0 \
libflite1 \
libavif16 \
libharfbuzz-icu0 \
libsecret-1-0 \
libhyphen0 \
libmanette-0.2-0 \
libgles2 \
gstreamer1.0-libav

- name: Install mamba
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v2
with:
environment-file: dev-env-pip.yml
environment-name: dev-env
micromamba-version: "1.4.1"

- name: Install pyjs-code-runner
shell: bash -el {0}
run: |
micromamba activate dev-env
python -m pip install .
playwright install

- name: Run Tests
shell: bash -el {0}
run: |
micromamba activate dev-env
pytest -s
pytest -s -vvvvv
8 changes: 6 additions & 2 deletions dev-env-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ channels:
dependencies:
- python
- pip
- emsdk
- pytest
- pytest
- pytest-sugar
- typer
- appdirs
- empack >=3,<4
- rich
3 changes: 2 additions & 1 deletion dev-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ dependencies:
- python
- pip
- pytest
- pytest-sugar
- typer
- appdirs
- empack >=3,<4
- microsoft::playwright
- emsdk
- rich
- rich
8 changes: 7 additions & 1 deletion pyjs_code_runner/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ function eval_main_script(pyjs, workdir, filename) {
return 0;
}
catch (e) {
console.error("error while evaluating main file:", e)
if (typeof e === "number") {
const msg = get_exception_message(e);
console.error("error while evaluating main file:", msg)
}
else {
console.error("error while evaluating main file:", e)
}
return 1;
}
return 0
Expand Down
13 changes: 4 additions & 9 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@
from typer.testing import CliRunner
import os

# @pytest.fixture(scope="session")
# def session_temp_path(tmp_path_factory):
# return tmp_path_factory.mktemp()

ON_GITHUB_ACTIONS = False
if "GITHUB_ACTION" in os.environ:
ON_GITHUB_ACTIONS = True


@pytest.fixture(scope="session")
def env_prefix():
env_root = Path(appdirs.user_data_dir("pytest_code_runner_tests", "DerThorsten"))
env_root.mkdir(exist_ok=True, parents=True)
def env_prefix(tmp_path_factory):

env_root = tmp_path_factory.mktemp("pytest_code_runner_tests")
env_prefix = Path(env_root) / "testenv"

if env_prefix.exists():
shutil.rmtree(env_prefix)

print("prefix", env_prefix)
channels = (
"-c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge"
)
cmd = [
f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs """
f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs>=2.7.0"""
]

ret = subprocess.run(cmd, shell=True)
Expand Down
1 change: 1 addition & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_help(self, runner):
def test_sync_err(
self, env_prefix, em_work_dir, backend_cli_settings, tmpdir, runner
):

backend_type, backend_args = backend_cli_settings

to_mount_dir = tmpdir
Expand Down
Loading