forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.08 KB
/
code-hygiene.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
name: Code Hygiene
on: [push, pull_request]
jobs:
linelint:
runs-on: ubuntu-latest
name: Check if all files end in newline
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Linelint
uses: fernandrone/linelint@0.0.4
spotless:
runs-on: ubuntu-latest
name: Spotless scan
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11
- uses: gradle/gradle-build-action@v2
with:
arguments: spotlessCheck
checkstyle:
runs-on: ubuntu-latest
name: Checkstyle scan
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11
- uses: gradle/gradle-build-action@v2
with:
arguments: checkstyleMain checkstyleTest
spotbugs:
runs-on: ubuntu-latest
name: Spotbugs scan
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11
- uses: gradle/gradle-build-action@v2
with:
arguments: spotbugsMain
check-permissions-order:
runs-on: ubuntu-latest
name: Check permissions orders
steps:
- uses: actions/checkout@v2
- run: npm install yaml
- name: Check permissions order
run: |
exclude_pattern="(^|/)roles_invalidxcontent.yml($|/)
(^|/)invalid_config/config.yml($|/)"
# Set pattern to exclude certain files
set -e
exit_code=0
for file in $(find . -name '*.yml' | grep -Ev "$exclude_pattern"); do
if ! node check-permissions-order.js "$file" --slient; then
exit_code=1
echo "Error: $file requires changes. Run the following command to fix:"
echo "node check-permissions-order.js $file --fix"
fi
done
exit $exit_code