Repository navigation
159 lines (139 loc) · 4.8 KB
/
Copy pathcodestyle.yml
File metadata and controls
159 lines (139 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
# SPDX-License-Identifier: BSD-3-Clause
#
# Static hygiene and lint checks for sof-utils:
# - yamllint : strict YAML lint for workflows and west.yml
# - spdx-check : verify SPDX-License-Identifier headers on tracked source/build files
# - shell-syntax : bash -n syntax validation for shell scripts
# - python-lint : ruff fatal syntax & undefined-name checks (E9, F63, F7, F82)
# - commit-messages : subject format, 75-char wrap, and Signed-off-by trailer check
name: codestyle
# yamllint disable-line rule:truthy
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
workflow_dispatch:
permissions: {}
concurrency:
group: "${{ github.workflow }}-${{ github.event_name }}-\
${{ github.event_name == 'pull_request' && github.ref || github.run_id }}"
cancel-in-progress: true
jobs:
yamllint:
name: YAML lint
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install yamllint
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends yamllint
- name: Run yamllint
env:
yamllint_config: '{extends: default, rules: {line-length: {max: 100}}}'
run: |
yamllint -f parsable -d "$yamllint_config" --strict \
.github/workflows/*.yml *.yml
spdx-check:
name: SPDX license headers
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Verify SPDX-License-Identifier headers
run: |
set -euo pipefail
missing=0
while IFS= read -r f; do
case "$f" in
LICENSE|*.md|*.desktop|*.txt|.gitignore|\
debian/changelog|debian/control|debian/copyright|\
sof-remote-server/sepolicy/*|sof-remote-server/Android.bp|\
sof-remote-server/sof_remote_server.rc|\
sof-testbench/arch/host/configs/*)
continue
;;
esac
if ! head -n 5 "$f" | grep -q "SPDX-License-Identifier:"; then
echo "ERROR: missing SPDX-License-Identifier header in $f"
missing=1
fi
done < <(git ls-files)
exit "$missing"
shell-syntax:
name: Shell script syntax
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check bash syntax on tracked shell scripts
run: |
set -euo pipefail
while IFS= read -r f; do
echo "Checking $f"
bash -n "$f"
done < <(git ls-files '*.sh')
python-lint:
name: Python fatal lint (ruff)
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Run ruff fatal checks
uses: astral-sh/ruff-action@278981a28ce3188b1e39527901f38254bf3aac89 # v4.1.0
with:
args: "check --select E9,F63,F7,F82"
src: >-
. sof-builder/sof-builder sof-ucm/sof-ucm
sof-top/sof-top sof-top/sof-top-cli
commit-messages:
name: Commit messages (subject, wrap, SoB)
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Check commit messages
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE: ${{ github.event.before }}
PUSH_AFTER: ${{ github.event.after }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = "pull_request" ]; then
rev_range="${PR_BASE_SHA}..${PR_HEAD_SHA}"
elif [ "$EVENT_NAME" = "push" ] && [ -n "$PUSH_BEFORE" ] \
&& [ "$PUSH_BEFORE" != "0000000000000000000000000000000000000000" ]; then
rev_range="${PUSH_BEFORE}..${PUSH_AFTER}"
else
rev_range="HEAD~1..HEAD"
fi
echo "Checking commit range: ${rev_range}"
python3 scripts/check_commits.py "$rev_range"