forked from oceanbase/obshell-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aci.yml
76 lines (65 loc) · 2.34 KB
/
.aci.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
version: "2.0"
only:
triggerType:
- pullRequest
- tagPush
- push
stages:
- 合规扫描
- 代码检查
jobs:
Header 扫描:
stage: 合规扫描
component: shell-with-clone
inputs:
script: |
#!/bin/bash
TARGET_DIR="${BASE_WORKSPACE}"
echo "$TARGET_DIR"
COPYRIGHT_TEXT=$'/*\n'
COPYRIGHT_TEXT+=$' * Copyright (c) 2024 OceanBase.\n'
COPYRIGHT_TEXT+=$' *\n'
COPYRIGHT_TEXT+=$' * Licensed under the Apache License, Version 2.0 (the "License");\n'
COPYRIGHT_TEXT+=$' * you may not use this file except in compliance with the License.\n'
COPYRIGHT_TEXT+=$' * You may obtain a copy of the License at\n'
COPYRIGHT_TEXT+=$' *\n'
COPYRIGHT_TEXT+=$' * http://www.apache.org/licenses/LICENSE-2.0\n'
COPYRIGHT_TEXT+=$' *\n'
COPYRIGHT_TEXT+=$' * Unless required by applicable law or agreed to in writing, software\n'
COPYRIGHT_TEXT+=$' * distributed under the License is distributed on an "AS IS" BASIS,\n'
COPYRIGHT_TEXT+=$' * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n'
COPYRIGHT_TEXT+=$' * See the License for the specific language governing permissions and\n'
COPYRIGHT_TEXT+=$' * limitations under the License.\n'
COPYRIGHT_TEXT+=$' */'
non_compliant_files=()
temp_file=$(mktemp)
find "$TARGET_DIR" -type f -name "*.go" > "$temp_file"
while IFS= read -r file; do
start_of_file=$(head -n 15 "$file")
if [[ "$start_of_file" != "$COPYRIGHT_TEXT" ]]; then
non_compliant_files+=("$file")
fi
done < "$temp_file"
rm "$temp_file"
if [ ${#non_compliant_files[@]} -ne 0 ]; then
echo -e "\033[31mError: The following files are missing the correct copyright header:\033[0m"
for file in "${non_compliant_files[@]}"; do
echo -e "\033[31m${file}\033[0m"
done
exit 1
else
echo "All files have the correct copyright header."
fi
exit 0
规范检查:
stage: 代码检查
component: golang-sast
inputs:
excludes:
- "**_test.go**"
config:
execute:
timeout: 600
afterExecute:
checkRule:
- ${{outputs.critical}} <= 10