From c87cca2b5f2c7156096ac7a6fed248474ebe0db1 Mon Sep 17 00:00:00 2001 From: syumai Date: Tue, 16 Apr 2024 10:19:53 +0900 Subject: [PATCH 1/4] add command to build examples to Makefile --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index b2084f5..4bb3c27 100644 --- a/Makefile +++ b/Makefile @@ -2,3 +2,10 @@ test: @PATH=$(CURDIR)/misc/wasm:$(PATH) GOOS=js GOARCH=wasm go test ./... +.PHONY: build-examples +build-examples: + for dir in $(shell find ./_examples -maxdepth 1 -type d); do \ + if [ $$dir = "./_examples" ]; then continue; fi; \ + cd $$dir && GOOS=js GOARCH=wasm go build -o ./build/app.wasm; \ + cd ../../; \ + done \ No newline at end of file From ccc1c0f061a39e3ec1e9d784a5279b244eb6aedd Mon Sep 17 00:00:00 2001 From: syumai Date: Tue, 16 Apr 2024 23:27:26 +0900 Subject: [PATCH 2/4] output build target directory name in build-examples --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4bb3c27..4859fb9 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ test: build-examples: for dir in $(shell find ./_examples -maxdepth 1 -type d); do \ if [ $$dir = "./_examples" ]; then continue; fi; \ + echo 'build:' $$dir; \ cd $$dir && GOOS=js GOARCH=wasm go build -o ./build/app.wasm; \ cd ../../; \ - done \ No newline at end of file + done From c5def28fb1bec46a698dbd55c888c930dc8d4449 Mon Sep 17 00:00:00 2001 From: syumai Date: Tue, 16 Apr 2024 23:27:40 +0900 Subject: [PATCH 3/4] fix service-bindings example --- _examples/service-bindings/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_examples/service-bindings/main.go b/_examples/service-bindings/main.go index 81e1614..ab9a23a 100644 --- a/_examples/service-bindings/main.go +++ b/_examples/service-bindings/main.go @@ -16,7 +16,7 @@ func main() { bind := cloudflare.GetBinding(ctx, "hello") fc := fetch.NewClient(fetch.WithBinding(bind)) - hc := fc.HTTPClient() + hc := fc.HTTPClient(fetch.RedirectModeFollow) res, err := hc.Do(req) if err != nil { fmt.Println(err) From 081d6e2763ffed959669ea290a22767dac2ee736 Mon Sep 17 00:00:00 2001 From: syumai Date: Tue, 16 Apr 2024 23:31:09 +0900 Subject: [PATCH 4/4] add Build examples step to CI --- .github/workflows/pull_request.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 8261015..9570f72 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -22,4 +22,21 @@ jobs: - name: Test shell: bash run: | - PATH=$PWD/misc/wasm:$PATH GOOS=js GOARCH=wasm go test ./... \ No newline at end of file + PATH=$PWD/misc/wasm:$PATH GOOS=js GOARCH=wasm go test ./... + + examples: + name: Build examples + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Golang + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Build examples + shell: bash + run: make build-examples +