Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorect zip file #20

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ jobs:
uses: arduino/setup-protoc@v3

- name: Unit testing
run: make protoc && make test

- name: Build binary
run: make build
run: make test

- name: Upload binary
uses: actions/upload-artifact@v4
Expand All @@ -60,13 +57,6 @@ jobs:
compression-level: 9
retention-days: 10

- name: E2E testing with binary
run: make test-e2e

- name: Build binary for release
run: make clean && make release

- name: E2E testing with binary for release
run: make test-e2e

- name: E2E testing
run: make clean test-e2e

46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,46 @@ RESET := \033[0m
define print_step
@echo "$(GREEN)===== $(1) =====$(RESET)"
endef
.PHONY: build

all: protoc build
.PHONY: protoc build release test test-e2e build-for-release

all: build
$(call print_step, Done)

release: protoc build-for-release
release: build-for-release
$(call print_step, Done)

protoc:
$(call print_step, Generating protobuf files)
$(MAKE) -f go.mk protoc
$(MAKE) -C ts protoc

test:
$(call print_step, Testing)
$(MAKE) -f go.mk test
$(MAKE) -C ts test

test-e2e:
$(call print_step, Testing e2e)
$(MAKE) -f go.mk test-e2e

build:
build: protoc
$(call print_step, Building)
$(MAKE) -C ts build
$(MAKE) copy
$(MAKE) -f go.mk build

build-for-release:
build-for-release: protoc
$(call print_step, Build for releasing)
$(MAKE) -C ts build
$(MAKE) copy
$(MAKE) zip
$(MAKE) -f go.mk build-for-release

test: build
$(call print_step, Testing)
$(MAKE) -f go.mk test
$(MAKE) -C ts test

test-e2e: build
$(call print_step, Testing e2e)
$(MAKE) -f go.mk test-e2e
$(MAKE) clean
$(MAKE) protoc build-for-release
$(call print_step, Testing e2e again)
$(MAKE) -f go.mk test-e2e

clean:
$(call print_step, Cleaning)
$(MAKE) -f go.mk clean
Expand All @@ -51,12 +56,19 @@ clean:
fi

copy:
$(call print_step, Removing static files from go)
$(call print_step, Removing static files)
@if [ -d "./assets/web/html" ]; then \
rm -rf ./assets/web/html; \
fi
$(call print_step, Copying static files to go)
$(call print_step, Copying static files)
cp -r ts/out assets/web/html

zip:
zip -r assets/web/html.zip ts/out/*
$(call print_step, Removing zip)
@if [ -d "rm ./assets/web/html.zip" ]; then \
rm -rf rm ./assets/web/html.zip; \
fi

$(call print_step, Copying zip)
# this won't work as it creates ts/out entry in the .zip: zip -r assets/web/html.zip ts/out/*
cd ts/out && zip -r ../../assets/web/html.zip ./*
Binary file modified assets/web/html.zip
Binary file not shown.
12 changes: 11 additions & 1 deletion tests/e2e/run_binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/assert"
)

//goland:noinspection HttpUrlsUsage
func TestRunBinary(t *testing.T) {

binary, err := FindBinary(t)
Expand All @@ -32,7 +33,6 @@ func TestRunBinary(t *testing.T) {
assert.True(t, LogContainsText(c.Status(), "listening on localhost:12345") ||
LogContainsText(c.Status(), "listening on 127.0.0.1:12345"), WhatsWrong(c.Status()))

//goland:noinspection HttpUrlsUsage
url := fmt.Sprintf("http://%s:%d", host, port)

Test(t,
Expand All @@ -41,4 +41,14 @@ func TestRunBinary(t *testing.T) {
Expect().Status().Equal(http.StatusOK),
Expect().Body().String().Contains("Live pprof"),
)

url = fmt.Sprintf("http://%s:%d/favicon.ico", host, port)

Test(t,
Description("Get favicon.ico: "+url),
Get(url),
Expect().Status().Equal(http.StatusOK),
Expect().Headers("content-type").First().Contains("image"),
Expect().Body().Bytes().Len().GreaterThan(0),
)
}