Skip to content

Commit

Permalink
fix: incorect zip file (#20)
Browse files Browse the repository at this point in the history
* fix: incorect zip file
  • Loading branch information
clement2026 authored Sep 6, 2024
1 parent 59e2151 commit ad5ed36
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
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),
)
}

0 comments on commit ad5ed36

Please sign in to comment.