-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build/ci: add dependency downloading to Makefile, add ci/cd
- Loading branch information
Showing
9 changed files
with
169 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build and Release | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Extism | ||
run: | | ||
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh | ||
sh install.sh | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' # Specify the Node.js version you need | ||
|
||
- name: Build | ||
run: | | ||
npm i | ||
npm run build | ||
- name: Run bundle script | ||
run: ./bundle.sh | ||
|
||
- name: Upload release asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./bundle.zip | ||
asset_name: bundle.zip | ||
asset_content_type: application/zip | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Run Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Extism and XTP | ||
run: | | ||
curl -O https://raw.githubusercontent.com/extism/js-pdk/main/install.sh | ||
sh install.sh | ||
curl https://static.dylibso.com/cli/install.sh | sh | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '21' | ||
|
||
- name: Install | ||
run: | | ||
npm ci | ||
- name: Build | ||
run: | | ||
npm run build | ||
- name: Run test script | ||
run: | | ||
cd tests && ./test.sh | ||
- name: Run Bindgen Test | ||
run: | | ||
# we already have a folder named bundle | ||
# move it before we get the simulation bundle | ||
# TODO change the name | ||
mv bundle template-bundle | ||
# get the latest release | ||
RELEASE_INFO=$(curl -s "https://api.github.com/repos/dylibso/xtp-bindgen-test/releases/latest") | ||
ASSET_URL=$(echo $RELEASE_INFO | grep -oP '"browser_download_url": "\K(.*bundle.zip)(?=")') | ||
if [ -z "$ASSET_URL" ]; then | ||
echo "Asset URL not found. Please check the asset name or the repository." | ||
exit 1 | ||
fi | ||
# download and unzip the bundle | ||
curl -L -o bundle.zip "$ASSET_URL" | ||
unzip bundle.zip | ||
cd bundle/ | ||
# Using ../template-bundle so we test the head template | ||
xtp plugin init --schema-file schema.yaml --template ../template-bundle --path exampleplugin --name exampleplugin --feature stub-with-code-samples | ||
xtp plugin build --path exampleplugin | ||
xtp plugin test exampleplugin/dist/plugin.wasm --with test.wasm --mock-host mock.wasm | ||
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
template-suffix: ejs | ||
dependencies: | ||
- tinygo | ||
|
||
available-feature-flags: | ||
- name: stub-with-code-samples | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,51 @@ | ||
WASI_SDK_PATH?=../../wasi-sdk | ||
ifeq ($(origin WASI_SDK_PATH),undefined) | ||
WASI_SDK_PATH=./wasi-sdk | ||
ifeq ("$(wildcard ./wasi-sdk)","") | ||
$(shell chmod +x ./install-wasi-sdk.sh) | ||
$(shell ./install-wasi-sdk.sh) | ||
endif | ||
endif | ||
|
||
.PHONY: build | ||
build: dist/plugin.wasm | ||
|
||
.PHONY: run | ||
run: dist/plugin.wasm | ||
extism call ./dist/plugin.wasm referenceTypes --log-level debug --wasi --input "\"apple\"" | ||
.PHONY: format | ||
format: | ||
$(WASI_SDK_PATH)/bin/clang-format -i *.cpp *.hpp | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f *.wasm *.o | ||
|
||
.PHONY: veryclean | ||
veryclean: clean | ||
rm -rf include ./wasi-sdk | ||
|
||
.PHONY: run-bad-input | ||
run-bad-input: dist/plugin.wasm | ||
extism call ./dist/plugin.wasm referenceTypes --log-level debug --wasi --input "\"steak\"" | ||
|
||
.PHONY: run-top | ||
run-top: dist/plugin.wasm | ||
extism call ./dist/plugin.wasm topLevelPrimitives --log-level debug --wasi --input "\"hello\"" | ||
include/extism-pdk.hpp: | ||
mkdir -p include | ||
cd include && \ | ||
wget -q https://raw.githubusercontent.com/extism/cpp-pdk/695c794d2f3a42dff8c6f37e1902ad0dee9ff29a/extism-pdk.hpp | ||
|
||
.PHONY: run-void | ||
run-void: dist/plugin.wasm | ||
extism call ./dist/plugin.wasm voidFunc --log-level debug --wasi | ||
include/magic_enum/include/magic_enum: | ||
mkdir -p include/magic_enum | ||
cd include/magic_enum && \ | ||
wget -q https://github.com/Neargye/magic_enum/releases/download/v0.9.6/magic_enum-v0.9.6.tar.gz && \ | ||
tar xf magic_enum-v0.9.6.tar.gz | ||
|
||
pdk.gen.o: pdk.gen.cpp pdk.gen.hpp extism-pdk.hpp | ||
$(WASI_SDK_PATH)/bin/clang++ -I. -Imagic_enum -std=c++23 -fno-exceptions -O2 -g -c pdk.gen.cpp | ||
include/jsoncons/include: | ||
mkdir -p include | ||
cd include && \ | ||
wget -q https://github.com/danielaparker/jsoncons/archive/refs/tags/v0.177.0.zip && \ | ||
unzip -qq v0.177.0.zip && \ | ||
mv jsoncons-0.177.0 jsoncons | ||
|
||
impl.o: impl.cpp pdk.gen.hpp | ||
$(WASI_SDK_PATH)/bin/clang++ -I. -std=c++23 -fno-exceptions -O2 -g -c impl.cpp | ||
pdk.gen.o: pdk.gen.cpp pdk.gen.hpp include/extism-pdk.hpp include/magic_enum/include/magic_enum include/jsoncons/include | ||
$(WASI_SDK_PATH)/bin/clang++ -Iinclude -Iinclude/jsoncons/include -Iinclude/magic_enum/include/magic_enum -std=c++23 -fno-exceptions -O2 -g -c pdk.gen.cpp | ||
|
||
impl.o: impl.cpp pdk.gen.hpp include/extism-pdk.hpp include/magic_enum/include/magic_enum include/jsoncons/include | ||
$(WASI_SDK_PATH)/bin/clang++ -Iinclude -Iinclude/jsoncons/include -Iinclude/magic_enum/include/magic_enum -std=c++23 -fno-exceptions -O2 -g -c impl.cpp | ||
|
||
dist/plugin.wasm: pdk.gen.o impl.o | ||
mkdir -p dist | ||
$(WASI_SDK_PATH)/bin/clang++ -I. -std=c++23 -fno-exceptions -O2 -g -o $@ $^ -mexec-model=reactor | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f *.wasm *.o | ||
$(WASI_SDK_PATH)/bin/clang++ -std=c++23 -fno-exceptions -O2 -g -o $@ $^ -mexec-model=reactor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
# Orignal from: https://github.com/Shopify/javy | ||
|
||
set -euo pipefail | ||
|
||
PATH_TO_SDK="./wasi-sdk" | ||
if [[ ! -d $PATH_TO_SDK ]]; then | ||
TMPGZ=$(mktemp) | ||
VERSION_MAJOR="24" | ||
VERSION_MINOR="0" | ||
ARCH=$(uname -m) | ||
if [[ "$(uname -s)" == "Darwin" ]]; then | ||
curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-${ARCH}-macos.tar.gz --output $TMPGZ | ||
else | ||
curl --fail --location --silent https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${VERSION_MAJOR}/wasi-sdk-${VERSION_MAJOR}.${VERSION_MINOR}-${ARCH}-linux.tar.gz --output $TMPGZ | ||
fi | ||
mkdir $PATH_TO_SDK | ||
tar xf $TMPGZ -C $PATH_TO_SDK --strip-components=1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters