11# .github/workflows/makefile-lint.yml
2+
3+ # print_error(msg, line_start, line_end)
4+ #
5+ # Formats and prints error messages according to CEP-7 guidelines and GitHub Actions' logging
6+ # commands.
7+ #
8+ # Arguments:
9+ # msg - The error message to display.
10+ # line_start - The starting line number where the error occurred.
11+ # line_end - The ending line number where the error occurred.
12+ #
13+ # This function outputs an error message in the GitHub Actions logging format, including the
14+ # file path, line numbers, a title, and the error message content. This ensures consistency
15+ # and clarity in error reporting within workflow scripts.
16+
217---
318name : Makefile Lint
419on : # yamllint disable-line rule:truthy
@@ -23,15 +38,25 @@ jobs:
2338 - name : Install Apt-Get Dependencies
2439 run : |
2540 sudo apt-get update || exit 1
26- sudo apt-get install -y yamllint golang-go pandoc || exit 1
27- ERR_MSG_STUB="Go installation failed."
28- ERR_DETAILS="file=.github/workflows/makefile-lint.yml,line=25,endLine=30,title=FAILURE"
29- ERR_MSG_LINE="::error ${ERR_DETAILS}::ERROR ${ERR_MSG_STUB}"
30- go version || { printf "%s\n" "${ERR_MSG_LINE}"; exit 1; }
41+ sudo apt-get install -y yamllint golang-go pandoc || : # handle error with detail below
42+ print_error() {
43+ local msg="$1"
44+ local file_stub=".github/workflows/makefile-lint.yml"
45+ local line_start="$2"
46+ local line_end="$3"
47+ printf "::error file=%s,line=%s,endLine=%s,title=VALIDATION_ERROR::ERROR %s\n" \
48+ "${file_stub}" "${line_start}" "${line_end}" "${msg}"
49+ }
50+ go version || { print_error "Go installation failed." 40 41 ; exit 126; }
51+ yamllint --version || { print_error "Yamllint installation failed." 40 41 ; exit 126; }
52+ pandoc --version || { print_error "Pandoc installation failed." 40 41 ; exit 126; }
3153 - name : Lint Workflow YAML
3254 if : ${{ success() }}
55+ env :
56+ YAML_ARGS : " ${{ vars.YAML_ARGS }}"
3357 run : |
34- yamllint ${{ vars.YAML_ARGS }} .github/workflows/makefile-lint.yml
58+ printf "Validating workflow with args: %s\n" "${YAML_ARGS}"
59+ yamllint ${YAML_ARGS} .github/workflows/makefile-lint.yml
3560 - name : Install checkmake
3661 if : ${{ success() }}
3762 env :
@@ -44,14 +69,14 @@ jobs:
4469 ACTUAL_SHA=$(git rev-parse HEAD)
4570 if [ "$EXPECTED_SHA" != "$ACTUAL_SHA" ]; then
4671 ERR_MSG_STUB="Checkmake repository hash verification failed."
47- ERR_DETAILS="file=.github/workflows/makefile-lint.yml,line=42 ,endLine=51 ,title=FAILURE"
72+ ERR_DETAILS="file=.github/workflows/makefile-lint.yml,line=75 ,endLine=79 ,title=FAILURE"
4873 ERR_MSG_LINE="::error ${ERR_DETAILS}::ERROR ${ERR_MSG_STUB}"
4974 printf "%s\n" "${ERR_MSG_LINE}"
5075 exit 1;
5176 fi
5277 make && make install || { \
5378 ERR_MSG_STUB="Checkmake build failed." \
54- ERR_DETS="file=.github/workflows/makefile-lint.yml,line=52 ,endLine=59 ,title=FAILURE" \
79+ ERR_DETS="file=.github/workflows/makefile-lint.yml,line=77 ,endLine=83 ,title=FAILURE" \
5580 ERR_MSG_LINE="::error ${ERR_DETS}::ERROR ${ERR_MSG_STUB}" \
5681 printf "%s\n" "${ERR_MSG_LINE}" \
5782 exit 1 \
@@ -77,20 +102,19 @@ jobs:
77102 - name : Lint Makefiles Files
78103 run : |
79104 TOOL_PATH=".github/tool_checkmake.sh"
105+ print_error() {
106+ local msg="$1"
107+ local file_stub=".github/workflows/makefile-lint.yml"
108+ local line_start="$2"
109+ local line_end="$3"
110+ printf "::error file=%s,line=%s,endLine=%s,title=FAILURE::ERROR %s\n" \
111+ "${file_stub}" "${line_start}" "${line_end}" "${msg}"
112+ }
80113 if [ ! -x "$TOOL_PATH" ]; then
81- { \
82- ERR_MSG_STUB="$TOOL_PATH not found or not executable." \
83- ERR_DETS="file=.github/workflows/makefile-lint.yml,line=79,endLine=88,title=FAILURE" \
84- ERR_MSG_LINE="::error ${ERR_DETS}::ERROR ${ERR_MSG_STUB}" \
85- printf "%s\n" "${ERR_MSG_LINE}" \
86- exit 1 \
87- ;}
114+ { print_error "$TOOL_PATH not found or not executable." 114 114; exit 1; } ;
88115 fi
89116 FILE="${{ steps.makefiles.outputs.files }}" ;
90117 printf "::group::%s\n" "${FILE}" ;
91- ERR_MSG_STUB="Linting failed."
92- ERR_DETS="file=.github/workflows/makefile-lint.yml,line=89,endLine=97,title=FAILURE"
93- ERR_MSG_LINE="::error ${ERR_DETS}::ERROR ${ERR_MSG_STUB}"
94- "$TOOL_PATH" "${FILE}" || { printf "%s\n" "${ERR_MSG_LINE}"; exit 1; } ;
118+ "$TOOL_PATH" "${FILE}" || { print_error "Linting failed." 118 118; exit 1; } ;
95119 printf "::endgroup::\n" ; unset FILE 2>/dev/null || true ;
96120 if : ${{ !cancelled() && steps.makefiles.outputs.files != '' }}
0 commit comments