Skip to content

Commit 5677100

Browse files
committed
AEA-5959 Check for build target. Run only if present.
1 parent 94eecd8 commit 5677100

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

.github/workflows/quality-checks.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,4 +409,9 @@ jobs:
409409
path: cfn_guard_output
410410

411411
- name: Build project
412-
run: make build
412+
run: |
413+
if scripts/check_makefile_target.sh build; then
414+
make build
415+
else
416+
echo "No build target found in Makefile, skipping build step"
417+
fi

scripts/check_makefile_target.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Script to check if a target exists in a Makefile
4+
# Usage: check_makefile_target.sh <target_name> [makefile_path]
5+
6+
set -euo pipefail
7+
8+
TARGET_NAME="${1:-}"
9+
MAKEFILE_PATH="${2:-Makefile}"
10+
11+
if [ -z "$TARGET_NAME" ]; then
12+
echo "Error: Target name is required" >&2
13+
echo "Usage: $0 <target_name> [makefile_path]" >&2
14+
exit 1
15+
fi
16+
17+
if [ ! -f "$MAKEFILE_PATH" ]; then
18+
echo "Error: Makefile not found at '$MAKEFILE_PATH'" >&2
19+
exit 1
20+
fi
21+
22+
# Check if the target exists in the Makefile
23+
# Matches lines like "target:" or "target: dependencies"
24+
if grep -qE "^${TARGET_NAME}:" "$MAKEFILE_PATH"; then
25+
echo "Target '$TARGET_NAME' exists in $MAKEFILE_PATH"
26+
exit 0
27+
else
28+
echo "Target '$TARGET_NAME' not found in $MAKEFILE_PATH" >&2
29+
exit 1
30+
fi

0 commit comments

Comments
 (0)