diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 0260cb6a..43fe719d 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -11,7 +11,7 @@ defaults: jobs: prepare-release: - runs-on: ubuntu-latest-8core + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 782cc634..5c605299 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -10,7 +10,7 @@ defaults: jobs: publish-release: - runs-on: ubuntu-latest-8core + runs-on: ubuntu-latest permissions: id-token: write contents: read diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index 62cc4f2f..b7f51d52 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -14,7 +14,7 @@ defaults: jobs: publish-snapshot: - runs-on: ubuntu-latest-8core + runs-on: ubuntu-latest permissions: contents: read id-token: write diff --git a/.github/workflows/publish-unstable.yml b/.github/workflows/publish-unstable.yml index 6eeae7fb..89a0e2b8 100644 --- a/.github/workflows/publish-unstable.yml +++ b/.github/workflows/publish-unstable.yml @@ -12,7 +12,7 @@ on: jobs: publish-unstable: - runs-on: ubuntu-latest-8core + runs-on: ubuntu-latest permissions: id-token: write contents: read diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e732efc..785b7cbb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ on: jobs: BuildAndTest: - runs-on: ubuntu-latest-8core + runs-on: ubuntu-latest env: MINICONDA_PYTHON_VERSION: py38 MINICONDA_VERSION: 4.11.0 diff --git a/core/tests/index.html b/core/tests/index.html index 9ae674b8..97385367 100644 --- a/core/tests/index.html +++ b/core/tests/index.html @@ -14,5 +14,5 @@ a:hover { opacity: 1; } - + diff --git a/core/tests/javascript/workers/create_named/index.html b/core/tests/javascript/workers/create_named/index.html new file mode 100644 index 00000000..faedf304 --- /dev/null +++ b/core/tests/javascript/workers/create_named/index.html @@ -0,0 +1,18 @@ + + + + mpy using py named worker + + + + + + + + diff --git a/core/tests/javascript/workers/index.html b/core/tests/javascript/workers/index.html deleted file mode 100644 index 99b61efc..00000000 --- a/core/tests/javascript/workers/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - diff --git a/core/tests/javascript/workers/mpy/index.html b/core/tests/javascript/workers/mpy/index.html new file mode 100644 index 00000000..31d74920 --- /dev/null +++ b/core/tests/javascript/workers/mpy/index.html @@ -0,0 +1,16 @@ + + + + mpy using py named worker + + + + + + + + + diff --git a/core/tests/javascript/workers/named.html b/core/tests/javascript/workers/named.html deleted file mode 100644 index 6079becc..00000000 --- a/core/tests/javascript/workers/named.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - named workers - - - - - - - - diff --git a/core/tests/javascript/workers/py/index.html b/core/tests/javascript/workers/py/index.html new file mode 100644 index 00000000..46c2117f --- /dev/null +++ b/core/tests/javascript/workers/py/index.html @@ -0,0 +1,16 @@ + + + + py using mpy named worker + + + + + + + + + diff --git a/core/tests/javascript/workers/test.py b/core/tests/javascript/workers/test.py index 55a99a42..08b5dc70 100644 --- a/core/tests/javascript/workers/test.py +++ b/core/tests/javascript/workers/test.py @@ -1,19 +1,13 @@ from pyscript import document, workers -async def test(interpreter): - # accessed as item - named = await workers.micropython_version +async def test(name): + # retrieve sync utilities from the named worker + 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(document.createElement("hr")) - # accessed as attribute - named = await workers["pyodide_version"] - - version = await named.pyodide_version() - document.body.append(version) - document.body.append(document.createElement("hr")) - - document.documentElement.classList.add(interpreter) + # flag the expectations around name done + document.documentElement.classList.add(name) diff --git a/core/tests/javascript/workers/worker.py b/core/tests/javascript/workers/worker.py index 59b78330..915f1cd0 100644 --- a/core/tests/javascript/workers/worker.py +++ b/core/tests/javascript/workers/worker.py @@ -1,7 +1,7 @@ -def micropython_version(): +def runtime_version(): import sys return sys.version -__export__ = ["micropython_version"] +__export__ = ['runtime_version'] diff --git a/core/tests/js_tests.spec.js b/core/tests/js_tests.spec.js index 06623859..aff590e0 100644 --- a/core/tests/js_tests.spec.js +++ b/core/tests/js_tests.spec.js @@ -95,9 +95,19 @@ test('MicroPython + JS Storage', async ({ page }) => { await page.waitForSelector('html.ok'); }); -test('MicroPython + workers', async ({ page }) => { - await page.goto('http://localhost:8080/tests/javascript/workers/index.html'); - await page.waitForSelector('html.mpy.py'); +test('MicroPython using named Pyodide Worker', async ({ page }) => { + await page.goto('http://localhost:8080/tests/javascript/workers/mpy/index.html'); + 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 }) => { diff --git a/core/types/core.d.ts b/core/types/core.d.ts index c7c72922..6c2ac1c2 100644 --- a/core/types/core.d.ts +++ b/core/types/core.d.ts @@ -55,5 +55,5 @@ declare const exportedHooks: { }; }; declare const exportedConfig: {}; -declare const exportedWhenDefined: any; +declare const exportedWhenDefined: (type: string) => Promise; export { stdlib, optional, inputFailure, TYPES, relative_url, exportedPyWorker as PyWorker, exportedMPWorker as MPWorker, exportedHooks as hooks, exportedConfig as config, exportedWhenDefined as whenDefined };