-
-
Notifications
You must be signed in to change notification settings - Fork 363
176 lines (156 loc) · 5.42 KB
/
linter.yml
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: "Mixed linter and checks"
on:
push:
branches:
- 'master'
- 'dev'
- 'stable'
- 'container-*'
pull_request:
# Automatically cancel any previous workflow on new push.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-22.04
outputs:
yaml: ${{ steps.filter.outputs.yaml }}
clang-format: ${{ steps.filter.outputs.clang-format }}
bindgen-linter: ${{ steps.filter.outputs.bindgen-linter }}
prettier: ${{ steps.filter.outputs.prettier }}
python: ${{ steps.filter.outputs.python }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
yaml:
- '**.yml'
- '**.yaml'
- '.github/workflows/linter.yml'
bindgen-linter:
- '**.c'
- '**.h'
- '**.inc'
- '.github/workflows/linter.yml'
clang-format:
- '**.c'
- '**.h'
- '**.in'
- '**.inc'
- '.github/workflows/linter.yml'
- 'sys/clang-format.py'
- '.clang-format'
prettier:
- '**.js'
- '.github/workflows/linter.yml'
python:
- '**.py'
- '.github/workflows/linter.yml'
- '.pylintrc'
cmd_descs_yaml_check:
needs: changes
runs-on: ubuntu-22.04
if: ${{ needs.changes.outputs.yaml == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get install yamllint python3-yaml
- name: Check YamlLint
run: |
yamllint -d "{rules: {line-length: {max: 120}}}" ./librz/core/cmd_descs/*.yaml
- name: Check sync between yaml and C/H files
run: |
./librz/core/cmd_descs/cmd_descs_generate.py --output-dir /tmp ./librz/core/cmd_descs/*.yaml
diff /tmp/cmd_descs.c ./librz/core/cmd_descs/cmd_descs.c && diff /tmp/cmd_descs.h ./librz/core/cmd_descs/cmd_descs.h
bindgen-linter:
needs: changes
runs-on: ubuntu-22.04
if: ${{ needs.changes.outputs.bindgen-linter == 'true' }}
steps:
- name: Checkout rizin
uses: actions/checkout@v4
with:
path: rizin
- name: Checkout rz-bindgen
uses: actions/checkout@v4
with:
repository: rizinorg/rz-bindgen
path: rz-bindgen
- name: Install dependencies
run: |
sudo pip install meson ninja
sudo apt update
sudo apt install libclang-14-dev
- name: Build rizin
working-directory: rizin
run: |
meson setup build
ninja -C build
- name: Run rz-bindgen linter
run: |
python3 rz-bindgen/src/lint.py \
--clang-path "/usr/lib/llvm-14/lib" \
--clang-args "-resource-dir=$(clang -print-resource-dir) " \
--rizin-path rizin
clang-format:
needs: changes
runs-on: ubuntu-22.04
if: ${{ needs.changes.outputs.clang-format == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install wget, software-properties-common, lsb-release (dependencies of LLVM install script)
run: sudo apt --assume-yes install wget software-properties-common lsb-release
- name: Uninstall old conflicting packages
run: sudo apt purge --assume-yes --auto-remove llvm python3-lldb-14 llvm-14
- name: Install automatic LLVM 16
run: wget https://apt.llvm.org/llvm.sh -O /tmp/llvm-install.sh; chmod +x /tmp/llvm-install.sh; sudo /tmp/llvm-install.sh 16
- name: Install clang-format-16
run: sudo apt --assume-yes install clang-format-16
- name: Install gitpython
run: sudo pip install gitpython
- name: Run clang-format
run: |
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 160
clang-format --version
python sys/clang-format.py --check --verbose
prettier:
needs: changes
runs-on: ubuntu-22.04
if: ${{ needs.changes.outputs.prettier == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install prettier
run: |
sudo apt --assume-yes install npm
npm install prettier
- name: Run prettier
run: find . -name "*.js" | grep -v "bindings/node/index.js\|subprojects/tree-sitter" | xargs npx prettier --print-width 120 --check
python:
needs: changes
runs-on: ubuntu-22.04
if: ${{ needs.changes.outputs.python == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pylint, black, isort
run: pip install pylint black isort
- name: Run black
run: |
export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH}
find . -name "*.py" | grep -v "subprojects" | xargs black --check
- name: Run pylint
run: |
export PATH=${HOME}/Library/Python/3.9/bin:${HOME}/Library/Python/3.10/bin:${HOME}/.local/bin:${PATH}
find . -name "*.py" | grep -v "subprojects" | grep -v "librz/bin/format/xnu/scripts/" | xargs -I % pylint --disable=R1737 '%'
licenses:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1