-
Notifications
You must be signed in to change notification settings - Fork 201
158 lines (131 loc) · 4.79 KB
/
Copy pathsyntax-checks.yml
File metadata and controls
158 lines (131 loc) · 4.79 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
---
name: Validate syntax
'on':
- push
- pull_request
permissions: {}
jobs:
json-syntax:
name: JSON
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate syntax for JSON files
run: |
error=0
readarray -d '' json_files < \
<(find . \( -path ./.git -or -path ./DATA/testing/private \) -prune -false -or -type f -name '*.json' -print0)
for jsonf in "${json_files[@]}"; do
echo "::debug::Checking $jsonf..."
if ! errmsg=$(jq . "$jsonf" 2>&1 >/dev/null); then
error=1
echo "Invalid JSON syntax found in $jsonf:" >&2
printf '::error file=%s,title=%s::%s\n' "$jsonf" 'Invalid JSON syntax' "$errmsg"
fi
done
exit "$error"
bash-syntax:
name: Bash
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate syntax with bash -n
run: |
error=0
readarray -d '' files < \
<(find . -path ./.git -prune -false -or -type f -name '*.sh' -print0)
for bashf in "${files[@]}"; do
echo "::debug::Checking $bashf..."
if ! errmsg=$(bash -n "$bashf" 2>&1 >/dev/null); then
error=1
echo "Invalid Bash syntax found in $bashf:" >&2
printf '::error file=%s,title=%s::%s\n' "$bashf" 'Invalid syntax' "$errmsg"
fi
done
exit "$error"
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Shellcheck to find errors
run: |
error=0
find . -path ./.git -prune -false -or -type f -name '*.sh' -print0 |
xargs -0 shellcheck -xf json1 -S error -s bash > errors.json || error=$?
# Produce code annotations in GitHub's format.
jq -r '.comments[] | "Error found in \(.file) line \(.line):\n::error file=\(.file),line=\(.line),endLine=\(.endLine),col=\(.column),endColumn=\(.endColumn)::\(.message)"' errors.json
exit "$error"
config-check:
name: Config-check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run .ini configs check
run: |
error=0
readarray -d '' files < \
<(find . -path ./.git -prune -false -or -type f -name '*.ini' -print0)
for cfg in "${files[@]}"; do
if grep -q "O2DPG_ROOT" "$cfg"; then
error=1
echo "Deprecated O2DPG_ROOT detected in $cfg, replace with O2DPG_MC_CONFIG_ROOT" >&2
fi
done
exit "$error"
- name: Run .C configs check
run: |
error=0
readarray -d '' files < \
<(find . -path ./.git -prune -false -or -type f -name '*.C' -print0)
for cfg in "${files[@]}"; do
if grep -q "\$O2DPG_ROOT" "$cfg" || grep -q "\${O2DPG_ROOT}" "$cfg"; then
error=1
echo "Deprecated O2DPG_ROOT detected in $cfg, replace with O2DPG_MC_CONFIG_ROOT" >&2
fi
done
exit "$error"
runner-tests:
name: Workflow-runner unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install prerequisites
run: pip install pytest psutil
- name: Run the o2dpg_runner test suite
working-directory: MC/workflow_runner
run: pytest o2dpg_runner/tests -q
filegraph-tests:
name: File-IO-graph unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install prerequisites
run: pip install psutil
- name: Run the FileIOGraph test suite
run: python3 -m unittest discover -s UTILS/FileIOGraph/tests -t UTILS/FileIOGraph/tests
pylint:
name: Pylint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install prerequisites
run: |
sudo apt update -y
sudo apt install -y pylint
- name: Run Pylint to find errors
run: |
error=0
find . -path ./.git -prune -false -or -type f -name '*.py' -print0 |
# "import-errors" are shown for valid modules like ROOT, so ignore them.
xargs -0 pylint -E -f json --disable import-error > errors.json || error=$?
# Produce code annotations in GitHub's format.
jq -r '.[] | "Error found in \(.path) line \(.line):\n::error file=\(.path),line=\(.line),endLine=\(.endLine),col=\(.column),endColumn=\(.endColumn),title=Pylint \(.type) \(.symbol)::\(.message)"' errors.json
exit "$error"