Skip to content

Feature automate change-log #712

Feature automate change-log

Feature automate change-log #712

Workflow file for this run

# .github/workflows/makefile-lint.yml
# print_error(msg, line_start, line_end)
#
# Formats and prints error messages according to CEP-7 guidelines and GitHub Actions' logging
# commands.
#
# Arguments:
# msg - The error message to display.
# line_start - The starting line number where the error occurred.
# line_end - The ending line number where the error occurred.
#
# This function outputs an error message in the GitHub Actions logging format, including the
# file path, line numbers, a title, and the error message content. This ensures consistency
# and clarity in error reporting within workflow scripts.
---
name: Makefile Lint
on: # yamllint disable-line rule:truthy
push:
branches: ["main", "master", "stable"]
pull_request:
branches: ["main", "master", "stable", "feature-*", "patch-*", "HOTFIX-*"]
permissions: {} # Setting default permissions to none for enhanced security
jobs:
makefile-lint:
permissions:
contents: read
statuses: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Install Apt-Get Dependencies
run: |
sudo apt-get update || exit 1
sudo apt-get install -y yamllint golang-go pandoc || : # handle error with detail below
print_error() {
local msg="$1"
local file_stub=".github/workflows/makefile-lint.yml"
local line_start="$2"
local line_end="$3"
printf "::error file=%s,line=%s,endLine=%s,title=VALIDATION_ERROR::ERROR %s\n" \
"${file_stub}" "${line_start}" "${line_end}" "${msg}"
}
go version || { print_error "Go installation failed." 40 41 ; exit 126; }
yamllint --version || { print_error "Yamllint installation failed." 40 41 ; exit 126; }
pandoc --version || { print_error "Pandoc installation failed." 40 41 ; exit 126; }
- name: Lint Workflow YAML
if: ${{ success() }}
env:
YAML_ARGS: "${{ vars.YAML_ARGS }}"
run: |
printf "Validating workflow with args: %s\n" "${YAML_ARGS}"
# shellcheck disable=SC2086
yamllint ${YAML_ARGS} .github/workflows/makefile-lint.yml
- name: Install checkmake
if: ${{ success() }}
env:
BUILDER_NAME: "makefile-lint"
BUILDER_EMAIL: "no-reply@localhost"
EXPECTED_SHA: "${{ vars.CHECKMAKE_EXPECTED_SHA }}"
run: |
git clone --depth 1 --branch main https://github.com/mrtazz/checkmake.git checkmake
cd checkmake
ACTUAL_SHA=$(git rev-parse HEAD)
if [ "$EXPECTED_SHA" != "$ACTUAL_SHA" ]; then
ERR_MSG_STUB="Checkmake repository hash verification failed."
ERR_DETAILS="file=.github/workflows/makefile-lint.yml,line=72,endLine=75,title=FAILURE"
ERR_MSG_LINE="::error ${ERR_DETAILS}::ERROR ${ERR_MSG_STUB}"
printf "%s\n" "${ERR_MSG_LINE}"
exit 1;
fi
make && make install || { \
ERR_MSG_STUB="Checkmake build failed." \
ERR_DETS="file=.github/workflows/makefile-lint.yml,line=79,endLine=83,title=FAILURE" \
ERR_MSG_LINE="::error ${ERR_DETS}::ERROR ${ERR_MSG_STUB}" \
printf "%s\n" "${ERR_MSG_LINE}" \
exit 1 \
;}
wait ;
cd ..
- name: Get makefiles Files
id: makefiles
shell: bash
run: |
FILES=$(git ls-files --exclude-standard -- Makefile 2>/dev/null)
if [ -z "$FILES" ]; then
printf "%s\n" "No Makefiles found."
printf "%s\n" "files=" >> "$GITHUB_OUTPUT"
else
printf "%s\n" "Makefiles found:"
printf "%s\n" "$FILES"
# Replace line breaks with spaces for GitHub Action Output
FILES="${FILES//$'\n'/ }"
printf "%s\n" "files=$FILES" >> "$GITHUB_OUTPUT"
fi
if: ${{ success() }}
- name: Lint Makefiles Files
run: |
TOOL_PATH=".github/tool_checkmake.sh"
print_error() {
local msg="$1"
local file_stub=".github/workflows/makefile-lint.yml"
local line_start="$2"
local line_end="$3"
printf "::error file=%s,line=%s,endLine=%s,title=FAILURE::ERROR %s\n" \
"${file_stub}" "${line_start}" "${line_end}" "${msg}"
}
if [ ! -x "$TOOL_PATH" ]; then
{ print_error "$TOOL_PATH not found or not executable." 114 114; exit 1; } ;
fi
FILE="${{ steps.makefiles.outputs.files }}" ;
printf "::group::%s\n" "${FILE}" ;
"$TOOL_PATH" "${FILE}" || { print_error "Linting failed." 119 119; exit 1; } ;
printf "::endgroup::\n" ; unset FILE 2>/dev/null || true ;
if: ${{ !cancelled() && steps.makefiles.outputs.files != '' }}