Skip to content

Commit

Permalink
output error to chatops comment
Browse files Browse the repository at this point in the history
Signed-off-by: kevindiu <[email protected]>
  • Loading branch information
kevindiu committed Apr 7, 2023
1 parent 86cc8c8 commit cf43421
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/chatops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ jobs:
with:
go-version: ${{ steps.golang_version.outputs.version }}
- name: Generate tests and push
id: gen_test
if: steps.check_comments_gen_test.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true'
run: |
curl -s ${PR_INFO_URL} > /tmp/pr_info.json
Expand All @@ -342,7 +343,7 @@ jobs:
git checkout ${HEAD_BRANCH}
make gotests/install
make -j 4 gotests/gen
GITHUB_OUTPUT=$(make gotests/gen 2>&1 >/dev/null)
git add cmd hack internal pkg
git commit -S --signoff -m ":robot: Add automatically generated tests"
Expand All @@ -361,12 +362,13 @@ jobs:
- name: failure comment
if: failure()
run: |
ERR_LOG=${{ steps.gen_test.outputs }}
curl --include --verbose --fail \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
--request POST \
--data "{\"body\": \"**[GEN TEST]** Failed to generate tests.\"}" \
--data "{\"body\": \"**[GEN TEST]** Failed to generate tests. Error: $ERR_LOG\"}" \
$API_URL
env:
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
Expand Down
10 changes: 10 additions & 0 deletions Makefile.d/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,22 @@ define gen-go-test-sources
@for f in $(GO_SOURCES); do \
echo "Generating go test file: $$f"; \
gotests -w -template_dir $(ROOTDIR)/assets/test/templates/common -all $(patsubst %_test.go,%.go,$$f); \
RESULT=$$?; \
if [ ! $$RESULT -eq 0 ]; then \
echo $$RESULT; \
exit 1; \
fi; \
done
endef

define gen-go-option-test-sources
@for f in $(GO_OPTION_SOURCES); do \
echo "Generating go option test file: $$f"; \
gotests -w -template_dir $(ROOTDIR)/assets/test/templates/common -all $(patsubst %_test.go,%.go,$$f); \
RESULT=$$?; \
if [ ! $$RESULT -eq 0 ]; then \
echo $$RESULT; \
exit 1; \
fi; \
done
endef

0 comments on commit cf43421

Please sign in to comment.