Skip to content

Commit fc52e32

Browse files
authored
Merge pull request qualcomm-linux#67 from smuppand/main
Add CI workflow to check for unintended executable permissions in scripts
2 parents a499fd9 + 7551c73 commit fc52e32

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Enforce Script Executable Permissions
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**/run.sh'
7+
- '**/*.sh'
8+
9+
jobs:
10+
permissions:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Detect missing executable permissions on shell scripts
17+
run: |
18+
# Find all .sh and run.sh scripts without +x
19+
BAD=$(find . -type f -name 'run.sh' -o -name '*.sh' ! -perm -u=x)
20+
if [ -n "$BAD" ]; then
21+
echo "::error file=run.sh,line=1::❌ Some shell scripts are missing executable permissions. This can break CI and LAVA. Please fix before merging."
22+
echo "::error file=run.sh,line=2::To fix, run: find . -name '*.sh' -o -name 'run.sh' | xargs chmod +x && git add . && git commit -m 'Fix: restore executable bits on scripts' && git push"
23+
echo ""
24+
echo "The following scripts need 'chmod +x':"
25+
echo "$BAD"
26+
# Output a PR annotation for each file
27+
echo "$BAD" | while read -r file; do
28+
echo "::error file=$file,line=1::$file is not executable. Please run: chmod +x $file && git add $file"
29+
done
30+
exit 1
31+
else
32+
echo "✅ All shell scripts have correct executable permissions."
33+
fi
34+
35+
- name: Detect accidental executables on non-shell files (optional, warning only)
36+
run: |
37+
# (Advanced/optional) Warn if any non-.sh file has +x (customize as needed)
38+
OTHER_EXEC=$(find . -type f ! -name '*.sh' ! -name 'run.sh' -perm -u=x)
39+
if [ -n "$OTHER_EXEC" ]; then
40+
echo "::warning file=run.sh,line=1::Warning: Non-shell files with executable permissions detected. Review if needed."
41+
echo "$OTHER_EXEC"
42+
fi

.github/workflows/preflight-checker-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
uses: qualcomm-linux/qli-actions/.github/workflows/multi-checker.yml@main
1212
with:
1313
repolinter: true # default: true
14-
semgrep: false # default: true
14+
semgrep: true # default: true
1515
copyright-license-detector: true # default: true
1616
pr-check-emails: true # default: true
1717

0 commit comments

Comments
 (0)