Skip to content

Commit 080630c

Browse files
authored
Merge pull request #186 from fastly/cee-dub/limitless-headers
Deprecate remaining Limits, make all buffers adaptive
2 parents e7ad78e + 588e69b commit 080630c

27 files changed

+580
-363
lines changed

.github/actions/install-tinygo/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ inputs:
44
tinygo-version:
55
description: "The version of TinyGo to install"
66
required: true
7-
default: "0.33.0"
7+
default: "0.39.0"
88
runs:
99
using: "composite"
1010
steps:

.github/workflows/build-examples.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,23 @@ on:
88
jobs:
99
build-examples:
1010
runs-on: ubuntu-latest
11+
1112
strategy:
1213
matrix:
1314
include:
1415
# Newest supported configuration
15-
- go-version: '1.23' # pairs with TinyGo 0.33.0
16-
tinygo-version: '0.33.0'
16+
- go-version: "1.25" # pairs with TinyGo 0.39.0
17+
tinygo-version: "0.39.0"
1718
# Oldest supported configuration
18-
- go-version: '1.21' # pairs with TinyGo 0.29.0
19-
tinygo-version: '0.29.0'
19+
- go-version: "1.23" # pairs with TinyGo 0.33.0
20+
tinygo-version: "0.33.0"
2021

2122
steps:
22-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v5
24+
2325
- uses: actions/setup-go@v5
2426
with:
2527
go-version: ${{ matrix.go-version }}
26-
- uses: ./.github/actions/install-tinygo
27-
with:
28-
tinygo-version: ${{ matrix.tinygo-version }}
2928

3029
- name: Build examples Go
3130
env:
@@ -37,9 +36,14 @@ jobs:
3736
cd ${GITHUB_WORKSPACE}/$i && go build -tags fastlyinternaldebug
3837
done
3938
39+
- uses: acifani/setup-tinygo@v2
40+
with:
41+
tinygo-version: ${{ matrix.tinygo-version }}
42+
binaryen-version: "124"
43+
4044
- name: Build examples TinyGo
4145
run: |
4246
for i in _examples/*/; do
4347
echo ${GITHUB_WORKSPACE}/$i
44-
cd ${GITHUB_WORKSPACE}/$i && tinygo build -target=wasi -tags fastlyinternaldebug
48+
cd ${GITHUB_WORKSPACE}/$i && tinygo build -target=wasip1 -tags fastlyinternaldebug
4549
done

.github/workflows/integration-tests.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,34 @@ on:
88
jobs:
99
integration-tests:
1010
runs-on: ubuntu-latest
11+
1112
strategy:
1213
matrix:
1314
include:
14-
# Newest supported configuration
15-
- go-version: "1.23" # pairs with TinyGo 0.33.0+
15+
- go-version: "1.25.1" # pairs with TinyGo 0.39.0+
16+
tinygo-version: "0.39.0"
17+
tinygo-wasi-target: "wasip1"
18+
- go-version: "1.23.12" # pairs with TinyGo 0.33.0+
1619
tinygo-version: "0.35.0"
1720
tinygo-wasi-target: "wasip1"
18-
- go-version: "1.22" # pairs with TinyGo 0.31.2
19-
tinygo-version: "0.31.2"
20-
tinygo-wasi-target: "wasi"
21-
# Oldest supported configuration
22-
- go-version: "1.21" # pairs with TinyGo 0.29.0
23-
tinygo-version: "0.29.0"
24-
tinygo-wasi-target: "wasi"
2521

2622
steps:
27-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v5
24+
2825
- uses: actions/setup-go@v5
2926
with:
3027
go-version: ${{ matrix.go-version }}
3128

3229
- uses: ./.github/actions/install-tinygo
3330
with:
3431
tinygo-version: ${{ matrix.tinygo-version }}
32+
- run: tinygo version
3533

3634
- name: Setup Fastly CLI
37-
uses: fastly/compute-actions/setup@v7
38-
39-
- name: Install Viceroy
40-
run: make tools/viceroy
41-
42-
- name: Print dependency versions
43-
run: |
44-
go version
45-
tinygo version
46-
fastly version
47-
viceroy --version
35+
uses: fastly/compute-actions/setup@v11
36+
with:
37+
verbose: true
38+
- run: fastly version
4839

4940
- name: Tests - Go
5041
run: make test-go

.github/workflows/validate.yml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@ on:
88
jobs:
99
validate:
1010
runs-on: ubuntu-latest
11+
1112
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-go@v5
14-
with:
15-
go-version-file: go.mod
13+
- uses: actions/checkout@v5
1614

17-
- uses: ./.github/actions/install-tinygo
15+
- id: setup-go
16+
uses: actions/setup-go@v5
1817
with:
19-
tinygo-version: "0.35.0"
20-
21-
- name: Print dependency versions
22-
run: |
23-
go version
24-
tinygo version
18+
go-version-file: go.mod
2519

26-
- run: go vet ./...
20+
- name: vet
21+
run: go vet ./...
2722

2823
- name: staticcheck
2924
run: |
@@ -32,16 +27,10 @@ jobs:
3227
3328
- name: nilness
3429
run: |
35-
go install golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness@master
30+
go install golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness@v0.36.0
3631
nilness ./...
3732
3833
- name: ineffassign
3934
run: |
40-
go install github.com/gordonklaus/ineffassign@latest
35+
go install github.com/gordonklaus/ineffassign@v0.2.0
4136
ineffassign ./...
42-
43-
- name: Install viceroy
44-
run: make tools/viceroy
45-
46-
- name: Run Tests
47-
run: make test

Makefile

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,73 @@
11
.DEFAULT: test
22

3-
test: test-go test-tinygo test-integration
43
.PHONY: test
5-
6-
# Makes tools/viceroy available as an executable within Makefile recipes.
7-
PATH := $(PWD)/tools:$(PATH)
4+
test: test-go test-tinygo test-integration test-e2e
85

96
# Override these with environment variables or directly on the make command line.
107
GO_BUILD_FLAGS := -tags=fastlyinternaldebug,nofastlyhostcalls
118
GO_TEST_FLAGS := -v
129
GO_PACKAGES := ./...
1310

11+
.PHONY: test-go
1412
test-go:
13+
@echo ">> Running Go tests..." >&2
1514
go test $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
16-
.PHONY: test-go
1715

1816
# Using this target lets viceroy provide the wasm runtime, eliminating a dependency on wasmtime.
1917
TINYGO_TARGET := ./targets/fastly-compute-wasip1.json
2018

21-
test-tinygo:
22-
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
2319
.PHONY: test-tinygo
20+
test-tinygo: viceroy
21+
@echo ">> Running TinyGo tests..." >&2
22+
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
2423

2524
# Integration tests use viceroy and override the default values for these variables.
2625
test-integration-%: GO_BUILD_FLAGS := -tags=fastlyinternaldebug
2726
test-integration-%: GO_PACKAGES := ./integration_tests/...
2827

29-
test-integration: test-integration-go test-integration-tinygo
28+
3029
.PHONY: test-integration
30+
test-integration: test-integration-go test-integration-tinygo
3131

32-
test-integration-go: tools/viceroy
33-
GOARCH=wasm GOOS=wasip1 go test -exec "viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
3432
.PHONY: test-integration-go
33+
test-integration-go: viceroy
34+
@echo ">> Running Go integration tests..." >&2
35+
GOARCH=wasm GOOS=wasip1 go test -exec "viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
3536

36-
test-integration-tinygo: tools/viceroy
37-
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
3837
.PHONY: test-integration-tinygo
38+
test-integration-tinygo: viceroy
39+
@echo ">> Running TinyGo integration tests..." >&2
40+
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
41+
42+
# End to end tests use serve.sh and override the default values for these variables.
43+
test-e2e-%: GO_BUILD_FLAGS := -tags=fastlyinternaldebug
44+
test-e2e-%: GO_PACKAGES := ./end_to_end_tests/...
45+
test-e2e-%: export PATH := $(PWD)/end_to_end_tests:$(PATH) # allows go test to find serve.sh
46+
47+
.PHONY: test-e2e
48+
test-e2e: test-e2e-go test-e2e-tinygo
49+
50+
.PHONY: test-e2e-go
51+
test-e2e-go: viceroy
52+
@echo ">> Running Go end-to-end tests..." >&2
53+
GOARCH=wasm GOOS=wasip1 go test -exec "serve.sh viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
54+
55+
.PHONY: test-e2e-tinygo
56+
test-e2e-tinygo: TINYGO_TARGET := ./targets/fastly-compute-wasip1-serve.json
57+
test-e2e-tinygo: viceroy
58+
@echo ">> Running TinyGo end-to-end tests..." >&2
59+
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES)
3960

40-
tools/viceroy: | tools # Download latest version of Viceroy ./tools/viceroy; delete it if you'd like to upgrade
41-
@arch=$$(uname -m | sed 's/x86_64/amd64/'); \
42-
os=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
43-
url=$$(curl -s https://api.github.com/repos/fastly/viceroy/releases/latest | jq --arg arch $$arch --arg os $$os -r '.assets[] | select((.name | contains($$arch)) and (.name | contains($$os))) | .browser_download_url'); \
44-
filename=$$(basename $$url); \
45-
curl -sSLO $$url && \
46-
tar -xzf $$filename --directory ./tools/ && \
47-
rm $$filename && \
48-
./tools/viceroy --version && \
49-
touch ./tools/viceroy
50-
ifneq ($(strip $(GITHUB_PATH)),)
51-
@echo "$(PWD)/tools" >> "$(GITHUB_PATH)"
52-
endif
53-
54-
tools:
55-
@mkdir -p tools
56-
57-
viceroy-update:
58-
@rm -f tools/viceroy
59-
@$(MAKE) tools/viceroy
60-
.PHONY: viceroy-update
61+
.PHONY: viceroy
62+
viceroy:
63+
@which viceroy || ( \
64+
echo "viceroy not found: please ensure it is installed and available in your PATH:" && \
65+
echo $$PATH && \
66+
echo && \
67+
echo "The fastly CLI installs Viceroy in the fastly subdirectory of the path returned by" && \
68+
echo "os.UserConfigDir():" && \
69+
echo " > On Unix systems, it returns \$$XDG_CONFIG_HOME if non-empty, else \$$HOME/.config." && \
70+
echo " > On Darwin, it returns \$$HOME/Library/Application Support." && \
71+
echo "From https://pkg.go.dev/os#UserConfigDir" && \
72+
exit 1 \
73+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin/
2+
pkg/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file describes a Fastly Compute package. To learn more visit:
2+
# https://www.fastly.com/documentation/reference/compute/fastly-toml
3+
4+
authors = []
5+
description = ""
6+
language = "go"
7+
manifest_version = 3
8+
name = "serve on loopback test"
9+
service_id = ""
10+
11+
[scripts]
12+
build = "GOARCH=wasm GOOS=wasip1 go build -tags fastlyinternaldebug -o bin/main.wasm ."
13+
14+
[local_server.backends.self]
15+
url = "http://127.0.0.1:23456/"

end_to_end_tests/loopback/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//go:build !test
2+
3+
package main
4+
5+
import (
6+
"context"
7+
8+
"github.com/fastly/compute-sdk-go/fsthttp"
9+
)
10+
11+
func main() {
12+
handler := func(ctx context.Context, w fsthttp.ResponseWriter, r *fsthttp.Request) {
13+
w.Header().Set("Content-Type", "text/plain")
14+
w.Header().Set("X-Test-Header", "present")
15+
w.Write([]byte("OK"))
16+
}
17+
fsthttp.ServeFunc(handler)
18+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//go:build ((tinygo.wasm && wasi) || wasip1) && !nofastlyhostcalls
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"io"
8+
"testing"
9+
10+
"github.com/fastly/compute-sdk-go/fsthttp"
11+
)
12+
13+
func TestLoopback(t *testing.T) {
14+
req, err := fsthttp.NewRequest("GET", "http://anyplace.horse", nil)
15+
if err != nil {
16+
t.Fatal(err)
17+
}
18+
resp, err := req.Send(context.Background(), "self")
19+
if err != nil {
20+
t.Fatal(err)
21+
}
22+
defer resp.Body.Close()
23+
24+
if h, want := resp.Header.Get("content-type"), "text/plain"; h != want {
25+
t.Errorf("Content-Type = %s, want: %s", h, want)
26+
}
27+
if resp.Header.Get("date") == "" {
28+
t.Errorf("expected default Date header is missing")
29+
}
30+
if h, want := resp.Header.Get("x-test-header"), "present"; h != want {
31+
t.Errorf("X-Test-Header = %s, want: %s", h, want)
32+
}
33+
body, err := io.ReadAll(resp.Body)
34+
if err != nil {
35+
t.Fatal(err)
36+
}
37+
if b, want := string(body), "OK"; b != want {
38+
t.Errorf("resp.Body = %s, want: %s", b, want)
39+
}
40+
}

0 commit comments

Comments
 (0)