-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from fastly/cee-dub/make-it-so
Makefile: introduce tasks to aid testing; update CI
- Loading branch information
Showing
14 changed files
with
130 additions
and
96 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
_examples/*/bin | ||
_examples/*/pkg | ||
tools/viceroy |
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,60 @@ | ||
.DEFAULT: test | ||
|
||
test: test-go test-tinygo test-integration | ||
.PHONY: test | ||
|
||
# Makes tools/viceroy available as an executable within Makefile recipes. | ||
PATH := $(PWD)/tools:$(PATH) | ||
|
||
# Override these with environment variables or directly on the make command line. | ||
GO_BUILD_FLAGS := -tags=fastlyinternaldebug,nofastlyhostcalls | ||
GO_TEST_FLAGS := -v | ||
GO_PACKAGES := ./... | ||
|
||
test-go: | ||
go test $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) | ||
.PHONY: test-go | ||
|
||
# Using this target lets viceroy provide the wasm runtime, eliminating a dependency on wasmtime. | ||
TINYGO_TARGET := ./targets/fastly-compute-wasip1.json | ||
|
||
test-tinygo: | ||
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) | ||
.PHONY: test-tinygo | ||
|
||
# Integration tests use viceroy and override the default values for these variables. | ||
test-integration-%: GO_BUILD_FLAGS := -tags=fastlyinternaldebug | ||
test-integration-%: GO_PACKAGES := ./integration_tests/... | ||
|
||
test-integration: test-integration-go test-integration-tinygo | ||
.PHONY: test-integration | ||
|
||
test-integration-go: tools/viceroy | ||
GOARCH=wasm GOOS=wasip1 go test -exec "viceroy run -C fastly.toml" $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) | ||
.PHONY: test-integration-go | ||
|
||
test-integration-tinygo: tools/viceroy | ||
tinygo test -target=$(TINYGO_TARGET) $(GO_BUILD_FLAGS) $(GO_TEST_FLAGS) $(GO_PACKAGES) | ||
.PHONY: test-integration-tinygo | ||
|
||
tools/viceroy: | tools # Download latest version of Viceroy ./tools/viceroy; delete it if you'd like to upgrade | ||
@arch=$$(uname -m | sed 's/x86_64/amd64/'); \ | ||
os=$$(uname -s | tr '[:upper:]' '[:lower:]'); \ | ||
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'); \ | ||
filename=$$(basename $$url); \ | ||
curl -sSLO $$url && \ | ||
tar -xzf $$filename --directory ./tools/ && \ | ||
rm $$filename && \ | ||
./tools/viceroy --version && \ | ||
touch ./tools/viceroy | ||
ifneq ($(strip $(GITHUB_PATH)),) | ||
@echo "$(PWD)/tools" >> "$(GITHUB_PATH)" | ||
endif | ||
|
||
tools: | ||
@mkdir -p tools | ||
|
||
viceroy-update: | ||
@rm -f tools/viceroy | ||
@$(MAKE) tools/viceroy | ||
.PHONY: viceroy-update |
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
Empty file.
Empty file.
Empty file.
Empty file.
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,3 +1,3 @@ | ||
module github.com/fastly/compute-sdk-go | ||
|
||
go 1.20 | ||
go 1.21 |
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 +0,0 @@ | ||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= | ||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= | ||
github.com/json-iterator/tinygo v0.0.0-20211217141205-d684fd97f7cf h1:GNaFMjcDLzxr4j3RNBsbiiwUfCU3AGUJRTz7qG96MNM= | ||
github.com/json-iterator/tinygo v0.0.0-20211217141205-d684fd97f7cf/go.mod h1:sR5SXbtbtp8PxPu3yGjZug4AS5aAur8jQZl9DXYTpP0= | ||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= | ||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= | ||
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,12 @@ | ||
# This file describes a Fastly Compute package. To learn more visit: | ||
# https://www.fastly.com/documentation/reference/compute/fastly-toml | ||
|
||
authors = ["[email protected]"] | ||
description = "" | ||
language = "go" | ||
manifest_version = 2 | ||
name = "print-request" | ||
|
||
[scripts] | ||
# build = "GOARCH=wasm GOOS=wasip1 go build -o bin/main.wasm ." | ||
# build = "tinygo build -target=wasip1 -gc=conservative -o ./bin/main.wasm ./" |
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,13 @@ | ||
// Copyright 2025 Fastly, Inc. | ||
|
||
package main | ||
|
||
import ( | ||
"runtime/debug" | ||
"testing" | ||
) | ||
|
||
func TestGoVersion(t *testing.T) { | ||
bi, _ := debug.ReadBuildInfo() | ||
t.Log(bi.GoVersion) | ||
} |