From 8501b5801a13a61b8f7bf6d13fa9fb7e1325d11b Mon Sep 17 00:00:00 2001 From: Mehdi Salemi Date: Mon, 7 Jul 2025 11:33:05 -0400 Subject: [PATCH 1/4] add ci to rust, ts, js, wasm for checking if function runs --- .github/workflows/validate-js-functions.yml | 22 +++++++++++++++++++ .github/workflows/validate-rust-functions.yml | 22 +++++++++++++++++++ .github/workflows/validate-ts-functions.yml | 22 +++++++++++++++++++ .github/workflows/validate-wasm-functions.yml | 22 +++++++++++++++++++ 4 files changed, 88 insertions(+) diff --git a/.github/workflows/validate-js-functions.yml b/.github/workflows/validate-js-functions.yml index cff769e7..b9937640 100644 --- a/.github/workflows/validate-js-functions.yml +++ b/.github/workflows/validate-js-functions.yml @@ -25,3 +25,25 @@ jobs: run: yarn js-typegen - name: Test run: yarn js-test + - name: Test function execution + run: | + # Install Shopify CLI + npm install -g @shopify/cli + + # Test each JS function + for func_dir in functions-*-js; do + if [ -d "$func_dir" ]; then + echo "Testing function execution for $func_dir" + + # Build function to wasm + shopify app function build --path "$func_dir" + + # Create empty input + echo '{}' > input.json + + # Run function with empty input + shopify app function run --input input.json --path "$func_dir" --json + + echo "Function $func_dir executed successfully" + fi + done diff --git a/.github/workflows/validate-rust-functions.yml b/.github/workflows/validate-rust-functions.yml index 895aafa5..18dd9b34 100644 --- a/.github/workflows/validate-rust-functions.yml +++ b/.github/workflows/validate-rust-functions.yml @@ -31,3 +31,25 @@ jobs: run: rustup target add wasm32-wasip1 - name: Build with wasm32-wasip1 target run: cargo build --release --target wasm32-wasip1 + - name: Test function execution + run: | + # Install Shopify CLI + npm install -g @shopify/cli + + # Test each Rust function + for func_dir in functions-*-rs; do + if [ -d "$func_dir" ]; then + echo "Testing function execution for $func_dir" + + # Build function to wasm + shopify app function build --path "$func_dir" + + # Create empty input + echo '{}' > input.json + + # Run function with empty input + shopify app function run --input input.json --path "$func_dir" --json + + echo "Function $func_dir executed successfully" + fi + done diff --git a/.github/workflows/validate-ts-functions.yml b/.github/workflows/validate-ts-functions.yml index eb0e4240..8ee73d18 100644 --- a/.github/workflows/validate-ts-functions.yml +++ b/.github/workflows/validate-ts-functions.yml @@ -25,3 +25,25 @@ jobs: run: yarn js-typegen - name: Test run: yarn js-test + - name: Test function execution + run: | + # Install Shopify CLI + npm install -g @shopify/cli + + # Test each JS function (includes TS functions) + for func_dir in functions-*-js; do + if [ -d "$func_dir" ]; then + echo "Testing function execution for $func_dir" + + # Build function to wasm + shopify app function build --path "$func_dir" + + # Create empty input + echo '{}' > input.json + + # Run function with empty input + shopify app function run --input input.json --path "$func_dir" --json + + echo "Function $func_dir executed successfully" + fi + done diff --git a/.github/workflows/validate-wasm-functions.yml b/.github/workflows/validate-wasm-functions.yml index ba3f5b79..cfc80028 100644 --- a/.github/workflows/validate-wasm-functions.yml +++ b/.github/workflows/validate-wasm-functions.yml @@ -19,3 +19,25 @@ jobs: run: yarn - name: Expand liquid for TypeScript functions run: CI=1 yarn expand-liquid wasm + - name: Test function execution + run: | + # Install Shopify CLI + npm install -g @shopify/cli + + # Test each WASM function + for func_dir in functions-*-wasm; do + if [ -d "$func_dir" ]; then + echo "Testing function execution for $func_dir" + + # Build function to wasm + shopify app function build --path "$func_dir" + + # Create empty input + echo '{}' > input.json + + # Run function with empty input + shopify app function run --input input.json --path "$func_dir" --json + + echo "Function $func_dir executed successfully" + fi + done From d0a39afe811a929b60322830be790cc910f92b84 Mon Sep 17 00:00:00 2001 From: Mehdi Salemi Date: Mon, 7 Jul 2025 11:54:42 -0400 Subject: [PATCH 2/4] Test with valid client id --- .github/workflows/validate-js-functions.yml | 14 ++++++++++++++ .github/workflows/validate-rust-functions.yml | 3 +++ .github/workflows/validate-ts-functions.yml | 3 +++ .github/workflows/validate-wasm-functions.yml | 3 +++ shopify.app.toml | 10 ++++++++++ 5 files changed, 33 insertions(+) create mode 100644 shopify.app.toml diff --git a/.github/workflows/validate-js-functions.yml b/.github/workflows/validate-js-functions.yml index b9937640..188cbfef 100644 --- a/.github/workflows/validate-js-functions.yml +++ b/.github/workflows/validate-js-functions.yml @@ -35,6 +35,20 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" + # Create app structure with real client ID + cat > shopify.app.toml << EOF +client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}" +name = "ci-test-app" +application_url = "https://example.com" +embedded = true + +[auth] +redirect_urls = ["https://example.com/auth/callback"] + +[webhooks] +api_version = "2024-01" +EOF + # Build function to wasm shopify app function build --path "$func_dir" diff --git a/.github/workflows/validate-rust-functions.yml b/.github/workflows/validate-rust-functions.yml index 18dd9b34..544c8e9c 100644 --- a/.github/workflows/validate-rust-functions.yml +++ b/.github/workflows/validate-rust-functions.yml @@ -41,6 +41,9 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" + # Create app structure with real client ID + echo 'client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}"' > shopify.app.toml + # Build function to wasm shopify app function build --path "$func_dir" diff --git a/.github/workflows/validate-ts-functions.yml b/.github/workflows/validate-ts-functions.yml index 8ee73d18..63ad122d 100644 --- a/.github/workflows/validate-ts-functions.yml +++ b/.github/workflows/validate-ts-functions.yml @@ -35,6 +35,9 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" + # Create app structure with real client ID + echo 'client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}"' > shopify.app.toml + # Build function to wasm shopify app function build --path "$func_dir" diff --git a/.github/workflows/validate-wasm-functions.yml b/.github/workflows/validate-wasm-functions.yml index cfc80028..952a792f 100644 --- a/.github/workflows/validate-wasm-functions.yml +++ b/.github/workflows/validate-wasm-functions.yml @@ -29,6 +29,9 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" + # Create app structure with real client ID + echo 'client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}"' > shopify.app.toml + # Build function to wasm shopify app function build --path "$func_dir" diff --git a/shopify.app.toml b/shopify.app.toml new file mode 100644 index 00000000..44ede5fb --- /dev/null +++ b/shopify.app.toml @@ -0,0 +1,10 @@ +client_id = "cce73c955015bde64a40f32619843cad" +name = "ci-test-app" +application_url = "https://example.com" +embedded = true + +[auth] +redirect_urls = ["https://example.com/auth/callback"] + +[webhooks] +api_version = "2024-01" \ No newline at end of file From 89b9dba1b9bdf58ba6223ed871f0ae4fa1b4a971 Mon Sep 17 00:00:00 2001 From: Mehdi Salemi Date: Mon, 7 Jul 2025 11:57:31 -0400 Subject: [PATCH 3/4] test1 --- .github/workflows/validate-js-functions.yml | 14 +------------- .github/workflows/validate-rust-functions.yml | 3 +-- .github/workflows/validate-ts-functions.yml | 3 +-- .github/workflows/validate-wasm-functions.yml | 3 +-- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.github/workflows/validate-js-functions.yml b/.github/workflows/validate-js-functions.yml index 188cbfef..7cfc169a 100644 --- a/.github/workflows/validate-js-functions.yml +++ b/.github/workflows/validate-js-functions.yml @@ -35,19 +35,7 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # Create app structure with real client ID - cat > shopify.app.toml << EOF -client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}" -name = "ci-test-app" -application_url = "https://example.com" -embedded = true - -[auth] -redirect_urls = ["https://example.com/auth/callback"] - -[webhooks] -api_version = "2024-01" -EOF + # shopify.app.toml already exists at root with complete configuration # Build function to wasm shopify app function build --path "$func_dir" diff --git a/.github/workflows/validate-rust-functions.yml b/.github/workflows/validate-rust-functions.yml index 544c8e9c..6252d721 100644 --- a/.github/workflows/validate-rust-functions.yml +++ b/.github/workflows/validate-rust-functions.yml @@ -41,8 +41,7 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # Create app structure with real client ID - echo 'client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}"' > shopify.app.toml + # shopify.app.toml already exists at root with complete configuration # Build function to wasm shopify app function build --path "$func_dir" diff --git a/.github/workflows/validate-ts-functions.yml b/.github/workflows/validate-ts-functions.yml index 63ad122d..5d6d5434 100644 --- a/.github/workflows/validate-ts-functions.yml +++ b/.github/workflows/validate-ts-functions.yml @@ -35,8 +35,7 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # Create app structure with real client ID - echo 'client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}"' > shopify.app.toml + # shopify.app.toml already exists at root with complete configuration # Build function to wasm shopify app function build --path "$func_dir" diff --git a/.github/workflows/validate-wasm-functions.yml b/.github/workflows/validate-wasm-functions.yml index 952a792f..a7ece610 100644 --- a/.github/workflows/validate-wasm-functions.yml +++ b/.github/workflows/validate-wasm-functions.yml @@ -29,8 +29,7 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # Create app structure with real client ID - echo 'client_id = "${{ secrets.SHOPIFY_APP_CLIENT_ID }}"' > shopify.app.toml + # shopify.app.toml already exists at root with complete configuration # Build function to wasm shopify app function build --path "$func_dir" From 0da12e4a8bb97cee8f58cdd345c04e46b5991a28 Mon Sep 17 00:00:00 2001 From: Mehdi Salemi Date: Mon, 7 Jul 2025 11:59:51 -0400 Subject: [PATCH 4/4] Test2 --- .github/workflows/validate-js-functions.yml | 12 +++++++++--- .github/workflows/validate-rust-functions.yml | 12 +++++++++--- .github/workflows/validate-ts-functions.yml | 12 +++++++++--- .github/workflows/validate-wasm-functions.yml | 12 +++++++++--- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.github/workflows/validate-js-functions.yml b/.github/workflows/validate-js-functions.yml index 7cfc169a..d2deb9e6 100644 --- a/.github/workflows/validate-js-functions.yml +++ b/.github/workflows/validate-js-functions.yml @@ -35,17 +35,23 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # shopify.app.toml already exists at root with complete configuration + # Copy app config to function directory and run from there + cp shopify.app.toml "$func_dir/" + cd "$func_dir" # Build function to wasm - shopify app function build --path "$func_dir" + shopify app function build # Create empty input echo '{}' > input.json # Run function with empty input - shopify app function run --input input.json --path "$func_dir" --json + shopify app function run --input input.json --json echo "Function $func_dir executed successfully" + + # Clean up and return to root + rm shopify.app.toml input.json + cd .. fi done diff --git a/.github/workflows/validate-rust-functions.yml b/.github/workflows/validate-rust-functions.yml index 6252d721..9200afab 100644 --- a/.github/workflows/validate-rust-functions.yml +++ b/.github/workflows/validate-rust-functions.yml @@ -41,17 +41,23 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # shopify.app.toml already exists at root with complete configuration + # Copy app config to function directory and run from there + cp shopify.app.toml "$func_dir/" + cd "$func_dir" # Build function to wasm - shopify app function build --path "$func_dir" + shopify app function build # Create empty input echo '{}' > input.json # Run function with empty input - shopify app function run --input input.json --path "$func_dir" --json + shopify app function run --input input.json --json echo "Function $func_dir executed successfully" + + # Clean up and return to root + rm shopify.app.toml input.json + cd .. fi done diff --git a/.github/workflows/validate-ts-functions.yml b/.github/workflows/validate-ts-functions.yml index 5d6d5434..03c1bc72 100644 --- a/.github/workflows/validate-ts-functions.yml +++ b/.github/workflows/validate-ts-functions.yml @@ -35,17 +35,23 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # shopify.app.toml already exists at root with complete configuration + # Copy app config to function directory and run from there + cp shopify.app.toml "$func_dir/" + cd "$func_dir" # Build function to wasm - shopify app function build --path "$func_dir" + shopify app function build # Create empty input echo '{}' > input.json # Run function with empty input - shopify app function run --input input.json --path "$func_dir" --json + shopify app function run --input input.json --json echo "Function $func_dir executed successfully" + + # Clean up and return to root + rm shopify.app.toml input.json + cd .. fi done diff --git a/.github/workflows/validate-wasm-functions.yml b/.github/workflows/validate-wasm-functions.yml index a7ece610..36a79b1a 100644 --- a/.github/workflows/validate-wasm-functions.yml +++ b/.github/workflows/validate-wasm-functions.yml @@ -29,17 +29,23 @@ jobs: if [ -d "$func_dir" ]; then echo "Testing function execution for $func_dir" - # shopify.app.toml already exists at root with complete configuration + # Copy app config to function directory and run from there + cp shopify.app.toml "$func_dir/" + cd "$func_dir" # Build function to wasm - shopify app function build --path "$func_dir" + shopify app function build # Create empty input echo '{}' > input.json # Run function with empty input - shopify app function run --input input.json --path "$func_dir" --json + shopify app function run --input input.json --json echo "Function $func_dir executed successfully" + + # Clean up and return to root + rm shopify.app.toml input.json + cd .. fi done