Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5635c1b
feat: Setup local testing with pytest
baalimago Sep 16, 2025
26265fb
feat: Added support for running tests in wasmer runtime
baalimago Sep 17, 2025
a943e0c
docs: Changed back formatting to not joink git blame
baalimago Sep 17, 2025
f22c676
docs: Added final step to run tests in wasmer
baalimago Sep 17, 2025
948d8cd
feat(debug): Added tests to pipeline as final step
baalimago Sep 17, 2025
fda3a22
revertme: Removed path requirement
baalimago Sep 17, 2025
e29005d
feat: Separated the workflow for reusability, fixed runner issue
baalimago Sep 17, 2025
79b03a3
fix: Correct path to workflow
baalimago Sep 17, 2025
9369961
tweak: Removed pyenv, shouldnt be needed
baalimago Sep 17, 2025
a13a800
fix: Install zbar since tests didnt want to pass without it
baalimago Sep 17, 2025
ecba365
feat: Ghetto-pytest refactor (aka compilation-station)
baalimago Sep 17, 2025
96e26b6
tweaks: Inject psql server details as env vars, spelling
baalimago Sep 17, 2025
2ea54f2
tweaks: Removed pytest from dependencies
baalimago Sep 18, 2025
bcdf4a3
feat: Converted project to be fastapi
baalimago Sep 18, 2025
e0107f9
refactor: It now deploys and runs on edge
baalimago Sep 18, 2025
24467a3
feat: Added <api>/check/<test> and added run-all-tests-via-api.py
baalimago Sep 18, 2025
3d89331
feat: Allow resolving IP to specific server on run-all-tests
baalimago Sep 18, 2025
4ee7f70
cleanup: PR comments
baalimago Sep 18, 2025
68ab11b
cleanup: Reset README oopsie overwrite
baalimago Sep 18, 2025
424cfb6
Apply suggestion from @zebreus
baalimago Sep 18, 2025
62348cd
cleanup: Moved new testing system into directory testing
baalimago Sep 18, 2025
250060c
cleanup: Removed try-catch on pysql and mysql tests to fish for linke…
baalimago Sep 18, 2025
a83b06f
tweaks: Test pipeline should in theory now work
baalimago Sep 18, 2025
7a4e785
tweaks: ... theory was incorrect, now it should work
baalimago Sep 18, 2025
d805739
fix: Paths should now be OK
baalimago Sep 18, 2025
e4dab79
fix: Path to wasmer
baalimago Sep 18, 2025
953ffe4
tweak: Fix path for running python tests natively
baalimago Sep 18, 2025
1ed415e
feat: Re-enable contine-on-error for native tests
baalimago Sep 18, 2025
fbcfe19
revert: Pipeline now runs only as last step of normal release
baalimago Sep 18, 2025
b3ea1a9
tweak: Reset formatting to not joink git blame on merge commit
baalimago Sep 18, 2025
b85f988
tweak: Updated "broken filter" in run-tests.sh
baalimago Sep 18, 2025
2bcfe10
feat: Added env var ALLOW_BROKEN to list broken tests
baalimago Sep 19, 2025
f889f33
tweaks: Final things while push to prod + compile, tweaked readme
baalimago Sep 19, 2025
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
16 changes: 15 additions & 1 deletion .github/workflows/generate-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,18 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4

test:
strategy:
matrix:
python-version: ["3.13"]
wasmer-version: ["v6.1.0-rc.3"]
uses: ./.github/workflows/test-python-index.yaml
with:
python-version: ${{ matrix.python-version }}
wasmer-version: ${{ matrix.wasmer-version }}
# Test primary python index only for now. This
# setup allows for hosting a separate "testing" python
# index down the line (or simply a local one)
python-index: https://pythonindex.wasix.org
65 changes: 65 additions & 0 deletions .github/workflows/test-python-index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Test Workflow

on:
workflow_call:
inputs:
python-version:
required: true
type: string
wasmer-version:
required: true
type: string
python-index:
required: true
type: string
ubuntu-runner:
required: false
type: string
default: "ubuntu-24.04"

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Setup environment
run: |
cd testing
sudo apt-get install libzbar0
pip install .
# Validate that the python tests themselves are valid
- name: Run tests natively
continue-on-error: true
run: |
cd testing
TEST_DIR=../tests/ python src/run-tests.py
# Secondly, validate that the tests pass within wasmer as well
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install wasmer
run: curl https://get.wasmer.io -sSfL | sh -s ${{ inputs.wasmer-version }}
- name: Setup project for wasmer
run: |
cd testing
uv pip compile pyproject.toml \
--python-version=${{ inputs.python-version }} \
--universal \
--extra-index-url ${{ inputs.python-index }}/simple \
--index-url=https://pypi.org/simple \
--emit-index-url \
--only-binary :all: \
-o wasmer-requirements.txt

uvx pip install -r wasmer-requirements.txt \
--python-version=${{ inputs.python-version }} \
--target wasix-site-packages \
--platform wasix_wasm32 \
--only-binary=:all: \
--compile
# Ensure tests pass on wasmer
- name: Run tests (wasmer)
run: cd testing && /home/runner/.wasmer/bin/wasmer run . --registry=wasmer.wtf --command-name=test --net
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ __pycache__
/pkgs/*.build
/pkgs/*.prepared
/pkgs/*.sysroot
wasix-site-packages
wasmer-requirements.txt
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,60 @@ psycopg3-c is just the sdist of psycopg3-binary
* This is the commit that is currently used by wasix-libc
<!-- LIB_VERSIONS_END -->

## Tests

The whole point of these tests is to ensure that the packages works within the wasmer runtime.
So there are two ways of running the tests, natively and with wasmer:

### Native

Requirements:

- Python 3.13
- `python -m venv env`
- `source venv/bin/activate`
- `pip install .`
- `pip install pytest`

I'm sure it's possible to do via uv, or poetry, or many other ways. But this works also.

Run tests:

- `python -m pytest`
- Discovers files matching `*-test.py`, `*_test.py`, and `test_*.py` under `tests/`.
- Files ending with `.skip.py` are ignored.
- Files ending with `-broken.py` are marked as expected failures (strict). If they pass, the run reports XPASS and fails.

### Wasmer

These are the instructions as of 2025-10, but there's a shipit looming, which may optimize the flow.

Requirements:

- wasmer 6.1.0-rc.3+

Run tests:

- `cd testing`
- `uv pip compile pyproject.toml --python-version=3.13 --universal --extra-index-url https://pythonindex.wasix.org/simple --index-url=https://pypi.org/simple --emit-index-url --only-binary :all: -o wasmer-requirements.txt`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may be able to convert the test script to a PEP 723 script with URL based specifiers. That way we should be able to just uv run the tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know what that means or how it would work. These preconditionals are just copy-pasted from what Syrus had in the fastapi template.

I vote for out of scope/future improvement!

- `uvx pip install -r wasmer-requirements.txt --target wasix-site-packages --platform wasix_wasm32 --only-binary=:all: --python-version=3.13 --compile`
- `TEST_DIR=../tests/ wasmer run . --registry=wasmer.wtf --net --forward-host-env`
- `curl localhost:8081/check`

This will run all tests via fastapi.

You may also run each test individually by:

- `curl localhost:8081/list`
- `curl localhost:8081/check/<test-file>`

This is needed when testing on edge, since `.../check` times out the workload.
In conjunction with this, there is a convenience script which runs all tests each in a separate query.

So you may also run `./run-all-tests-via-api.py --host <hostname> --port <port>`.
If you need to hit a specific IP while preserving the original hostname (e.g., for edge testing or custom DNS), use `--resolve-ip <ip>` which is SNI-compatible for HTTPS and sets the HTTP `Host` header accordingly.
This is intended to be run to validate package functionaltiy on edge, as each test becomes a separate workload.

### Notes

All built library packages should include a pkg-config file for each library.
Expand Down
5 changes: 5 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: build-scripts
app_id: da_nm3IetwU74x2
owner: wasmer
package: '.'
kind: wasmer.io/App.v0
2 changes: 1 addition & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for testfile in tests/*.py; do
fi

EXPECT_BROKEN=false
if [[ "$TEST_NAME" == *-broken.py ]]; then
if [[ "$TEST_NAME" == *\.broken.py ]]; then
EXPECT_BROKEN=true
fi

Expand Down
5 changes: 5 additions & 0 deletions testing/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: wasmer.io/App.v0
name: build-scripts
owner: lorentz-dev
package: .
app_id: da_2OPIqt7UeOLK
79 changes: 79 additions & 0 deletions testing/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "wasmer-build-scripts"
version = "0.0.0"
description = "Test scaffolding for build-scripts; runs tests via pytest."
readme = "README.md"
requires-python = ">=3.13"
authors = [{ name = "Wasmer contributors" }]
dependencies = [
"annotated-types",
"brotlicffi",
"certifi",
"cffi",
"charset-normalizer",
"cryptography",
"google-crc32c",
"fastapi>=0.116.1",
"idna",
"jiter",
"lxml",
"MarkupSafe",
"msgpack",
"mysqlclient",
"numpy",
"orjson",
"pandas",
"Pillow",
"protobuf",
"psycopg[binary]",
"pycparser",
"pycryptodome",
"pycryptodomex",
"pydantic>=2",
"PyNaCl",
"pyOpenSSL",
"pypandoc",
"pypng",
"pyzbar",
"qrcode",
"regex",
"requests",
"rpds-py",
"shapely",
"six",
"tiktoken",
"typing-inspection",
"typing_extensions",
"tzdata",
"urllib3",
"uvloop",
"uvicorn>=0.35.0",
"python-dateutil",
"psycopg",
"psycopg_pool",
"pytz",
"PyYAML",
"svgwrite",
]

[tool.setuptools.packages.find]
include = []
exclude = ["*"]


[tool.pytest.ini_options]
python_files = ["*-test.py", "*_test.py", "test_*.py"]
addopts = ["-q"]
testpaths = ["tests"]

[[tool.uv.index]]
# A human-friendly name you pick
name = "wasix"
# The Simple index URL
url = "https://wasix-org.github.io/build-scripts/simple"
# Optional – make this the primary index
default = true
Loading