mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Refactor named workers test to avoid circular dependencies + free CI (#2212)
* Refactor named workers test to avoid circular dependencies + free CI
This commit is contained in:
committed by
GitHub
parent
febbb031ac
commit
a6b6dd8479
2
.github/workflows/prepare-release.yml
vendored
2
.github/workflows/prepare-release.yml
vendored
@@ -11,7 +11,7 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare-release:
|
prepare-release:
|
||||||
runs-on: ubuntu-latest-8core
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
2
.github/workflows/publish-release.yml
vendored
2
.github/workflows/publish-release.yml
vendored
@@ -10,7 +10,7 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-release:
|
publish-release:
|
||||||
runs-on: ubuntu-latest-8core
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
2
.github/workflows/publish-snapshot.yml
vendored
2
.github/workflows/publish-snapshot.yml
vendored
@@ -14,7 +14,7 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-snapshot:
|
publish-snapshot:
|
||||||
runs-on: ubuntu-latest-8core
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|||||||
2
.github/workflows/publish-unstable.yml
vendored
2
.github/workflows/publish-unstable.yml
vendored
@@ -12,7 +12,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-unstable:
|
publish-unstable:
|
||||||
runs-on: ubuntu-latest-8core
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write
|
id-token: write
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@@ -18,7 +18,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
BuildAndTest:
|
BuildAndTest:
|
||||||
runs-on: ubuntu-latest-8core
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
MINICONDA_PYTHON_VERSION: py38
|
MINICONDA_PYTHON_VERSION: py38
|
||||||
MINICONDA_VERSION: 4.11.0
|
MINICONDA_VERSION: 4.11.0
|
||||||
|
|||||||
@@ -14,5 +14,5 @@
|
|||||||
a:hover { opacity: 1; }
|
a:hover { opacity: 1; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body><ul><li><strong><span>javascript</span></strong><ul><li><a href="./javascript/async-listener.html">async-listener<small>.html</small></a></li><li><a href="./javascript/config-url.html">config-url<small>.html</small></a></li><li><a href="./javascript/config_type.html">config_type<small>.html</small></a></li><li><strong><a href="./javascript/fetch/index.html">fetch</a></strong></li><li><a href="./javascript/ffi.html">ffi<small>.html</small></a></li><li><a href="./javascript/hooks.html">hooks<small>.html</small></a></li><li><strong><a href="./javascript/issue-2093/index.html">issue-2093</a></strong></li><li><a href="./javascript/js-storage.html">js-storage<small>.html</small></a></li><li><a href="./javascript/js_modules.html">js_modules<small>.html</small></a></li><li><strong><a href="./javascript/loader/index.html">loader</a></strong></li><li><a href="./javascript/mpy.html">mpy<small>.html</small></a></li><li><a href="./javascript/py-terminal-main.html">py-terminal-main<small>.html</small></a></li><li><a href="./javascript/py-terminal-worker.html">py-terminal-worker<small>.html</small></a></li><li><a href="./javascript/py-terminal.html">py-terminal<small>.html</small></a></li><li><a href="./javascript/py-terminals.html">py-terminals<small>.html</small></a></li><li><strong><a href="./javascript/pyodide-cache/index.html">pyodide-cache</a></strong></li><li><a href="./javascript/storage.html">storage<small>.html</small></a></li><li><strong><a href="./javascript/workers/index.html">workers</a></strong><ul><li><a href="./javascript/workers/named.html">named<small>.html</small></a></li></ul></li></ul></li><li><strong><a href="./manual/index.html">manual</a></strong><ul><li><a href="./manual/all-done.html">all-done<small>.html</small></a></li><li><a href="./manual/async.html">async<small>.html</small></a></li><li><a href="./manual/camera.html">camera<small>.html</small></a></li><li><a href="./manual/click.html">click<small>.html</small></a></li><li><a href="./manual/code-a-part.html">code-a-part<small>.html</small></a></li><li><a href="./manual/combo.html">combo<small>.html</small></a></li><li><a href="./manual/config.html">config<small>.html</small></a></li><li><a href="./manual/create-element.html">create-element<small>.html</small></a></li><li><a href="./manual/dialog.html">dialog<small>.html</small></a></li><li><a href="./manual/display.html">display<small>.html</small></a></li><li><strong><a href="./manual/donkey/index.html">donkey</a></strong></li><li><a href="./manual/error.html">error<small>.html</small></a></li><li><a href="./manual/html-decode.html">html-decode<small>.html</small></a></li><li><a href="./manual/input.html">input<small>.html</small></a></li><li><a href="./manual/interpreter.html">interpreter<small>.html</small></a></li><li><strong><a href="./manual/issue-7015/index.html">issue-7015</a></strong></li><li><a href="./manual/multi.html">multi<small>.html</small></a></li><li><a href="./manual/multiple-editors.html">multiple-editors<small>.html</small></a></li><li><a href="./manual/no-error.html">no-error<small>.html</small></a></li><li><strong><a href="./manual/no_sab/index.html">no_sab</a></strong></li><li><strong><a href="./manual/piratical/index.html">piratical</a></strong></li><li><a href="./manual/py-editor.html">py-editor<small>.html</small></a></li><li><a href="./manual/py-editor-failure.html">py-editor-failure<small>.html</small></a></li><li><strong><a href="./manual/py-terminals/index.html">py-terminals</a></strong><ul><li><a href="./manual/py-terminals/no-repl.html">no-repl<small>.html</small></a></li><li><a href="./manual/py-terminals/repl.html">repl<small>.html</small></a></li></ul></li><li><a href="./manual/py_modules.html">py_modules<small>.html</small></a></li><li><strong><a href="./manual/service-worker/index.html">service-worker</a></strong></li><li><a href="./manual/split-config.html">split-config<small>.html</small></a></li><li><a href="./manual/submit.html">submit<small>.html</small></a></li><li><a href="./manual/target.html">target<small>.html</small></a></li><li><a href="./manual/test_display_HTML.html">test_display_HTML<small>.html</small></a></li><li><a href="./manual/test_when.html">test_when<small>.html</small></a></li><li><a href="./manual/worker.html">worker<small>.html</small></a></li></ul></li><li><strong><a href="./python/index.html">python</a></strong></li></ul></body>
|
<body><ul><li><strong><span>javascript</span></strong><ul><li><a href="./javascript/async-listener.html">async-listener<small>.html</small></a></li><li><a href="./javascript/config-url.html">config-url<small>.html</small></a></li><li><a href="./javascript/config_type.html">config_type<small>.html</small></a></li><li><strong><a href="./javascript/fetch/index.html">fetch</a></strong></li><li><a href="./javascript/ffi.html">ffi<small>.html</small></a></li><li><a href="./javascript/hooks.html">hooks<small>.html</small></a></li><li><strong><a href="./javascript/issue-2093/index.html">issue-2093</a></strong></li><li><a href="./javascript/js-storage.html">js-storage<small>.html</small></a></li><li><a href="./javascript/js_modules.html">js_modules<small>.html</small></a></li><li><strong><a href="./javascript/loader/index.html">loader</a></strong></li><li><a href="./javascript/mpy.html">mpy<small>.html</small></a></li><li><a href="./javascript/py-terminal-main.html">py-terminal-main<small>.html</small></a></li><li><a href="./javascript/py-terminal-worker.html">py-terminal-worker<small>.html</small></a></li><li><a href="./javascript/py-terminal.html">py-terminal<small>.html</small></a></li><li><a href="./javascript/py-terminals.html">py-terminals<small>.html</small></a></li><li><strong><a href="./javascript/pyodide-cache/index.html">pyodide-cache</a></strong></li><li><a href="./javascript/storage.html">storage<small>.html</small></a></li><li><strong><span>workers</span></strong><ul><li><strong><a href="./javascript/workers/mpy/index.html">mpy</a></strong></li><li><strong><a href="./javascript/workers/py/index.html">py</a></strong></li></ul></li></ul></li><li><strong><a href="./manual/index.html">manual</a></strong><ul><li><a href="./manual/all-done.html">all-done<small>.html</small></a></li><li><a href="./manual/async.html">async<small>.html</small></a></li><li><a href="./manual/camera.html">camera<small>.html</small></a></li><li><a href="./manual/click.html">click<small>.html</small></a></li><li><a href="./manual/code-a-part.html">code-a-part<small>.html</small></a></li><li><a href="./manual/combo.html">combo<small>.html</small></a></li><li><a href="./manual/config.html">config<small>.html</small></a></li><li><a href="./manual/create-element.html">create-element<small>.html</small></a></li><li><a href="./manual/dialog.html">dialog<small>.html</small></a></li><li><a href="./manual/display.html">display<small>.html</small></a></li><li><strong><a href="./manual/donkey/index.html">donkey</a></strong></li><li><a href="./manual/error.html">error<small>.html</small></a></li><li><a href="./manual/html-decode.html">html-decode<small>.html</small></a></li><li><a href="./manual/input.html">input<small>.html</small></a></li><li><a href="./manual/interpreter.html">interpreter<small>.html</small></a></li><li><strong><a href="./manual/issue-7015/index.html">issue-7015</a></strong></li><li><a href="./manual/multi.html">multi<small>.html</small></a></li><li><a href="./manual/multiple-editors.html">multiple-editors<small>.html</small></a></li><li><a href="./manual/no-error.html">no-error<small>.html</small></a></li><li><strong><a href="./manual/no_sab/index.html">no_sab</a></strong></li><li><strong><a href="./manual/piratical/index.html">piratical</a></strong></li><li><a href="./manual/py-editor.html">py-editor<small>.html</small></a></li><li><a href="./manual/py-editor-failure.html">py-editor-failure<small>.html</small></a></li><li><strong><a href="./manual/py-terminals/index.html">py-terminals</a></strong><ul><li><a href="./manual/py-terminals/no-repl.html">no-repl<small>.html</small></a></li><li><a href="./manual/py-terminals/repl.html">repl<small>.html</small></a></li></ul></li><li><a href="./manual/py_modules.html">py_modules<small>.html</small></a></li><li><strong><a href="./manual/service-worker/index.html">service-worker</a></strong></li><li><a href="./manual/split-config.html">split-config<small>.html</small></a></li><li><a href="./manual/submit.html">submit<small>.html</small></a></li><li><a href="./manual/target.html">target<small>.html</small></a></li><li><a href="./manual/test_display_HTML.html">test_display_HTML<small>.html</small></a></li><li><a href="./manual/test_when.html">test_when<small>.html</small></a></li><li><a href="./manual/worker.html">worker<small>.html</small></a></li></ul></li><li><strong><a href="./python/index.html">python</a></strong></li></ul></body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
18
core/tests/javascript/workers/create_named/index.html
Normal file
18
core/tests/javascript/workers/create_named/index.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>mpy using py named worker</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<script type="module" src="../../../../dist/core.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="mpy" config="../config.toml">
|
||||||
|
from pyscript import create_named_worker
|
||||||
|
await create_named_worker("../worker.py", name="pyodide_version", type="py")
|
||||||
|
|
||||||
|
from test import test
|
||||||
|
await test("pyodide_version")
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
||||||
<script type="module" src="../../../dist/core.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script type="mpy" async>
|
|
||||||
from pyscript import create_named_worker
|
|
||||||
|
|
||||||
await create_named_worker("./worker.py", name="micropython_version", type="mpy")
|
|
||||||
</script>
|
|
||||||
<script type="mpy" config="./config.toml" async>
|
|
||||||
from test import test
|
|
||||||
await test("mpy")
|
|
||||||
</script>
|
|
||||||
<script type="py" config="./config.toml" async>
|
|
||||||
from test import test
|
|
||||||
await test("py")
|
|
||||||
</script>
|
|
||||||
<script type="py" name="pyodide_version" worker>
|
|
||||||
def pyodide_version():
|
|
||||||
import sys
|
|
||||||
return sys.version
|
|
||||||
|
|
||||||
__export__ = ['pyodide_version']
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
16
core/tests/javascript/workers/mpy/index.html
Normal file
16
core/tests/javascript/workers/mpy/index.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>mpy using py named worker</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<script type="module" src="../../../../dist/core.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="mpy" config="../config.toml">
|
||||||
|
from test import test
|
||||||
|
await test("pyodide_version")
|
||||||
|
</script>
|
||||||
|
<script type="py" src="../worker.py" name="pyodide_version" worker></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
||||||
<title>named workers</title>
|
|
||||||
<script type="module" src="../../../dist/core.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script type="mpy" async>
|
|
||||||
from pyscript import workers
|
|
||||||
|
|
||||||
await (await workers["mpy"]).greetings()
|
|
||||||
await (await workers["py"]).greetings()
|
|
||||||
</script>
|
|
||||||
<script type="mpy" worker name="mpy">
|
|
||||||
def greetings():
|
|
||||||
print("micropython")
|
|
||||||
|
|
||||||
__export__ = ['greetings']
|
|
||||||
</script>
|
|
||||||
<script type="py" worker name="py">
|
|
||||||
def greetings():
|
|
||||||
print("pyodide")
|
|
||||||
|
|
||||||
__export__ = ['greetings']
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
16
core/tests/javascript/workers/py/index.html
Normal file
16
core/tests/javascript/workers/py/index.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>py using mpy named worker</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
<script type="module" src="../../../../dist/core.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="py" config="../config.toml">
|
||||||
|
from test import test
|
||||||
|
await test("micropython_version")
|
||||||
|
</script>
|
||||||
|
<script type="mpy" src="../worker.py" name="micropython_version" worker></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,19 +1,13 @@
|
|||||||
from pyscript import document, workers
|
from pyscript import document, workers
|
||||||
|
|
||||||
|
|
||||||
async def test(interpreter):
|
async def test(name):
|
||||||
# accessed as item
|
# retrieve sync utilities from the named worker
|
||||||
named = await workers.micropython_version
|
named = await workers[name]
|
||||||
|
|
||||||
version = await named.micropython_version()
|
# invoke the runtime_version __export__ + show it
|
||||||
|
version = await named.runtime_version()
|
||||||
document.body.append(version)
|
document.body.append(version)
|
||||||
document.body.append(document.createElement("hr"))
|
|
||||||
|
|
||||||
# accessed as attribute
|
# flag the expectations around name done
|
||||||
named = await workers["pyodide_version"]
|
document.documentElement.classList.add(name)
|
||||||
|
|
||||||
version = await named.pyodide_version()
|
|
||||||
document.body.append(version)
|
|
||||||
document.body.append(document.createElement("hr"))
|
|
||||||
|
|
||||||
document.documentElement.classList.add(interpreter)
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
def micropython_version():
|
def runtime_version():
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
return sys.version
|
return sys.version
|
||||||
|
|
||||||
|
|
||||||
__export__ = ["micropython_version"]
|
__export__ = ['runtime_version']
|
||||||
|
|||||||
@@ -95,9 +95,19 @@ test('MicroPython + JS Storage', async ({ page }) => {
|
|||||||
await page.waitForSelector('html.ok');
|
await page.waitForSelector('html.ok');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('MicroPython + workers', async ({ page }) => {
|
test('MicroPython using named Pyodide Worker', async ({ page }) => {
|
||||||
await page.goto('http://localhost:8080/tests/javascript/workers/index.html');
|
await page.goto('http://localhost:8080/tests/javascript/workers/mpy/index.html');
|
||||||
await page.waitForSelector('html.mpy.py');
|
await page.waitForSelector('html.pyodide_version');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('MicroPython creating a named Pyodide Worker', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:8080/tests/javascript/workers/create_named/index.html');
|
||||||
|
await page.waitForSelector('html.pyodide_version');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Pyodide using named MicroPython Worker', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:8080/tests/javascript/workers/py/index.html');
|
||||||
|
await page.waitForSelector('html.micropython_version');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('MicroPython Editor setup error', async ({ page }) => {
|
test('MicroPython Editor setup error', async ({ page }) => {
|
||||||
|
|||||||
2
core/types/core.d.ts
vendored
2
core/types/core.d.ts
vendored
@@ -55,5 +55,5 @@ declare const exportedHooks: {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
declare const exportedConfig: {};
|
declare const exportedConfig: {};
|
||||||
declare const exportedWhenDefined: any;
|
declare const exportedWhenDefined: (type: string) => Promise<object>;
|
||||||
export { stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };
|
export { stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };
|
||||||
|
|||||||
Reference in New Issue
Block a user