Skip to content

Commit aa91509

Browse files
author
zach
authored
ci: add test/release workflows (#1)
1 parent 4be4048 commit aa91509

File tree

6 files changed

+122
-2
lines changed

6 files changed

+122
-2
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Release
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
build-and-release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Setup Extism
17+
run: |
18+
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh
19+
sh install.sh
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: '14' # Specify the Node.js version you need
25+
26+
- name: Install
27+
run: |
28+
npm i
29+
npm install -g ejs-lint
30+
31+
- name: Build
32+
run: |
33+
npm run build
34+
35+
- name: Run bundle script
36+
run: ./bundle.sh
37+
38+
- name: Upload release asset
39+
uses: actions/upload-release-asset@v1
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
with:
43+
upload_url: ${{ github.event.release.upload_url }}
44+
asset_path: ./bundle.zip
45+
asset_name: bundle.zip
46+
asset_content_type: application/zip
47+
48+

.github/workflows/test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
repository: extism/python-pdk
20+
path: python-pdk
21+
22+
- name: Setup Extism and XTP
23+
run: |
24+
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh
25+
sh install.sh
26+
curl https://static.dylibso.com/cli/install.sh | sh
27+
28+
- name: Setup extism-py
29+
run: |
30+
curl -O https://raw.githubusercontent.com/extism/python-pdk/main/install.sh
31+
sh install.sh
32+
curl -LsSf https://astral.sh/uv/install.sh | sh
33+
34+
- name: Setup Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.12'
38+
39+
- name: Set up Node.js
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: '21'
43+
44+
- name: Install Rust
45+
uses: actions-rs/toolchain@v1
46+
with:
47+
toolchain: stable
48+
49+
- name: Install
50+
run: |
51+
npm ci
52+
npm install -g ejs-lint
53+
54+
- name: Build
55+
run: |
56+
npm run build
57+
58+
- name: Check Rust Version
59+
run: rustc --version
60+
61+
- name: Run test script
62+
run: |
63+
cd tests && ./test.sh
64+
65+
- name: Run Bindgen Test
66+
run: |
67+
sh bindgen-test.sh install
68+
sh bindgen-test.sh run
69+
70+

bindgen-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ case $1 in
2929
# Using ../../bundle so we test the bindgen template
3030
PLUGIN_NAME=exampleplugin
3131
echo "generating initial plugin code in '$(pwd)/$PLUGIN_NAME'..."
32-
# xtp plugin init --schema-file schema.yaml --template ../../bundle --path $PLUGIN_NAME --name $PLUGIN_NAME --feature stub-with-code-samples
32+
xtp plugin init --schema-file schema.yaml --template ../../bundle --path $PLUGIN_NAME --name $PLUGIN_NAME --feature stub-with-code-samples
3333
echo "building '$PLUGIN_NAME'..."
3434
xtp plugin build --path $PLUGIN_NAME
3535
echo "testing '$PLUGIN_NAME'..."

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ dependencies:
55
available-feature-flags:
66
- name: stub-with-code-samples
77
description: |
8-
Stub the `__init__.py` implementations with code from the codeSamples property.
8+
Stub the `plugin.py` implementations with code from the codeSamples property.
99
By default the implementations will throw a not-implemented error. This will error out
1010
if every export doesn't have at least one Python codeSample.

template/plugin/pdk_types.py.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# THIS FILE WAS GENERATED BY `xtp-python-bindgen`. DO NOT EDIT.
22

3+
from __future__ import annotations
34
from enum import Enum # noqa: F401
45
from typing import Optional, List # noqa: F401
56
from datetime import datetime # noqa: F401

template/plugin/plugin.py.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import extism # noqa: F401 # pyright: ignore
22
from pdk_types import <%- Object.values(schema.schemas).map(schema => schema.name).join(", ") %> # noqa: F401
33
from pdk_imports import <%- schema.imports.map(schema => camelToSnakeCase(schema.name)).join(", ") %> # noqa: F401
4+
from typing import List, Optional # noqa: F401
45

56
<% schema.exports.forEach(ex => { -%>
67
def <%- camelToSnakeCase(ex.name) %>(<% if (ex.input) { %>input: <%- toPythonType(ex.input) %> <% } %>) <% if (ex.output) {%>-> <%- toPythonType(ex.output) %><%}%>:

0 commit comments

Comments
 (0)