-
-
Notifications
You must be signed in to change notification settings - Fork 0
243 lines (215 loc) · 7.81 KB
/
AutoFormat.yml
File metadata and controls
243 lines (215 loc) · 7.81 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Auto Format
run-name: Auto Format - ${{ github.ref_name }}
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
clang:
name: Clang
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Pull Request
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.AUTOFORMAT_COMMIT_TOKEN }}
- name: Format C Files
run: |
set -o pipefail
echo "<details open><summary>Clang-Format Output</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
git ls-files '*.c' '*.h' | xargs -r clang-format -i --verbose 2>&1 | tee -a $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
- name: Save Changes
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
if: github.ref_type != 'tag'
env:
HOME: ${{ github.workspace }}
with:
default_author: github_actions
message: 'Automatic Clang-Format: Standardized formatting automatically'
fetch: 'false'
cmake:
name: CMake
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Checkout Pull Request
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.AUTOFORMAT_COMMIT_TOKEN }}
fetch-depth: 1
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
pip-install: gersemi
- name: Format CMake Files
run: gersemi --in-place ${{ github.workspace }}
- name: Save Changes
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
if: github.ref_type != 'tag'
env:
HOME: ${{ github.workspace }}
with:
default_author: github_actions
message: 'Automatic CMake Format: Standardized formatting automatically'
fetch: 'false'
json:
name: Json
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Checkout Pull Request
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.AUTOFORMAT_COMMIT_TOKEN }}
fetch-depth: 1
- name: Format JSON Files
run: |
set -o pipefail
git ls-files '*.json' | xargs -r -I{} sh -c 'jq --tab . {} > {}.tmp && mv {}.tmp {}'
- name: Save Changes
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
if: github.ref_type != 'tag'
env:
HOME: ${{ github.workspace }}
with:
default_author: github_actions
message: 'Automatic Json Format: Standardized formatting automatically'
fetch: 'false'
perl:
name: Perl
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Checkout Pull Request
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.AUTOFORMAT_COMMIT_TOKEN }}
fetch-depth: 1
- name: Setup Perl
uses: shogo82148/actions-setup-perl@5a2f3b681f2e2fa0db6cc52c7608d9916527aa58 # v1.40.0
with:
install-modules: 'Perl::Tidy'
- name: Format Perl Files
run: |
set -o pipefail
git ls-files '*.pl' '*.pm' | xargs perltidy -b -bext='/'
- name: Save Changes
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
if: github.ref_type != 'tag'
env:
HOME: ${{ github.workspace }}
with:
default_author: github_actions
message: 'Automatic Perl Tidy: Standardized formatting automatically'
fetch: 'false'
asm:
name: Assembly
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Checkout Pull Request
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.AUTOFORMAT_COMMIT_TOKEN }}
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: 'stable'
cache: false
- name: Install asmfmt
run: |
set -o pipefail
go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
- name: Format Assembly Files
run: |
set -o pipefail
git ls-files '*.s' '*.asm' | xargs -r asmfmt -w -e
- name: Save Changes
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
if: github.ref_type != 'tag'
env:
HOME: ${{ github.workspace }}
with:
default_author: github_actions
message: 'Automatic Assembly Format: Standardized formatting automatically'
fetch: 'false'
web:
name: Web
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Checkout Pull Request
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.AUTOFORMAT_COMMIT_TOKEN }}
fetch-depth: 1
- name: Setup NodeJS
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
- name: Install Prettier
run: npm install -g --no-fund prettier
- name: Format Web Files
run: |
set -o pipefail
echo "<details open><summary>Prettier Output</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
git ls-files 'Web/*.html' 'Web/*.css' 'Web/*.js' | xargs -r prettier --write --use-tabs 2>&1 | tee -a $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
- name: Save Changes
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
if: github.ref_type != 'tag'
env:
HOME: ${{ github.workspace }}
with:
default_author: github_actions
message: 'Automatic Web Format: Standardized formatting automatically'
fetch: 'false'
all:
name: Completed All Auto Formatters
needs: [ clang, cmake, json, perl, asm, web ]
runs-on: ubuntu-slim
permissions: { }
if: always()
steps:
- name: Fail Auto Format
if: >
${{
needs.clang.result != 'success' ||
needs.cmake.result != 'success' ||
needs.json.result != 'success' ||
needs.perl.result != 'success' ||
needs.asm.result != 'success' ||
needs.web.result != 'success'
}}
run: |
echo "One or more auto format jobs have failed."
echo "Please check the individual job logs for details."
exit 1
- name: Complete Auto Format
run: |
echo "Auto Format has been completed for Clang, CMake, JSON, Perl, and Web files."
echo "Please refer to the individual job logs for detailed formatting information."