mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 09:49:12 +00:00
Merge pull request #99 from syumai/fix-examples-build
add Makefile command to build example files
This commit is contained in:
commit
9710147e94
19
.github/workflows/pull_request.yaml
vendored
19
.github/workflows/pull_request.yaml
vendored
@ -22,4 +22,21 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
PATH=$PWD/misc/wasm:$PATH GOOS=js GOARCH=wasm go test ./...
|
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
|
||||||
|
|
||||||
|
8
Makefile
8
Makefile
@ -2,3 +2,11 @@
|
|||||||
test:
|
test:
|
||||||
@PATH=$(CURDIR)/misc/wasm:$(PATH) GOOS=js GOARCH=wasm go 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; \
|
||||||
|
echo 'build:' $$dir; \
|
||||||
|
cd $$dir && GOOS=js GOARCH=wasm go build -o ./build/app.wasm; \
|
||||||
|
cd ../../; \
|
||||||
|
done
|
||||||
|
@ -16,7 +16,7 @@ func main() {
|
|||||||
bind := cloudflare.GetBinding(ctx, "hello")
|
bind := cloudflare.GetBinding(ctx, "hello")
|
||||||
fc := fetch.NewClient(fetch.WithBinding(bind))
|
fc := fetch.NewClient(fetch.WithBinding(bind))
|
||||||
|
|
||||||
hc := fc.HTTPClient()
|
hc := fc.HTTPClient(fetch.RedirectModeFollow)
|
||||||
res, err := hc.Do(req)
|
res, err := hc.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user