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

让 CI 中的报错信息更直观 #646

Closed
GimmeCyy opened this issue Jun 12, 2022 · 2 comments · Fixed by #955
Closed

让 CI 中的报错信息更直观 #646

GimmeCyy opened this issue Jun 12, 2022 · 2 comments · Fixed by #955
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/ci kind/easy

Comments

@GimmeCyy
Copy link
Contributor

GimmeCyy commented Jun 12, 2022

优化检查报错信息,让报错更明显些
b57d1f3e26c5490b4b44cd3d74d5a38

@seeflood seeflood added good first issue Good for newcomers help wanted Extra attention is needed labels Jun 12, 2022
@seeflood seeflood changed the title 检查报错信息不够直观 CI 中的报错信息不够直观 Jun 13, 2022
@seeflood seeflood changed the title CI 中的报错信息不够直观 让 CI 中的报错信息更直观 Jun 14, 2022
@seeflood
Copy link
Member

复现步骤: 提交个会让 ut 报错的 pr,github 跑 CI 会报错,但报错信息如上图、不明显,看不出来是哪个ut出错了

@alilestera
Copy link
Contributor

It seems still not solve, and nobody take this task.
I have a simple but useful idea, and I implemented it.

In layotto github-ci process, main command about go-unit-test is run: make test, this command runs go.test in layotto/make/golang.mk. My idea is make commands in go.test output a temp record file, instead of stdout. When unit test finished, output the file content to stdout firstly, then output the failed info.

.PHONY: go.test
OUTPUT := /home/alilestera/foo.txt
go.unittest:
	@echo "===========> Run unit test in diagnostics" > $(OUTPUT) && \
	$(GO) test -count=1 -timeout=10m -short -v `go list ./diagnostics/...` >> $(OUTPUT) && \
	echo "===========> Run unit test in sdk/go-sdk" >> $(OUTPUT) && \
	cd sdk/go-sdk && $(GO) test -count=1 -timeout=10m -short -v `go list ./... | grep -v runtime` >> $(OUTPUT) && \
	echo "===========> Run unit test in components" >> $(OUTPUT) && \
	cd ../../components/ && $(GO) test -count=1 -timeout=10m -short -v `go list ./...` >> $(OUTPUT) && \
	echo "===========> Run unit test in pkg" >> $(OUTPUT) && \
	cd ../ && $(GO) test -count=1 -timeout=10m -short -v `go list ./pkg/...` >> $(OUTPUT) || true

go.test: go.unittest
	@cat $(OUTPUT)
#	if failed, exit 1 to stop process
	@if grep -q "FAIL" $(OUTPUT); then \
    		grep "FAIL" $(OUTPUT); \
    		rm -f $(OUTPUT); \
    		exit 1; \
	fi;
	@rm -f $(OUTPUT)

Use && connect every command make the workflow can fail fast if one of these get failed, and it runs to || true. Then the workflow runs to go.test. In go.test, if it really get failed, exit 1 let the make process output Error and stop ci.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed kind/ci kind/easy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants