Skip to content

Commit 7a821c2

Browse files
authored
feat: add ci workflow (#1)
1 parent 984f855 commit 7a821c2

4 files changed

Lines changed: 83 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
10+
jobs:
11+
getPackages:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
matrix: ${{ env.matrix }}
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
- id: set-matrix
19+
run: echo "matrix=$(./scripts/getPackages.sh)" >> $GITHUB_ENV
20+
build:
21+
runs-on: ubuntu-latest
22+
needs:
23+
- getPackages
24+
strategy:
25+
matrix: ${{fromJSON(needs.getPackages.outputs.matrix)}}
26+
defaults:
27+
run:
28+
working-directory: ./packages/${{ matrix.package }}
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v3
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.10"
36+
- name: Install poetry
37+
run: curl -sSL https://install.python-poetry.org | python3 -
38+
- name: Install dependencies
39+
run: poetry install
40+
- name: Typecheck
41+
run: poetry run tox -e typecheck
42+
# FIXME: make this work
43+
# - name: Lint
44+
# run: poetry run tox -e lint
45+
# - name: Security
46+
# run: poetry run tox -e secure
47+
- name: Test
48+
run: poetry run tox

packages/polywrap-wasm/polywrap_wasm/wasm_package.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from typing import Optional, Union
22

33
from polywrap_core import IFileReader, IWasmPackage, Wrapper
44

@@ -22,10 +22,11 @@ def __init__(
2222
)
2323

2424
async def get_wasm_module(self) -> bytearray:
25-
self.wasm_module = self.wasm_module or await self.file_reader.read_file(
25+
wasm_module: bytearray = self.wasm_module or await self.file_reader.read_file(
2626
WRAP_MODULE_PATH
2727
)
28-
return self.wasm_module
28+
self.wasm_module = wasm_module
29+
return wasm_module
2930

3031
def create_wrapper(self) -> Wrapper:
3132
return WasmWrapper(self.file_reader, self.wasm_module)

packages/polywrap-wasm/polywrap_wasm/wasm_wrapper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from textwrap import dedent
12
from typing import Optional, Union
23

34
from polywrap_core import (
@@ -60,6 +61,18 @@ async def invoke(self, options: InvokeOptions, invoker: Invoker) -> InvocableRes
6061
else msgpack_encode(options.env)
6162
)
6263

64+
if not (state.method and state.args and state.env):
65+
raise ValueError(
66+
dedent(
67+
"""
68+
Expected invocation state to be definied got:
69+
method: ${state.method}
70+
args: ${state.args}
71+
env: ${state.env}
72+
"""
73+
)
74+
)
75+
6376
method_length = len(state.method)
6477
args_length = len(state.args)
6578
env_length = len(state.env)

scripts/getPackages.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function joinByString() {
2+
local separator="$1"
3+
shift
4+
local first="$1"
5+
shift
6+
printf "%s" "$first" "${@/#/$separator}"
7+
}
8+
9+
packages_arr=($(ls packages))
10+
# classic for-loop
11+
for ((idx=0; idx < ${#packages_arr[@]}; ++idx)); do
12+
# act on ${packages_arr[$idx]}
13+
packages_arr[$idx]="\"${packages_arr[$idx]}\""
14+
done
15+
16+
packages_str=$(joinByString ', ' ${packages_arr[@]})
17+
packages_json="{ \"package\": [ ${packages_str} ] }"
18+
echo $packages_json

0 commit comments

Comments
 (0)