Skip to content

Commit ee56063

Browse files
committed
do not keep wasm files in git
1 parent 9a07bd0 commit ee56063

6 files changed

Lines changed: 113 additions & 1 deletion

File tree

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ tests/custom/
2121
tests/datastream/
2222
tests/webhook_utils/
2323
CLAUDE.md
24+
WASM_VERSION

.github/workflows/ci.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
- name: Bootstrap poetry
1414
run: |
1515
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
16+
- name: Download WASM binary
17+
run: ./scripts/download-wasm.sh
18+
env:
19+
GH_TOKEN: ${{ github.token }}
1620
- name: Install dependencies
1721
run: poetry install --extras datastream
1822
- name: Compile
@@ -29,14 +33,46 @@ jobs:
2933
- name: Bootstrap poetry
3034
run: |
3135
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
36+
- name: Download WASM binary
37+
run: ./scripts/download-wasm.sh
38+
env:
39+
GH_TOKEN: ${{ github.token }}
3240
- name: Install dependencies
3341
run: poetry install --extras datastream
3442

3543
- name: Test
3644
run: poetry run pytest -rP -n auto .
3745

46+
verify-package:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout repo
50+
uses: actions/checkout@v4
51+
- name: Set up python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: 3.9
55+
- name: Bootstrap poetry
56+
run: |
57+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
58+
- name: Download WASM binary
59+
run: ./scripts/download-wasm.sh
60+
env:
61+
GH_TOKEN: ${{ github.token }}
62+
- name: Build package
63+
run: poetry build
64+
- name: Verify WASM in wheel
65+
run: |
66+
if ! zipinfo dist/*.whl | grep -q 'rulesengine.wasm'; then
67+
echo "ERROR: rulesengine.wasm not found in wheel"
68+
echo "Wheel contents:"
69+
zipinfo dist/*.whl
70+
exit 1
71+
fi
72+
echo "Verified: rulesengine.wasm is included in the wheel"
73+
3874
publish:
39-
needs: [compile, test]
75+
needs: [compile, test, verify-package]
4076
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
4177
runs-on: ubuntu-latest
4278
steps:
@@ -49,6 +85,10 @@ jobs:
4985
- name: Bootstrap poetry
5086
run: |
5187
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
88+
- name: Download WASM binary
89+
run: ./scripts/download-wasm.sh
90+
env:
91+
GH_TOKEN: ${{ github.token }}
5292
- name: Install dependencies
5393
run: poetry install
5494
- name: Publish to pypi

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
__pycache__/
44
dist/
55
poetry.toml
6+
7+
# WASM binary (downloaded from rulesengine-rust GitHub Releases)
8+
src/schematic/datastream/wasm/rulesengine.wasm
9+
src/schematic/datastream/wasm/.wasm_version

WASM_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

scripts/download-wasm.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Downloads the rules engine WASM binary from the schematic-api GitHub Release.
5+
# Reads the pinned version from WASM_VERSION at the repo root.
6+
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
9+
WASM_DIR="$REPO_ROOT/src/schematic/datastream/wasm"
10+
VERSION_FILE="$REPO_ROOT/WASM_VERSION"
11+
TARGET_FILE="$WASM_DIR/rulesengine.wasm"
12+
13+
GITHUB_REPO="SchematicHQ/schematic-api"
14+
15+
if [ ! -f "$VERSION_FILE" ]; then
16+
echo "ERROR: WASM_VERSION file not found at $VERSION_FILE"
17+
exit 1
18+
fi
19+
20+
VERSION=$(tr -d '[:space:]' < "$VERSION_FILE")
21+
TAG="rulesengine/v${VERSION}"
22+
23+
# Skip download if binary already exists and version matches
24+
if [ -f "$TARGET_FILE" ] && [ -f "$WASM_DIR/.wasm_version" ]; then
25+
CURRENT=$(tr -d '[:space:]' < "$WASM_DIR/.wasm_version")
26+
if [ "$CURRENT" = "$VERSION" ]; then
27+
echo "WASM binary already at version $VERSION, skipping download."
28+
exit 0
29+
fi
30+
fi
31+
32+
ASSET_NAME="rulesengine-wasm-python-v${VERSION}.tar.gz"
33+
34+
echo "Downloading rules engine WASM v${VERSION}..."
35+
mkdir -p "$WASM_DIR"
36+
37+
TMPDIR=$(mktemp -d)
38+
trap 'rm -rf "$TMPDIR"' EXIT
39+
40+
if ! gh release download "$TAG" \
41+
-R "$GITHUB_REPO" \
42+
-p "$ASSET_NAME" \
43+
-D "$TMPDIR" 2>/dev/null; then
44+
echo "ERROR: Failed to download WASM binary"
45+
echo "Tag: $TAG"
46+
echo "Asset: $ASSET_NAME"
47+
echo ""
48+
echo "If this is a new version, ensure a release exists at:"
49+
echo " https://github.com/${GITHUB_REPO}/releases/tag/${TAG}"
50+
echo ""
51+
echo "Ensure the GitHub CLI is authenticated: gh auth status"
52+
exit 1
53+
fi
54+
55+
tar -xzf "$TMPDIR/$ASSET_NAME" -C "$TMPDIR"
56+
57+
if [ ! -f "$TMPDIR/rulesengine.wasm" ]; then
58+
echo "ERROR: rulesengine.wasm not found in release archive"
59+
ls -la "$TMPDIR"
60+
exit 1
61+
fi
62+
63+
cp "$TMPDIR/rulesengine.wasm" "$TARGET_FILE"
64+
echo "$VERSION" > "$WASM_DIR/.wasm_version"
65+
66+
echo "Downloaded rules engine WASM v${VERSION} to $TARGET_FILE"
-564 KB
Binary file not shown.

0 commit comments

Comments
 (0)