Skip to content

Commit bb0e26f

Browse files
committed
Unit test
1 parent e2051d7 commit bb0e26f

File tree

5 files changed

+137
-9
lines changed

5 files changed

+137
-9
lines changed

.github/workflows/CI.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,30 @@ jobs:
152152
with:
153153
name: wheels-sdist
154154
path: dist
155+
156+
unit-test:
157+
name: Unit tests
158+
runs-on: ubuntu-latest
159+
strategy:
160+
matrix:
161+
version: ['3.10', '3.12']
162+
steps:
163+
- uses: actions/checkout@v4
164+
- uses: astral-sh/setup-uv@v3
165+
with:
166+
version: "latest"
167+
env:
168+
UV_PYTHON: ${{ matrix.version }}
169+
- name: Install vitessce
170+
run: uv sync --extra dev
171+
- name: Run tests
172+
run: uv run pytest
155173

156174
release:
157175
name: Release
158176
runs-on: ubuntu-latest
159177
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
160-
needs: [linux, musllinux, windows, macos, sdist]
178+
needs: [unit-test, linux, musllinux, windows, macos, sdist]
161179
permissions:
162180
# Use to sign the release artifacts
163181
id-token: write

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
11
# oxc-py
22

3+
## Usage
4+
5+
```py
6+
from oxc_py import transform
7+
8+
jsx = """
9+
import * as React from 'react'
10+
import * as ReactDOM from 'react-dom'
11+
12+
ReactDOM.render(
13+
<h1>Hello, world!</h1>,
14+
document.getElementById('root')
15+
);
16+
"""
17+
18+
print(transform(jsx))
19+
```
20+
21+
## Development
22+
23+
### Setup
24+
25+
```sh
26+
uv venv
27+
source .venv/bin/activate
28+
uv sync --extra dev
29+
```
30+
31+
### Test
32+
33+
```sh
34+
uv run pytest
35+
```
36+
37+
## Resources
38+
- https://github.com/keller-mark/esbuild-py
39+
- https://github.com/oxc-project/oxc/blob/71155cf575b6947bb0e85376d18375c2f3c50c73/crates/oxc_transformer/examples/transformer.rs
40+
- https://docs.rs/oxc_transformer/0.53.0/oxc_transformer/
41+
- https://www.maturin.rs/tutorial.html

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ classifiers = [
1111
"Programming Language :: Python :: Implementation :: PyPy",
1212
]
1313
dynamic = ["version"]
14-
dependencies = [
15-
"maturin>=1.8.2",
14+
dependencies = []
15+
16+
[project.optional-dependencies]
17+
dev = [
18+
'pytest>=6.2.4',
19+
"maturin>=1.8.2",
1620
]
21+
22+
1723
[tool.maturin]
1824
features = ["pyo3/extension-module"]

tests/test_transform.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ def test_jsx(self):
1818
expected = """
1919
import * as React from "react";
2020
import * as ReactDOM from "react-dom";
21-
ReactDOM.render(
22-
/* @__PURE__ */ React.createElement("h1", null, "Hello, world!"),
23-
document.getElementById("root")
24-
);
21+
ReactDOM.render(React.createElement("h1", null, "Hello, world!"), document.getElementById("root"));
2522
"""
2623
assert transform(jsx).strip() == expected.strip()

uv.lock

Lines changed: 70 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)